工具与软件:
尊敬的社区:
我在定制设计中将 SPI0用于外部闪存。 当我使用 SPI_MODE_BLOCKING 作为传输模式时、工作状态非常好。 最近、我不得不在非阻塞模式下使用它、而我将传输模式更改为 SPI_MODE_CALLBACK。
我的回调将针对每次传输进行调用、并且我看到事务状态正在变为 SPI_TRANSFER_COMPLETED。 传输计数也完全匹配。 但我在 Rx 缓冲区中看不到任何接收数据。
以下是我的初始化和读取闪存 ID 例程、供您参考:
int smartMCT_SPI0Init(void) // SPI0 init { //SPI0 init SPI_Params_init(&SbpSpiParams); SbpSpiParams.bitRate = 8000000; SbpSpiParams.transferMode =SPI_MODE_CALLBACK; SbpSpiParams.frameFormat = SPI_POL0_PHA0; SbpSpiParams.dataSize = 8; SbpSpiParams.transferCallbackFxn = wdt_spi_cb; SbpSpiHandle = SPI_open(MY_SPI0, &SbpSpiParams); if(SbpSpiHandle == NULL) { return -1; } } // Reading flash ID uint8 MH_SPIReadID(uint8 addr,uint8 *out) { txbuf[0] = 0x9F; // read command txbuf[1] = 0xFF; txbuf[2] = 0xFF; txbuf[3] = 0xFF; txbuf[4] = 0xFF; txbuf[5] = 0xFF; txbuf[6] = 0xFF; txbuf[7] = 0xFF; spiTransaction.arg = NULL; spiTransaction.count = 8; spiTransaction.txBuf = txbuf; spiTransaction.rxBuf = out; PIN_setOutputValue(myPins, MH_CS, 0); // /CS enable SPI_transfer(SbpSpiHandle, &spiTransaction); PIN_setOutputValue(myPins, MH_CS, 1); // /CS disable return 0; }
我可能会做错什么? 在回调模式下接收数据有什么注意事项?
好的
Lakshmi