Part Number: CC3200MODLAUNCHXL
Hello -
I was able to successfully stitch together the SPI DMA for the slave side where the data coming in ping pongs between two different arrays. I want to do the same thing for the master side where data going out ping pongs from two different arrays.
I currently have it set up where I mimicked the ping ponging that was done for the slave side to the master side. I put interrupts to check for either DMA RX and TX. If my understanding is correctly, for the master side, when you want to send data over SPI, an interrupt will be triggered when the TX buffer is filled where the DMA will take the full TX buffer and transfer it over the SPI.
So what I did was in the code below, I fill g_ucTxBuffA and likewise g_ucTxBuffB (since it is ping pong) and when each array gets filled, shouldn't an interrupt be triggered sending whatever is inside the g_ucTxBuffA/B over SPI?
SPIDmaEnable(GSPI_BASE,SPI_RX_DMA | SPI_TX_DMA);
MAP_SPIIntEnable(GSPI_BASE,SPI_INT_DMARX | SPI_INT_DMATX);
MAP_SPIIntRegister(GSPI_BASE,IntHandler);
flag = 0;
for (i = 0; i < 10240000; i++) {
if (i%TR_BUFF_SIZE == 0) {
flag = ~flag;
}
if (flag) {
g_ucTxBuffA[i%TR_BUFF_SIZE] = i;
}
else {
g_ucTxBuffB[i%TR_BUFF_SIZE] = i;
}
}
This code below is in my interrupt handler (IntHandler):
ulModeTXP = MAP_uDMAChannelModeGet(UDMA_CH31_GSPI_TX | UDMA_PRI_SELECT);
if (ulModeTXP == UDMA_MODE_STOP) {
ucTxBuffAcnt++;
MAP_uDMAChannelTransferSet(UDMA_CH31_GSPI_TX | UDMA_PRI_SELECT,UDMA_MODE_PINGPONG,
g_ucTxBuffA,
(void *)(GSPI_BASE + MCSPI_O_TX0),
TR_BUFF_SIZE);
MAP_uDMAChannelEnable(UDMA_CH31_GSPI_TX);
}
ulModeTXA = MAP_uDMAChannelModeGet(UDMA_CH31_GSPI_TX | UDMA_ALT_SELECT);
if (ulModeTXA == UDMA_MODE_STOP) {
ucTxBuffBcnt++;
MAP_uDMAChannelTransferSet(UDMA_CH31_GSPI_TX | UDMA_ALT_SELECT,UDMA_MODE_PINGPONG,
g_ucTxBuffB,
(void *)(GSPI_BASE + MCSPI_O_TX0),
TR_BUFF_SIZE);
MAP_uDMAChannelEnable(UDMA_CH31_GSPI_TX);
}
Thanks