?? tcsl_main55.c.bak
字號:
//-****************以下部分與csl和dsp bios庫有關,不要改動*********************-//
#include "includes.h"
#include "includes_async.h"
#ifdef OS_BIOS
#include "tsk.h"
#endif
#ifdef OS_BIOS
#define PROCESS_ENTRY(fxn) void fxn()
#else
#define PROCESS_ENTRY(fxn) OS_PROCESS (fxn)
#endif
//-****************************************************************************//
#include "dsp_includes.h"
#include <log.h>
extern LOG_Obj LOG0;
Uint32 src[1024/2],dst[1024/2];
void delay1s(Uint16 ts);
//-*********************************************************//
//跟timer測試相關定義
//跟GPIO測試相關定義
//跟Dma測試相關定義
//跟McBsp測試相關定義
//跟MPUI測試相關定義
//-**************************************************-//
DMA_Handle hdma;
MCBSP_Handle hbsp;
void main(void)
{
Uint16 val=0;
Uint16 i=0,led=1;
Uint16 *wsrc,*wdst;
Uint32 bspv=0;
CSL_init();
//CSL_initAsync();
IRQ_globalDisable();
//跟GPIO測試相關部分
InitDspGpio();
puts("開始測試gpio\n");
InitGpioMode(1,DSP_GPIO_OUT);
for(i=0;i<6;i++){ //燈閃3下
WrGpio(1,led);
led=led^1;
delay1s(10);
}
#if 0
//跟timer測試相關部分
puts("開始測試timer\n");
//
puts("開始測試timer1\n");
InitTimer(TIMER_DEV1,0x0ffff);
IRQ_globalEnable();
// for(i=0;i<10000;i++);
printf("Timer lh %u \n",i);
#endif //
#if 0
//跟Dma測試相關部分
//-*******************************************-//
wsrc=(Uint16*)src;wdst=(Uint16*)dst;
for(i=0;i<1024;i++){
wsrc[i]=i;
wdst[i]=0;
}
GlobalInitDma();
//EXTERNAL DMA_Handle InitDma(Uint16 dev_no,Uint16 prio,Uint16 sync_int,
// Uint16 frm_len,Uint16 elem_len,Uint16 dat_type);
hdma=InitDma(2,0,0,2,512,DMA16BIT);
if(hdma==INV)
puts("invalid dma handle\n");
DmaSetSrcMem(hdma,(void*)wsrc,1,0);
DmaSetDstMem(hdma,(void*)wdst,1,0);
DmaAutoInit(hdma,0);
DmaRepeat(hdma,0);
//void DmaFastSetFrmElemLen(DMA_Handle hDma,Uint16 frm_len,Uint16 elem_len)
DmaFastSetFrmElemLen(hdma,1,1024);
DmaSetInt(hdma,DMA_INT_BLOCK,DmaIsr,3);//0
DmaEndProg(hdma,1);
IRQ_globalEnable();
DmaStart(hdma);
for(i=0;i<32768;i++);
//LOG_printf(&LOG0,"test\n");
for(i=0;i<6;i++){ //燈閃3下
WrGpio(1,led);
led=led^1;
delay1s(10);
}
//-*******************************************-//
i=0;
while(DmaRunning(hdma));
DmaStop(hdma);
while(1){
//i = _PREG_GET(PREG16(_TIMER_RTH1_ADDR));
//i = _PREG_GET(PREG16(_TIMER_RTL1_ADDR));
if(i==0){
WrGpio(1,led);
led=led^1;
}
i++;
i=i&0x7fff;
}
#endif
//-********************************************-//
//軟件中斷測試
//-********************************************-//
//-********************************************-//
//跟McBsp測試相關部分
#if 1
hbsp=InitMcBsp(0);
McBspRxReset(hbsp,0); //0表示復位且disable
McBspTxReset(hbsp,0);
McBspSampleRateGeneratorReset(hbsp,0);
McBspFrameSyncLogicReset(hbsp,0);
McBspSetRxGpio(hbsp,0);//0:接收方向設置為正常
McBspSetTxGpio(hbsp,0);//0:發送方向設置為正常
McBspSetTxFrameWord(hbsp,MCBSP32BIT,256,16,0); //16比特word,幀長256bit,幀寬16bit,延時0
McBspSetRxFrameWord(hbsp,MCBSP32BIT,256,16,0);
McBspSetTxFrame(hbsp,MCBSP_INTERNAL_FS,MCBSP_FS_POLAR_HIGH);
McBspSetRxFrame(hbsp,MCBSP_INTERNAL_FS,MCBSP_FS_POLAR_HIGH);
McBspSetTxClk(hbsp,1,MCBSP_EXTERNAL_SGR_CLK,MCBSP_CLK_POLAR_UP);
McBspSetRxClk(hbsp,1,MCBSP_EXTERNAL_SGR_CLK,MCBSP_CLK_POLAR_UP);
McBspSetRxInt(hbsp,0,MCBSP_INTM_FS,BspRxIsr,1);
McBspSetTxInt(hbsp,0,MCBSP_INTM_FS,BspTxIsr,1);
McBspSampleRateGeneratorReset(hbsp,1);//1表示enable
McBspFrameSyncLogicReset(hbsp,1);
McBspRxReset(hbsp,1);
McBspTxReset(hbsp,1);
McBspStartTx(hbsp);
McBspStartRx(hbsp);
McBspLocalLoopBack(hbsp,1); //設置成自環
IRQ_globalEnable();
MCBSP_write32(hbsp,0x5555aaaa);
while(1){
i=i+1;
//MCBSP_write32(hbsp,0x5555aaaa);
for(i=0;i<255;i++);
bspv=11;
//bspv=MCBSP_read32(hbsp);
// printf("bspv=%l\n",bspv);
}
#endif //跟McBsp測試相關部分
//--********************************************-//
//跟MPUI測試相關部分
//--********************************************-//
}
//-*********************************************************//
//跟timer測試相關定義
//跟GPIO測試相關定義
//跟Dma測試相關定義
//跟McBsp測試相關定義
//跟MPUI測試相關定義
void delay1s(Uint16 ts)
{
Uint32 i=0,j=0;
for(i=0;i<ts;i++)
for(j=0;j<100000;j++);
}
void mcbsp_tx32(MCBSP_Handle hmc,Uint32 val)
{
}
Uint32 mcbsp_rx32(MCBSP_Handle hmc)
{
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -