⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcsl_main55.c.bak

📁 TI OMAP5910(1510)的最简单测试程序,用于 硬件最初的调试,简要文档含环境配置
💻 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 + -