|
#include "my_include.h"
int DataGeted=0; //数据已生成标记
unsigned int numTransfers_Tx=0; //发送数据块数计数器(中断中使用)
int BlockCnt=0; //处理数据块数计数器(驱动3D0发光管闪动)
int KeyDownFlag;
int KeyDownCnt;
int dat,xx;
//函数声明
extern void fir(); //fir
extern void initial_sys(); //系统初始化(I2C McBSP AIC23 EDMA EMIF etc.)
extern void func();
//Block Data Send interrupt function
//interrupt period=240/48000=0.005s=5ms
long DMARec_p;
interrupt void DMA_tx_Isr()
{
numTransfers_Tx++;
DataGeted=1;
//修改DMA2源地址,并启动DMA2
*DMA_CSR2=(*DMA_CSR2)&(0xfff7);//clear FRAME trasmited flag, B3 ,清除帧中断
if((numTransfers_Tx&0x0001)==1)
{
*DMA_CSSA_U2 =((long)BufferB*2)>>16; //通道目的起始地址Upper 数据地址为0x20000
*DMA_CSSA_L2 =(unsigned int)((long)BufferB*2); //通道目的起始地址Low
DMARec_p = BufferA;
}
else
{
*DMA_CSSA_U2 =((long)BufferA*2)>>16; //通道目的起始地址Upper 数据地址为0x20000
*DMA_CSSA_L2 =(unsigned int)((long)BufferA*2); //通道目的起始地址Low
DMARec_p = BufferB;
}
*DMA_CCR2 =0x1986; //通道使能,不重复,利用McBSP1发送事件进行同步
LBDS1=~uLED[(numTransfers_Tx>>5)&0x7];
}
//Light on/off LED 3D0 to display the Pragram is Running
void BlinkLed(int Flag)
{
if(Flag==0)
// *IODATA=(*IODATA)|(1<<6);//B6=1, GPIO6=1, Light off LED
*IODATA=(*IODATA)&0xffbf;//B6=0, GPIO6=0, Light on LED
else
*IODATA=(*IODATA)&0xffbf;//B6=0, GPIO6=0, Light on LED
}
void main(void)
{
initial_sys(); //初始化
//标红部分自己弄的,想用key1控制fir和func函数的调用,但是怎么改都不成,想法是这样子的:按key1,数码管()就是func的函数)会从0...9闪烁,fir也就成功接入了
while(1)
{
if(KeyDownFlag==1)
{
KeyDownCnt--;
if(KeyDownCnt==0)
KeyDownFlag=0;
}
dat=keyboard & 0x00ff;
if((dat!=0xff)&&(KeyDownFlag==0))//some key is down
{
KeyDownFlag=1;
KeyDownCnt=200; //200*5ms=1s
if(dat==0xf7) //key1 is down
xx=1;
}
if(DataGeted==1&&xx==1)//处理周期为5ms(48000/240=200Hz)
{
xx=0;
DataGeted=0;
*IODATA=(*IODATA)&0xff7f;//B7=0, GPIO7=0, 23J0=1, for test CPU use ratio
BlinkLed((BlockCnt/100)%2); //控制3D0已1Hz的频率闪动
BlockCnt++;
fir();
func();
*IODATA=(*IODATA)|(1<<7);//B7=1, GPIO7=1, 23J0=0, for test CPU use ratio
}//Block data Getted
}//while(1)
}
|
|