我想要改写spi的范例程序,因为在范例中只能接受固定数量的数据,我想把它改成像uart一样,直管接收的函数,所以我萌生了下面的想法:使用time out 来做一个结束的动作,但问题是该函数一直跳不进去,我的疑惑是难倒是spi salve不能使用中断???
void SPI0_IRQHandler(void)
{
printf("1");
if(SPI_GetIntFlag(SPI0, SPI_FIFO_RXTO_INT_MASK))
{
/* If RX FIFO is not empty, read RX FIFO. */
while(SPI_GET_RX_FIFO_EMPTY_FLAG(SPI0) == 0)
g_au32DestinationData[g_u32RxDataCount++] = SPI_READ_RX(SPI0);
g_end = TRUE;
SPI_DisableInt(SPI0,SPI_FIFO_RXTO_INT_MASK);
}
}
//这是我初始化和使能中断的一些步骤
void SPI_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init SPI */
/*---------------------------------------------------------------------------------------------------------*/
/* Configure SPI0 as a slave, clock idle low, 32-bit transaction, drive output on falling clock edge and latch input on rising edge. */
/* Configure SPI0 as a low level active device. SPI peripheral clock rate = f_PCLK0 */
SPI_Open(SPI0, SPI_SLAVE, SPI_MODE_0, 32, NULL);
SPI_SetFIFO(SPI0, 4, 4);
SPI_EnableInt(SPI0, SPI_FIFO_RXTO_INT_MASK | SPI_FIFO_RXTH_INT_MASK);
NVIC_EnableIRQ(SPI0_IRQn);
}
|