mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: targets/TARGET_NUVOTON/TARGET_M451/spi_api.c
- Revision:
- 161:2cc1468da177
- Parent:
- 153:fa9ff456f731
- Child:
- 167:e84263d55307
--- a/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c Tue Mar 14 16:40:56 2017 +0000 +++ b/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c Thu Mar 30 13:45:57 2017 +0100 @@ -314,8 +314,10 @@ MBED_ASSERT(modinit != NULL); MBED_ASSERT(modinit->modname == obj->spi.spi); + PDMA_T *pdma_base = dma_modbase(); + // Configure tx DMA - PDMA->CHCTL |= 1 << obj->spi.dma_chn_id_tx; // Enable this DMA channel + pdma_base->CHCTL |= 1 << obj->spi.dma_chn_id_tx; // Enable this DMA channel PDMA_SetTransferMode(obj->spi.dma_chn_id_tx, ((struct nu_spi_var *) modinit->var)->pdma_perp_tx, // Peripheral connected to this PDMA 0, // Scatter-gather disabled @@ -339,7 +341,7 @@ dma_set_handler(obj->spi.dma_chn_id_tx, (uint32_t) spi_dma_handler_tx, (uint32_t) obj, DMA_EVENT_ALL); // Configure rx DMA - PDMA->CHCTL |= 1 << obj->spi.dma_chn_id_rx; // Enable this DMA channel + pdma_base->CHCTL |= 1 << obj->spi.dma_chn_id_rx; // Enable this DMA channel PDMA_SetTransferMode(obj->spi.dma_chn_id_rx, ((struct nu_spi_var *) modinit->var)->pdma_perp_rx, // Peripheral connected to this PDMA 0, // Scatter-gather disabled @@ -380,6 +382,7 @@ void spi_abort_asynch(spi_t *obj) { SPI_T *spi_base = (SPI_T *) NU_MODBASE(obj->spi.spi); + PDMA_T *pdma_base = dma_modbase(); if (obj->spi.dma_usage != DMA_USAGE_NEVER) { // Receive FIFO Overrun in case of tx length > rx length on DMA way @@ -388,18 +391,18 @@ } if (obj->spi.dma_chn_id_tx != DMA_ERROR_OUT_OF_CHANNELS) { - PDMA_DisableInt(obj->spi.dma_chn_id_tx, 0); + PDMA_DisableInt(obj->spi.dma_chn_id_tx, PDMA_INT_TRANS_DONE); // FIXME: On NUC472, next PDMA transfer will fail with PDMA_STOP() called. Cause is unknown. //PDMA_STOP(obj->spi.dma_chn_id_tx); - PDMA->CHCTL &= ~(1 << obj->spi.dma_chn_id_tx); + pdma_base->CHCTL &= ~(1 << obj->spi.dma_chn_id_tx); } SPI_DISABLE_TX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi))); if (obj->spi.dma_chn_id_rx != DMA_ERROR_OUT_OF_CHANNELS) { - PDMA_DisableInt(obj->spi.dma_chn_id_rx, 0); + PDMA_DisableInt(obj->spi.dma_chn_id_rx, PDMA_INT_TRANS_DONE); // FIXME: On NUC472, next PDMA transfer will fail with PDMA_STOP() called. Cause is unknown. //PDMA_STOP(obj->spi.dma_chn_id_rx); - PDMA->CHCTL &= ~(1 << obj->spi.dma_chn_id_rx); + pdma_base->CHCTL &= ~(1 << obj->spi.dma_chn_id_rx); } SPI_DISABLE_RX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi))); }