mcbsp_dma.c

来自「dsp在音频处理中的运用」· C语言 代码 · 共 64 行

C
64
字号


#include <stdio.h>
#include <csl_mcbsp.h>
//#include <csl_dma.h>
//#include <csl_ssw.h>
//#include <csl_clkrst.h>
//#include <soc.h>
#include <string.h>
//#include <csl_test_fw.h>

/*-------Macro that gives 2 CLK delay cycles---------*/
#define WAIT_FOR_2_CLK   {                                   \
                               volatile int delayCnt = 2;      \
                               while(delayCnt > 0) --delayCnt; \
                         } 


#define SINE_TABLE_SIZE     48
extern CSL_McbspObj myMcbspObj;
//extern CSL_DmaObj dmaObj;
void tone()
{ 
  Int16 tone2100[48]=
  {
    0x0000,0x22bf,0x42e1,0x5dfe,0x720d,0x7d8a,0x7f9b,0x7817,0x678e,0x4f3e,0x30fc,0x0f0b,0xebfa,0xca69,0xacdf,0x9592,0x8644,0x8019,0x8389,0x9052,0xa57e,0xc175,0xe21e,0x0506,0x278e,0x471d,0x6155,0x743e,0x7e6d,0x7f1d,0x7642,0x6485,0x4b3d,0x2c4e,0x0a0b,0xe707,0xc5e4,0xa91d,0x92dd,0x84ce,0x8000,0x84ce,0x92dd,0xa91d,0xc5e4,0xe707,0x0a0b,0x2c4e
  };
  Int16 msec, sample;
  CSL_McbspHandle hMcbsp1;
  CSL_DmaHandle hDma;
  //CSL_DmaParam    dmaParam;
  CSL_BitMask16   ctrlMask;
  sMcbsp1_init(&hMcbsp1);
  mcbsp1_init(hMcbsp1);
  sDma_init(&hDma);
  dma_init(hDma,tone2100,(Uint32)(&(hMcbsp->regs->DXR1)));
  /*while(1)
	{

		    for ( msec = 0 ; msec < 5000 ; msec++ )
		    {
		        for ( sample = 0 ; sample < SINE_TABLE_SIZE ; sample++ )
		        {
		            /* Send a sample to the left channel */
		            //while ( ! OSK5912_AIC23_write16( hCodec, tone2100[sample] ) );

		            /* Send a sample to the right channel */
		            //while ( ! OSK5912_AIC23_write16( hCodec, tone2100[sample] ) );
		        /*}
		    }
		}*/
   /* Enable DMA channel */
   CSL_dmaHwControl(hDma, CSL_DMA_CMD_START, NULL);//set en bit of CCR 1
   WAIT_FOR_2_CLK;
   ctrlMask = CSL_MCBSP_CTRL_TX_ENABLE | CSL_MCBSP_CTRL_RX_ENABLE;
   CSL_mcbspHwControl(hMcbsp1, CSL_MCBSP_CMD_RESET_CONTROL, &ctrlMask);
   CSL_mcbspClose(hMcbsp1);
   CSL_dmaClose(hDma);

}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?