使用msp430f5529运行ti-rtos驱动spi仿真发现从spi的RXBUF中有数据,程序运行时无法跳过SPI_transfer(),运行到__no_operation();。
主要的taskFxn函数如下。
void pm25ld020taskFxn(UArg arg0, UArg arg1) {
GPIO_write(ZKS_GASSENSOR_X2_SPI_PM25LD020_CE,
ZKS_GASSENSOR_X2_PM25LD020_ENABLE);
SPI_Handle spi_handle_pm25ld020;
Bool transferOK;
SPI_Params spiParams_pm25ld020;
SPI_Params_init(&spiParams_pm25ld020);
spiParams_pm25ld020.transferMode = SPI_MODE_BLOCKING;
spiParams_pm25ld020.transferCallbackFxn = NULL;
spiParams_pm25ld020.bitRate = 8000000;
spi_handle_pm25ld020 = SPI_open(Board_SPI_PM25LD020, &spiParams_pm25ld020);
SPI_Transaction spi_transaction_pm25ld020;
UChar transmitBuffer[1] = { 0x9f };
UChar receiveBuffer[4] = { 0x04 };
spi_transaction_pm25ld020.count = 4;
spi_transaction_pm25ld020.txBuf = (Ptr) transmitBuffer;
spi_transaction_pm25ld020.rxBuf = (Ptr) receiveBuffer;
transferOK = SPI_transfer(spi_handle_pm25ld020, &spi_transaction_pm25ld020);
__no_operation();
GPIO_write(ZKS_GASSENSOR_X2_SPI_PM25LD020_CE,
ZKS_GASSENSOR_X2_PM25LD020_DISABLE);
if (!transferOK) {
/* Error in SPI transfer or transfer is already in progress */
}
}