各位大神~小弟正在研究2440的spi驱动(非操作系统代码),正在调试dma方式的spi0发-spi1收,spi1接收端如何证明我全部都收到了?希望高手帮忙指教
以下是我的代码:
void Test_Spi_Tx0RX1_DMA(void)
{
int i,j;
SPI_Port_Init(0); //设spi1为s,spi0为m
Uart_Printf("\n[SPI0-1 DMA]\n");
tx_dma1Done=0;
rx_dma3Done=0;
//TX
ptr_tx = (char *) SPI0_BUFFER; //开辟一个空间存要发的数
for(i=0; i<count; i++)
*(ptr_tx+i)=i;
//RX
ptr_rx = (char *) SPI1_BUFFER;//开辟一个空间存要收的数
//设置spi端口
rSPPRE0=0x0; //25Mhz
rSPCON0=(2<<5)|(1<<4)|(1<<3)|(1<<2)|(0<<1)(0<<0);
//DMA1,enSCK,master,low,A,normal
rSPPIN0=(0<<2)|(1<<1)|(0<<0);//dis-ENMUL,SBO,release
rSPPRE1=0x0; //25Mhz
rSPCON1=(2<<5)|(0<<4)|(0<<3)|(1<<2)|(0<<1)|(1<<0);//DMA3,dis-SCK,slave,low,A,TAGD
rSPPIN1=(0<<2)|(1<<1)|(0<<0);//dis-ENMUL,SBO,release
//set DMA1
rDISRC1=(unsigned)ptr_tx; //Address of src
rDISRCC1=(0<<1)|(0); //AHB(Memory), inc
rDIDST1=(unsigned)0x59000010;//Address of SPTDAT0 Register
rDIDSTC1=(1<<1)|(1); //APB(SPI), fix
rDCON1=((unsigned int)1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(3<<24)|(1<<23)|(1<<22)|(0<<20)|(count);
//handshake, sync PCLK, TC int, single tx, single service, SPI0, H/W request,
//off-reload, byte, 128Bytes
rDMASKTRIG1=(0<<2)|(1<<1)|(1);
//set DMA3
rDISRC3=(unsigned)0x59000034;//Address of SPRDAT1 Register
rDISRCC3=(1<<1)|(1); //APB(SPI), fix
rDIDST3=(unsigned)ptr_rx; //Address of rx buffer
rDIDSTC3=(0<<1)|(0); //AHB(Memory), inc
rDCON3=((unsigned int)1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(2<<24)|(1<<23)|(1<<22)|(0<<20)|(count);
//handshake, sync PCLK, TC int, single tx, single service, SPI1, H/W request,
//off-reload, byte, 128Bytes
rDMASKTRIG3=(0<<2)|(1<<1)|(1);
rSPTDAT1 = 0xff;
pISR_DMA1 = (unsigned)Dma1Tx_Int;
rINTMSK=~(BIT_DMA1);
if(!(rSPSTA1&0x1))
{
pISR_DMA3 = (unsigned)Dma3Rx_Int;
rINTMSK=~(BIT_DMA3);
}
Uart_Printf("rSPTDAT0 = %d\n",rSPTDAT0);
Uart_Printf("rSPRDAT1 = %d\n",rSPRDAT1);
Uart_Printf("****************************************\n");
for(i=0; i<count; i++)
Uart_Printf("rSPTDAT0 = %d\n",*(ptr_tx++));
for(j=0; j<count; j++)
Uart_Printf("rSPRDAT1 = %d\n",*(ptr_rx++));
Uart_Printf("DMA1-3 end\n");
}
//中断服务程序
void __irq Dma1Tx_Int(void)
{
rINTMSK|=BIT_DMA1;
ClearPending(BIT_DMA1);
}
void __irq Dma3Rx_Int(void)
{
rINTMSK|=BIT_DMA3;
ClearPending(BIT_DMA3);
}
期待大师们的解答 |