📄 main.c
字号:
//--------------------------------------------------------------------------//
// //
// Name: Talkthrough for the ADSP-BF533 EZ-KIT Lite //
// //
//--------------------------------------------------------------------------//
// //
// (C) Copyright 2006 - Analog Devices, Inc. All rights reserved. //
// //
// Project Name: BF533 C Talkthrough I2S //
// //
// Date Modified: 04/03/03 Rev 1.0 //
// //
// Software: VisualDSP++4.5 //
// //
// Hardware: ADSP-BF533 EZ-KIT Board //
// //
// Connections: Connect RSCLK0 to TSCLK0 together (Turn SW9 pin 6 on) //
// Connect RFS0 to TFS0 together (Turn SW9 pin 5 ON) // Connect an input source (such as a radio) to the Audio //
// input jack and an output source (such as headphones) to //
// the Audio output jack //
// //
// Purpose: This program sets up the SPI port on the ADSP-BF533 to //
// configure the AD1836 codec. The SPI port is disabled //
// after initialization. The data to/from the codec are //
// transfered over SPORT0 in I2S mode //
// //
//--------------------------------------------------------------------------//
#include "Talkthrough.h"
#include "sysreg.h"
#include "ccblkfn.h"
//--------------------------------------------------------------------------//
// Variables //
// //
// Description: The variables iChannelxLeftIn and iChannelxRightIn contain //
// the data coming from the codec AD1836. The (processed) //
// playback data are written into the variables //
// iChannelxLeftOut and iChannelxRightOut respectively, which //
// are then sent back to the codec in the SPORT0 ISR. //
// The values in the array iCodec1836TxRegs can be modified to //
// set up the codec in different configurations according to //
// the AD1885 data sheet. //
//--------------------------------------------------------------------------//
// left input data from ad1836
int iChannel0LeftIn, iChannel1LeftIn;
// right input data from ad1836
int iChannel0RightIn, iChannel1RightIn;
// left ouput data for ad1836
int iChannel0LeftOut, iChannel1LeftOut;
// right ouput data for ad1836
int iChannel0RightOut, iChannel1RightOut;
// array for registers to configure the ad1836
// names are defined in "Talkthrough.h"
volatile short sCodec1836TxRegs[CODEC_1836_REGS_LENGTH] =
{
DAC_CONTROL_1 | 0x000,
DAC_CONTROL_2 | 0x000,
DAC_VOLUME_0 | 0x3ff,
DAC_VOLUME_1 | 0x3ff,
DAC_VOLUME_2 | 0x3ff,
DAC_VOLUME_3 | 0x3ff,
DAC_VOLUME_4 | 0x000,
DAC_VOLUME_5 | 0x000,
ADC_CONTROL_1 | 0x000,
ADC_CONTROL_2 | 0x000,
ADC_CONTROL_3 | 0x000
};
// SPORT0 DMA transmit buffer
volatile int iTxBuffer1[4];
// SPORT0 DMA receive buffer
volatile int iRxBuffer1[4];
iir_state_fr16 LP_filt;
iir_state_fr16 HP_filt;
fract16 LP_delay[4] = {0, 0, 0, 0};
fract16 LP_coeffs[10];
fract16 HP_delay[4] = {0, 0, 0, 0};
fract16 HP_coeffs[10];
//--------------------------------------------------------------------------//
// Function: main //
// //
// Description: After calling a few initalization routines, main() just //
// waits in a loop forever. The code to process the incoming //
// data can be placed in the function Process_Data() in the //
// file "Process_Data.c". //
//--------------------------------------------------------------------------//
void main(void)
{
LP_coeffs[0] = float_to_fr16(0.6372369528 / 1.535104036);
LP_coeffs[1] = float_to_fr16(-1.535104036 / -1.535104036);
LP_coeffs[2] = float_to_fr16(1.0 / 2.0);
LP_coeffs[3] = float_to_fr16(2.0 / 2.0);
LP_coeffs[4] = float_to_fr16(1.0 / 2.0);
LP_coeffs[5] = float_to_fr16(0.8432114124 / 1.466933489);
LP_coeffs[6] = float_to_fr16(-1.466933489 / 1.466933489);
LP_coeffs[7] = float_to_fr16(1.0 / 2.0);
LP_coeffs[8] = float_to_fr16(2.0 / 2.0);
LP_coeffs[9] = float_to_fr16(1.0 / 2.0);
HP_coeffs[0] = float_to_fr16(-0.1368679255 );
HP_coeffs[1] = float_to_fr16(0.4791774154);
HP_coeffs[2] = float_to_fr16(1);
HP_coeffs[3] = float_to_fr16(0.7790518403);
HP_coeffs[4] = float_to_fr16(1);
HP_coeffs[5] = float_to_fr16(-0.6737909913 );
HP_coeffs[6] = float_to_fr16(1.07370162);
HP_coeffs[7] = float_to_fr16(1);
HP_coeffs[8] = float_to_fr16(-0.8766128421);
HP_coeffs[9] = float_to_fr16(1);
iir_init(LP_filt, LP_coeffs, LP_delay, 2);
iir_init(HP_filt, HP_coeffs, HP_delay, 2);
sysreg_write(reg_SYSCFG, 0x32); //Initialize System Configuration Register
Init_EBIU();
Init_Flash();
Init1836();
Init_Sport0();
Init_DMA();
Init_Interrupts();
Enable_DMA_Sport0();
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -