/*
* ip_functions.c
*
* Contains all functions which pertain to setup and use of IP periperals.
*/
#include "adventures_with_ip.h"
#include "audio.h"
/* ---------------------------------------------------------------------------- *
* lms_filter() *
* ---------------------------------------------------------------------------- *
* This function adds a tonal noise component to the sampled audio from the
* audio codec by passing a step size to the input of an NCO component in the
* PL. A sinusoidal signal is received back from the NCO which is then scaled
* and added to the sampled audio. The audio + noise sample can then be
* adaptively filtered using an LMS filter in the PL. The resulting audio,
* filtered or not, is then output to the audio codec.
*
* The main menu can be accessed by entering 'q' on the keyboard.
* ---------------------------------------------------------------------------- */
void lms_filter()
{
u32 nco_in, nco_out, in_left, in_right, out_left, out_right, step, \
prevL, prevR, prevTone, temp;
/* Read step size value from DIP switches */
step = XGpio_DiscreteRead(&Gpio, SWITCH_CHANNEL);
/* Write step size value to the LEDs */
Xil_Out32(LED_BASE, step);
/* Scale the step size */
nco_in = step;
xil_printf("Step = %d, nco_in = %d\r\n",step, nco_in);
while (!XUartPs_IsReceiveData(UART_BASEADDR)){
/* Input step size to the NCO core */
XNco_Set_step_size_V(&Nco, nco_in);
/* Receive sinusoidal sample from NCO core */
nco_out = XNco_Get_sine_sample_V(&Nco);
if(nco_out!=prevTone) { /* New sinusoidal sample? */
temp = nco_out;
}
/* Sample L+R audio from the codec */
in_left = Xil_In32(I2S_DATA_RX_L_REG);
in_right = Xil_In32(I2S_DATA_RX_R_REG);
/* -------------------------------------------------------------------------------- *
* --------------------------------- LEFT CHANNEL --------------------------------- *
* -------------------------------------------------------------------------------- */
if(in_left != prevL) /* New left sample? */
{
/* Add noise component to the L+R audio samples */
out_left = (temp + in_left);
Xil_Out32(LMS_D, out_left >> SCALE); // Input audio+noise as desired signal
Xil_Out32(LMS_X, temp >> SCALE); // Input noise as input
Xil_Out32(LMS_STROBE, 0x01); // Stobe LMS to signal inputs are finished
/* If any button is pressed */
if(XGpio_DiscreteRead(&Gpio, BUTTON_CHANNEL)>0){
/* Wait until output data is ready */
out_left = (Xil_In32(LMS_E) << (SCALE-1)); // Output filtered audio
}
/* Output audio to the codec */
Xil_Out32(I2S_DATA_TX_L_REG, out_left);
}
/* -------------------------------------------------------------------------------- *
* --------------------------------- RIGHT CHANNEL -------------------------------- *
* -------------------------------------------------------------------------------- */
if(in_right != prevR) /* New right sample? */
{
/* Add scaled noise component to the L+R audio samples */
out_right = (temp + in_right);
Xil_Out32(LMS_D, out_right >> SCALE); // Input audio+noise as desired signal
Xil_Out32(LMS_X, temp >> SCALE); // Input noise as input
Xil_Out32(LMS_STROBE, 0x01); // Stobe LMS to signal inputs are finished
/* If any button is pressed */
if(XGpio_DiscreteRead(&Gpio, BUTTON_CHANNEL)>0){
out_right = (Xil_In32(LMS_E) << (SCALE-1)); // output filtered audio
}
/* Output audio to the codec */
Xil_Out32(I2S_DATA_TX_R_REG, out_right);
}
/* Update previous input values */
prevL = in_left;
prevR = in_right;
prevTone = nco_out;
/* If the DIP switch values have changed, break from while
* loop to allow the step size value to update.
*/
if(step != XGpio_DiscreteRead(&Gpio, SWITCH_CHANNEL)) break;
} // while
/* If input from the terminal is 'q', then return to menu.
* Else, continue. */
if(XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET)=='q') menu();
else lms_filter();
} // LMS filtering
/* ---------------------------------------------------------------------------- *
* tonal_noise() *
* ---------------------------------------------------------------------------- *
* This function adds a tonal noise component to the sampled audio from the
* audio codec by passing a step size to the input of an NCO component in the
* PL. A sinusoidal signal is received back from the NCO which is then scaled
* and added to the sampled audio. The audio + noise sample is then sent to
* the audio codec for output.
*
* The main menu can be accessed by entering 'q' on the keyboard.
* ---------------------------------------------------------------------------- */
void tonal_noise(void)
{
u32 nco_in, nco_out, in_left, in_right, out_left, out_right, step, temp;
/* Read step size value from DIP switches */
step = XGpio_DiscreteRead(&Gpio, SWITCH_CHANNEL);
/* Write step size value to the LEDs */
Xil_Out32(LED_BASE, step);
/* Scale the step size */
nco_in = step;
xil_printf("Step = %d, nco_in = %d\r\n",step, nco_in);
while (!XUartPs_IsReceiveData(UART_BASEADDR)){
/* Input scaled step size to the NCO core */
XNco_Set_step_size_V(&Nco, nco_in);
/* Receive sinusoidal sample from NCO core */
nco_out = XNco_Get_sine_sample_V(&Nco);
temp = nco_out;
/* Sample L+R audio from the codec */
in_left = Xil_In32(I2S_DATA_RX_L_REG);
in_right = Xil_In32(I2S_DATA_RX_R_REG);
/* Add scaled noise component to the L+R audio samples */
out_left = temp + in_left;
out_right = temp + in_right;
/* Output corrupted audio to the codec */
Xil_Out32(I2S_DATA_TX_L_REG, out_left);
Xil_Out32(I2S_DATA_TX_R_REG, out_right);
/* If the DIP switch values have changed, break from while
* loop to allow the step size value to update.
*/
if(step != XGpio_DiscreteRead(&Gpio, SWITCH_CHANNEL)) break;
} // while
/* If input from the terminal is 'q', then return to menu.
* Else, continue. */
if(XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET) == 'q') menu();
else tonal_noise();
} // tonal_noise()
/* ---------------------------------------------------------------------------- *
* audio_stream() *
* ---------------------------------------------------------------------------- *
* This function performs audio loopback streaming by sampling the input audio
* from the codec and then immediately passing the sample to the output of the
* codec.
*
* The main menu can be accessed by entering 'q' on the keyboard.
* ---------------------------------------------------------------------------- */
void audio_stream(){
//int index = 0;
u32 in_left, in_right;
while (!XUartPs_IsReceiveData(UART_BASEADDR)){
// Read audio input from codec
in_left = Xil_In32(I2S_DATA_RX_L_REG);
in_right = Xil_In32(I2S_DATA_RX_R_REG);
// Write audio input to codec
Xil_Out32(I2S_DATA_TX_L_REG, in_left);
Xil_Out32(I2S_DATA_TX_R_REG, in_right);
}
/* If input from the terminal is 'q', then return to menu.
* Else, continue streaming. */
if(XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET) == 'q') menu();
else audio_stream();
} // audio_stream()
/* ---------------------------------------------------------------------------- *
* gpio_initi() *
* ---------------------------------------------------------------------------- *
* Initialises the GPIO driver for the push buttons and switches.
* ---------------------------------------------------------------------------- */
unsigned char gpio_init()
{
int Status;
Status = XGpio_Initialize(&Gpio, BUTTON_SWITCH_ID);
if(Status != XST_SUCCESS) return XST_FAILURE;
Status = XGpio_Initialize(&Gpio_audio_enable, AUDIO_ENABLE_ID);
if(Status != XST_SUCCESS) return XS
没有合适的资源?快使用搜索试试~ 我知道了~
嵌入式电子工程师资料合集 9.FPGA
共118个文件
doc:29个
pdf:18个
c:14个
需积分: 9 3 下载量 42 浏览量
2022-04-25
15:54:52
上传
评论
收藏 90.25MB RAR 举报
温馨提示
嵌入式电子工程师资料合集 9.FPGA
资源详情
资源评论
资源推荐
收起资源包目录
嵌入式电子工程师资料合集
9.FPGA (118个子文件)
Untitled Project 2.aliases 110B
ip_functions.c 9KB
ip_functions.c 9KB
audio.c 8KB
interrupt_counter_tut_2D.c 6KB
interrupt_counter_tut_2D.c 6KB
interrupt_counter_tut_2B.c 4KB
interrupt_counter_tut_2B.c 4KB
audio.c 4KB
adventures_with_ip.c 3KB
adventures_with_ip.c 3KB
LED_test_tut_1C.c 3KB
LED_test_tut_1C.c 3KB
led_controller_test_tut_4A.c 2KB
led_controller_test_tut_4A.c 2KB
nco.cpp 76KB
matrix_mult_test.cpp 2KB
matrix_mult_test.cpp 2KB
nco_tb.cpp 1KB
matrix_mult.cpp 585B
matrix_mult.cpp 585B
8.19 电梯控制器程序设计与仿真.doc 252KB
8.21 自动售货机VHDL程序与仿真.doc 200KB
8.17 采用等精度测频原理的频率计程序与仿真.doc 172KB
8.16 频率计程序设计与仿真.doc 147KB
8.22 出租车计价器VHDL程序与仿真.doc 138KB
华为FPGA设计流程指南.doc 132KB
8.14 MPSK调制与解调VHDL程序与仿真.doc 123KB
8.20 电子时钟VHDL程序与仿真.doc 115KB
8.11 PSK调制与解调VHDL程序及仿真.doc 113KB
8.18 电子琴程序设计与仿真 2004.8修改.doc 107KB
8.18 电子琴程序设计与仿真.doc 106KB
8.13 MFSK调制VHDL程序及仿真.doc 90KB
8.8 URAT VHDL程序与仿真.doc 86KB
8.10 FSK调制与解调VHDL程序及仿真.doc 86KB
8.15 基带码发生器程序设计与仿真.doc 78KB
8.9 ASK调制与解调VHDL程序及仿真.doc 67KB
8.23 波形发生程序.doc 61KB
8.22 出租车计价器VHDL程序与仿真 2004.8修改.doc 60KB
8.12 MASK调制VHDL程序及仿真.doc 60KB
8.2 LED控制VHDL程序与仿真.doc 34KB
8.2 LED控制VHDL程序与仿真 2004.8修改.doc 34KB
8.3 LCD控制VHDL程序与仿真 2004.8修改.doc 32KB
8.24 步进电机定位控制系统VHDL程序与仿真.doc 31KB
8.3 LCD控制VHDL程序与仿真.doc 26KB
8.4 ADC0809 VHDL控制程序.doc 24KB
8.7 TLC7524接口电路程序.doc 23KB
8.5 TLC5510 VHDL控制程序.doc 21KB
8.6 DAC0832 接口电路程序.doc 21KB
~$16 频率计程序设计与仿真.doc 162B
audio.h 3KB
adventures_with_ip.h 3KB
adventures_with_ip.h 3KB
audio.h 1KB
lms_pcore_addr.h 784B
lms_pcore_addr.h 784B
matrix_mult.h 544B
matrix_mult.h 544B
UntitledProject2_FPGATarget_Untitled2_wGPC87C8Mk8.lvbitx 5.23MB
UntitledProject2_FPGATarget_Untitled2_0NgihkQgjZA.lvbitx 5.23MB
UntitledProject2_FPGATarget_Untitled2_DBKI7hBgQWk.lvbitx 5.23MB
Untitled Library 1.lvlib 2KB
Untitled Project 2.lvlps 85B
Untitled Project 2.lvproj 28KB
playback.m 309B
setup.m 208B
《Verilog HDL数字设计与综合》.pdf 13.35MB
The_Zynq_Book_Tutorials_Aug_15.pdf 11.65MB
数字信号处理的FPGA实现中文版.pdf 7.29MB
Verilog数字系统设计教程(第二版) 夏宇闻.pdf 6.98MB
《FPGA权威指南(英文版)》.pdf 4.04MB
FPGA基础知识.pdf 2.13MB
Verilog HDL 代码书写规范.pdf 211KB
The_Zynq_Book_ebook_chinese.pdf 23.35MB
Digital Signal Processing with Field Programmable Gate Arrays(Third Edition).pdf 12.12MB
FPGA设计高级技巧Xilinx篇.pdf 2.94MB
Verilog经典教程(夏宇闻).pdf 1.7MB
VHDL语言详解(修正版).pdf 1.2MB
fpga应用经验谈.pdf 1.11MB
VHDL课件.pdf 621KB
静态时序分析与逻辑...pdf 598KB
Verilog基本电路设计指导书.pdf 384KB
Verilog_HDL_华为入门教程.pdf 309KB
Verilog+HDL入门教程.pdf 281KB
VHDL设计风格和实现.ppt 427KB
vssver2.scc 202B
vssver2.scc 202B
vssver2.scc 201B
vssver2.scc 110B
lms.slx 18KB
run_hls_zybo.tcl 801B
run_hls_zed.tcl 801B
run_hls_zybo.tcl 801B
run_hls_zed.tcl 801B
led_controller_v1_0_S00_AXI.vhd 15KB
led_controller_v1_0_S00_AXI.vhd 15KB
led_controller_v1_0.vhd 4KB
led_controller_v1_0.vhd 4KB
RT.vi 507KB
FPGA.vi 64KB
共 118 条
- 1
- 2
ヘ错觉
- 粉丝: 2
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 前端开发-什么是前端开发-关于前端开发的一些相关介绍
- Sora AI-关于文生视频的使用场景说明
- suno AI文生视频的相关教程和介绍使用
- 什么是后端开发-关于后端开发的一些小介绍分享
- Jurassic Pack Vol. II Dinosaurs 侏罗纪包卷恐龙二号Unity游戏模型资源unitypackage
- Jurassic Pack Vol. III Dinosaurs 侏罗纪包卷恐龙三号Unity游戏模型资源unitypackag
- Ultimate Seating Controller 终极座椅控制器Unity游戏开发插件资源unitypackage
- 什么是人工智能-关于人工智能的相关介绍说明
- Figma Converter for Unity适用Unity的Figma转换器Unity游戏开发插件unitypackage
- Creepy Animatronic Anims 令人毛骨悚然的电子动画Unity游戏动画插件资源unitypackage
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0