[rtems commit] bsp/atsam: Speed up SPI DMA transfer start

Sebastian Huber sebh at rtems.org
Wed Dec 14 12:10:18 UTC 2016


Module:    rtems
Branch:    master
Commit:    f74e2959ded6b0e1e750b539df27ba18eeceb46f
Changeset: http://git.rtems.org/rtems/commit/?id=f74e2959ded6b0e1e750b539df27ba18eeceb46f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec 13 15:18:00 2016 +0100

bsp/atsam: Speed up SPI DMA transfer start

---

 .../lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h  |  6 ++++++
 c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c              | 13 ++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/c/src/lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h b/c/src/lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h
index 34d4faa..058bcf9 100644
--- a/c/src/lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h
+++ b/c/src/lib/libbsp/arm/atsam/libraries/libchip/include/xdmac.h
@@ -122,6 +122,12 @@
 extern "C" {
 #endif
 
+static inline void XDMAC_StartTransfer(Xdmac *pXdmac, uint8_t iChannel)
+{
+	pXdmac->XDMAC_GE = (XDMAC_GE_EN0 << iChannel);
+	pXdmac->XDMAC_GIE = (XDMAC_GIE_IE0 << iChannel);
+}
+
 extern uint32_t XDMAC_GetType(Xdmac *pXdmac);
 extern uint32_t XDMAC_GetConfig(Xdmac *pXdmac);
 extern uint32_t XDMAC_GetArbiter(Xdmac *pXdmac);
diff --git a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
index c88cec9..247f886 100644
--- a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
+++ b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
@@ -354,8 +354,8 @@ static uint32_t atsam_send_command(
 )
 {
   Spid *spid = &bus->SpiDma;
-
   Spi *pSpiHw = spid->pSpiHw;
+  Xdmac *pXdmac = bus->SpiDma.pXdmad->pXdmacs;
 
   if (
     atsam_configure_link_list(
@@ -382,14 +382,9 @@ static uint32_t atsam_send_command(
 
   bus->spi_switched_on = true;
 
-  /* Start DMA 0(RX) && 1(TX) */
-  if (XDMAD_StartTransfer(spid->pXdmad, bus->dma_rx_channel)) {
-    return SPID_ERROR_LOCK;
-  }
-
-  if (XDMAD_StartTransfer(spid->pXdmad, bus->dma_tx_channel)) {
-    return SPID_ERROR_LOCK;
-  }
+  /* Start DMA */
+  XDMAC_StartTransfer(pXdmac, bus->dma_rx_channel);
+  XDMAC_StartTransfer(pXdmac, bus->dma_tx_channel);
 
   return 0;
 }



More information about the vc mailing list