📄 main.c
字号:
//--------------------------------------------------------------------------//
// //
// Name: Talkthrough for the ADSP-BF561 EZ-KIT Lite //
// //
//--------------------------------------------------------------------------//
// //
// (C) Copyright 2003 - Analog Devices, Inc. All rights reserved. //
// //
// Project Name: BF561 C Talkthrough TDM //
// //
// Date Modified: 16/10/03 HD Rev 0.2 //
// //
// Software: VisualDSP++3.5 //
// //
// Hardware: ADSP-BF561 EZ-KIT Board //
// //
// Connections: Dipswitch SW4 : set #6 to "on" //
// Dipswitch SW4 : set #5 to "off" //
// 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-BF561 to //
// configure the AD1836 codec. The SPI port is disabled //
// after initialization. The data to/from the codec are //
// transfered over SPORT0 in TDM mode //
// //
//--------------------------------------------------------------------------//
#include "Talkthrough.h"
#include "sysreg.h"
#include "ccblkfn.h"
#include <btc.h>
#include <fract.h>
#include <filter.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 AD1836 data sheet. //
//--------------------------------------------------------------------------//
fract16 coefs[2*NUM_TAPS] = {
#include "IIR_BP_coef2_1.dat"
};
fract16 delay[2*(NUM_TAPS+NUM_TAPS)];
iir_state_fr16 state; // declare filter state
//------------------------------
// left input data from ad1836
fract16 iChannel0LeftIn, iChannel1LeftIn;
// right input data from ad1836
fract16 iChannel0RightIn, iChannel1RightIn;
// left ouput data for ad1836
fract16 iChannel0LeftOut, iChannel1LeftOut;
// right ouput data for ad1836
fract16 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 | 0x010,
DAC_CONTROL_2 | 0x000,
DAC_VOLUME_0 | 0x3ff,
DAC_VOLUME_1 | 0x3ff,
DAC_VOLUME_2 | 0x3ff,
DAC_VOLUME_3 | 0x3ff,
DAC_VOLUME_4 | 0x3ff,
DAC_VOLUME_5 | 0x3ff,
ADC_CONTROL_1 | 0x024,
ADC_CONTROL_2 | 0x220,
ADC_CONTROL_3 | 0x000
};
// SPORT0 DMA transmit buffer0
fract16 iTxBuffer0[2*VEC_SIZE];
// SPORT0 DMA receive buffer0
fract16 iRxBuffer0[2*VEC_SIZE];
// SPORT0 DMA transmit buffer1
fract16 iTxBuffer1[2*VEC_SIZE];
// SPORT0 DMA receive buffer1
fract16 iRxBuffer1[2*VEC_SIZE];
dma_register_t pDmaDescR0;
dma_register_t pDmaDescT0;
dma_register_t pDmaDescR1;
dma_register_t pDmaDescT1;
int dmaFlag = 0;
////////////////////
// BTC Definitions
////////////////////
#define MAXBTCBUF 24000
long BTCLeft[MAXBTCBUF];
long BTCRight[MAXBTCBUF];
int BTCLeftVolume = 0;
int BTCRightVolume = 0;
BTC_MAP_BEGIN //Channel Name, Starting Address, Length (bytes)
BTC_MAP_ENTRY("Audio Left Channel", (long)&BTCLeft, sizeof(BTCLeft))
BTC_MAP_ENTRY("Audio Right Channel", (long)BTCRight, sizeof(BTCRight))
BTC_MAP_ENTRY("Audio Left Volume", (long)&BTCLeftVolume, sizeof(BTCLeftVolume))
BTC_MAP_ENTRY("Audio Right Volume", (long)&BTCRightVolume, sizeof(BTCRightVolume))
BTC_MAP_END
//--------------------------------------------------------------------------//
// 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)
{
Init1836();
Init_Sport0();
Init_DMA();
Init_Sport_Interrupts();
Enable_DMA_Sport0();
btc_init();
int i ;
fract16 tmp[NUM_TAPS*2];
for(i = 0; i<NUM_TAPS*2;i++)
{
tmp[i] = coefs[i];
}
for (i = 0; i < NUM_TAPS;i++)
{
coefs[2*i] = tmp[i];
coefs[2*i+1] = tmp[NUM_TAPS+i];
}
coefs[0] = 0;
while(1)
{
btc_poll();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -