📄 fftlab.c
字号:
/*****************************************************************************/
/* FIRlab.C AIC,McBSP,DMA initialization for FIR lab Filter */
/* */
/* Goal: This code performs the following functions: */
/* - toggle the three LEDs on the DSK */
/* - setup AIC (CODEC) parameters */
/* - initialize DMA Channel (CH2-input) */
/* - turn on interrupts */
/* - run forever (waiting for DMA interrupts to transfer data) */
/* */
/* Author: Scott Bland Date: 03/20/2000 */
/*****************************************************************************/
/*****************************************************************************/
/* Include Files */
/*****************************************************************************/
#include <type.h>
#include <board.h>
#include <codec.h>
#include <firlab.h>
#include <string.h>
#include <dsplib.h>
/*****************************************************************************/
/* Function Prototypes */
/*****************************************************************************/
void delay(s16 period);
extern void DMAC2ISR();
/*****************************************************************************/
/* Global Variables */
/*****************************************************************************/
HANDLE hHandset;
unsigned int dmsefc, dmmcr, dmctr, src_addr, dst_addr;
unsigned int dmpre, dmsrcp, dmdstp, dmidx0, dmidx1, dmfri0, dmfri1, dmgsa, dmgda, dmgcr, dmgfr;
/* Create specific data section for buffer (symbol, section_name) */
#pragma DATA_SECTION(inp_buffer,"audio_buffer");
DATA inp_buffer[0x200];
/* Create specific data section for buffer (symbol, section_name) */
#pragma DATA_SECTION(out_buffer,"outt_buffer");
DATA out_buffer[0x200];
/* declare and initialize two variables for DMAC ISRs */
int frame=0;
int flag=0;
int temp;
int currbuff = 0;
/* delayptr holds the address of the start of the delay buffer */
interrupt void DMAC2ISR();
/*****************************************************************************/
/* MAIN */
/*****************************************************************************/
void main()
{
s16 cnt=2;
/* These are the items that BIOS will set when we use it */
BSCR = 0x8806;
XPC = 0;
PMST = 0xA0;
brd_set_cpu_freq(100);
TIMER_HALT(0);
brd_set_wait_states(7, 7, 9);
TIMER_RESET(0);
IMR=0; //禁止所有中断
/* ----------------------------------------------------- */
if(brd_init_bios())
return;
while(cnt--)
{
brd_led_toggle(BRD_LED0); //切换LED指示灯0的显示状态
delay(1000);
brd_led_toggle(BRD_LED1); //切换LED指示灯1的显示状态
delay(1000);
brd_led_toggle(BRD_LED2); //切换LED指示灯2的显示状态
delay(1000);
}
/* Open Handset Codec */
hHandset = codec_open(HANDSET_CODEC); /* Acquire handle to codec */
/* Set codec parameters */
codec_dac_mode(hHandset, CODEC_DAC_15BIT); /* DAC in 15-bit mode */
codec_adc_mode(hHandset, CODEC_ADC_15BIT); /* ADC in 15-bit mode */
codec_ain_gain(hHandset, CODEC_AIN_6dB); /* 6dB gain on analog input to ADC */
codec_aout_gain(hHandset, CODEC_AOUT_MINUS_6dB); /* -6dB gain on analog output from DAC */
codec_sample_rate(hHandset,SR_16000); /* 16KHz sampling rate */
/* Clear IFR */
INTR_CLR_FLAG(DMAC2);
/* Reset all DMA channels */
dma_reset_all();
/* Initialize DMA channel 2 */
dmsefc = ((DSYNC_REVT1 <<12));
dmmcr = ((AUTOINIT_ENABLE << 15) | (DINM_ENABLE << 14) | (IMOD_HALFBLOCK <<13) | (CTMOD_DEC <<12) | (INDEXMODE_NOMOD << 8) | (SPACE_DATA << 6) | (INDEXMODE_INC << 2) | (SPACE_DATA));
dmctr = 0xFF;
src_addr = DRR1_ADDR(HANDSET_CODEC);
dst_addr = (unsigned int) &inp_buffer;
dma_init(DMA_CH2, dmsefc, dmmcr, dmctr, SPACE_DATA, src_addr, SPACE_DATA, dst_addr);
/* Set number of frames for channel 2 */
DMA_FRAMECOUNT(DMA_CH2, 1);
/* Set up global autoinit registers for DMA CH2 Input */
dmgsa = src_addr;
dmgda = dst_addr;
dmgcr = 0xFF;
dmgfr = 1;
/* Set up global priority and enable control register for Ch2 */
dmpre = ((HIGH_PRIORITY << 10) | (INTSEL_01 << 6));
dmsrcp = SPACE_DATA;
dmdstp = SPACE_DATA;
dmidx0 = 0;
dmidx1 = 0;
dmfri0 = 0;
dmfri1 = 0;
dma_global_init(dmpre, dmsrcp, dmdstp, dmidx0, dmidx1, dmfri0, dmfri1, dmgsa, dmgda, dmgcr, dmgfr);
/* Enable channel 2 */
DMA_ENABLE(DMA_CH2);
/* prime the serial port to begin input buffer stream */
temp = *(volatile u16*)DRR1_ADDR(HANDSET_CODEC);
/* Enable DMAC2 interrupt */
INTR_ENABLE(DMAC2);
/* Enable Global Interrupts */
INTR_GLOBAL_ENABLE;
/* Endless loop waiting for DMAC2 interrupt */
for(;;);
}
/*****************************************************************************/
/* delay() */
/*****************************************************************************/
void delay(s16 period)
{
int i, j;
for(i=0; i<period; i++)
{
for(j=0; j<period; j++);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -