mbed library sources. Supersedes mbed-src.

Dependents:   BREAK_SENSOR_LED

Fork of mbed-dev by mbed official

Revision:
161:2cc1468da177
Parent:
153:fa9ff456f731
Child:
167:e84263d55307
diff -r d5399cc887bb -r 2cc1468da177 targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c
--- a/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c	Tue Mar 14 16:40:56 2017 +0000
+++ b/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c	Thu Mar 30 13:45:57 2017 +0100
@@ -317,8 +317,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
@@ -340,7 +342,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
@@ -379,6 +381,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
@@ -390,7 +393,7 @@
             PDMA_DisableInt(obj->spi.dma_chn_id_tx, 0);
             // FIXME: 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)));
         
@@ -398,7 +401,7 @@
             PDMA_DisableInt(obj->spi.dma_chn_id_rx, 0);
             // FIXME: 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)));
     }