Using:
- Code compser 8
- pdk_omapl137_1_10
If DMA is enabled on SPI, only the first transaction works; a second transaction will hang.
Code (with SPI_DMA_ENABLE predefined symbol and Spi.Settings.useDma = "true"; in the cfg:
Init:
SPI_Params spiParams; /* SPI params structure */
SPI_v0_HWAttrs spi_cfg;
uint32_t xferEnable= 1;
SPI_socGetInitCfg(SPI_INSTANCE, &spi_cfg);
spi_cfg.enableIntr = false;
#ifdef SPI_DMA_ENABLE
/* Set the DMA related init config */
spi_cfg.edmaHandle = SPIApp_edmaInit();
spi_cfg.dmaMode = TRUE;
spi_cfg.enableIntr = false;
#endif
SPI_socSetInitCfg(SPI_INSTANCE, &spi_cfg);
SPI_Params_init(&spiParams);
/* Init SPI driver */
SPI_init();
hwHandle = (SPI_Handle)SPI_open(SPI_INSTANCE, &spiParams);
xferEnable = 1;
SPI_control(hwHandle, SPI_V0_CMD_XFER_ACTIVATE, (void *)&xferEnable);
Single Transaction:
unsigned char SpiTransaction(unsigned int len,void* txBuf,void* rxBuf)
{
SPI_Transaction transaction; // SPI transaction structure
uint32_t terminateXfer = 0; // SPI argument for callback mode
unsigned char retval;
#ifdef SPI_DMA_ENABLE
CacheP_wbInv((void *)txBuf, (int32_t)sizeof(txBuf));
CacheP_wbInv((void *)rxBuf, (int32_t)sizeof(rxBuf));
#endif
transaction.txBuf = txBuf;
transaction.rxBuf = rxBuf;
transaction.count = len;
transaction.arg = (void *)&terminateXfer;
retval = SPI_transfer(hwHandle, &transaction);
return retval;
}
In SPI_MODE_CALLBACK is the same; only the first transaction calls the callback.