有没有CC1310 SPI从模式下,阻塞模式接收的例程呀,我这个阻塞模式接收一直接收不到
Susan Yang:
很抱歉,目前没有直接的 SPI slave 阻塞模式接收的例程.
请问能详细说明下您的问题吗?若是可以的话,请附上您的代码,谢谢
liu shr:
回复 Susan Yang:
SPI_Params_init(&spiParams);spiParams.frameFormat = SPI_POL0_PHA1;spiParams.mode = SPI_SLAVE;spiParams.transferMode = SPI_MODE_BLOCKING;spiParams.transferTimeout = 10000;slaveSpi = SPI_open(Board_SPI_SLAVE, &spiParams);if (slaveSpi == NULL) {Display_printf(display, 0, 0, "Error initializing slave SPI\n");while (1);}else {Display_printf(display, 0, 0, "Slave SPI initialized\n");}
while(1){memset((void *) slaveRxBuffer, 0, SPI_MSG_LENGTH);transaction.count = SPI_MSG_LENGTH;transaction.txBuf = (void *) slaveTxBuffer;transaction.rxBuf = (void *) slaveRxBuffer;
/* Toggle on user LED, indicating a SPI transfer is in progress */GPIO_toggle(Board_GPIO_LED1);
/** Setup SPI transfer; Board_SPI_SLAVE_READY will be set to notify* master the slave is ready.*/transferOK = SPI_transfer(slaveSpi, &transaction);if (transferOK) {GPIO_write(Board_SPI_SLAVE_READY, 0);
/* Wait until transfer has completed */sem_wait(&slaveSem);
/** Drive Board_SPI_SLAVE_READY high to indicate slave is not ready* for another transfer yet.*/GPIO_write(Board_SPI_SLAVE_READY, 1);Display_printf(display, 0, 0, "Slave received: %s", slaveRxBuffer);}else {Display_printf(display, 0, 0, "Unsuccessful slave SPI transfer");}SPI_close(slaveSpi);
liu shr:
回复 Susan Yang:
阻塞模式下接收,但是好像没有接收到
Susan Yang:
回复 liu shr:
您现在是否有进行在线调试?首先要确定您现在数据有发送出来。
阻塞模式会阻塞task的执行,直到SPI传输完成。在TI-RTOS中的所有SPI驱动程序都使用DMA。在阻塞模式下,调用SPI_transfer的任务将挂在信号量上。DMA控制器生成的中断会发出信号,以解除阻塞SPI_transfer()的任务。
liu shr:
回复 Susan Yang:
在线调试,首确定有数据,因为用回调函数模式接收的是正确的。