下面的程序为2806x的SPI例程的一部分,属于中断加FIFO型。 现在需要将其修改成中断加基本型,如何关掉FIFO?如何修改中断函数?求细节!!
void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI
SpiaRegs.SPICCR.all=0x001F; //16-bit character, Loopback mode
SpiaRegs.SPICTL.all=0x0017; //Interrupt enabled, Master/Slave XMIT enabled
SpiaRegs.SPISTS.all=0x0000;
SpiaRegs.SPIBRR=0x0063; // Baud rate // FEDC BA98 7654 3210 SpiaRegs.SPIFFTX.all=0xC022; // Enable FIFO's, set TX FIFO level to 4 1100 0000 0010 0010
SpiaRegs.SPIFFRX.all=0x0022; // Set RX FIFO level to 4 0000 0000 0010 0010
SpiaRegs.SPIFFCT.all=0x00;
SpiaRegs.SPIPRI.all=0x0010;
SpiaRegs.SPICCR.bit.SPISWRESET=1; // Enable SPI
SpiaRegs.SPIFFTX.bit.TXFIFO=1;
SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;
}
__interrupt void spiTxFifoIsr(void)
{
Uint16 i;
for(i=0;i<2;i++)
{
SpiaRegs.SPITXBUF=sdata[i]; // Send data
}
for(i=0;i<2;i++) // Increment data for next cycle
{
sdata[i] = sdata[i] + 1;
}
SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=0x20; // Issue PIE ACK
}
__interrupt void spiRxFifoIsr(void)
{
Uint16 i;
for(i=0;i<2;i++)
{
rdata[i]=SpiaRegs.SPIRXBUF; // Read data
}
for(i=0;i<2;i++) // Check received data
{
if(rdata[i] != rdata_point+i) error();
}
rdata_point++;
SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1; // Clear Overflow flag
SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=0x20; // Issue PIE ack
}
Pingze Fu:
Nobody can do this ?