changeset 3959:bcda75d2c4ff

EFM32 dma: Fix dma get_status
author Sebastien Cerdan
date Fri, 08 Jun 2018 20:52:58 +0200
parents 9b72e555dfb6
children a0e6b2575364
files arch/efm32/drivers/dma/dma.c arch/efm32/drivers/usart/usart_char_dma.c
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/arch/efm32/drivers/dma/dma.c	Fri Jun 08 14:14:25 2018 +0200
+++ b/arch/efm32/drivers/dma/dma.c	Fri Jun 08 20:52:58 2018 +0200
@@ -327,6 +327,7 @@
   if (efm32_dma_get_src(rq))
     mode = DMA_CHANNEL_CFG_CYCLE_CTR_BASIC;
 
+
   struct efm32_dma_descriptor_s ctrl;
 
   error_t err = efm32_dma_set_ctrl(rq, rq->desc, &ctrl, mode);
@@ -893,11 +894,13 @@
           bool_t alt = (cpu_mem_read_32(pv->addr + PL230_DMA_CHALTS_ADDR) >> chan) & 1;
 
           size_t done = 0;
+	  uint8_t lidx = 0;
 
           if (rq->type & _DEV_DMA_CONTINUOUS)
             /* Ping-Pong mode */
             {
-              done = rq->desc[state->lidx].src.mem.size;
+	      lidx = state->lidx;
+              done = rq->desc[lidx].src.mem.size;
               done -= alt ? altrem : prirem; 
             }
           else if (rq->desc_count_m1)
@@ -905,10 +908,10 @@
               return -ENOTSUP;
           else
             /* Basic mode */
-            done = rq->desc[0].src.mem.size - prirem;
+            done = rq->desc[lidx].src.mem.size - prirem;
           
-          status->dst_addr = rq->desc->dst.mem.addr + done;
-          status->src_addr = rq->desc->src.mem.addr + done;
+          status->dst_addr = rq->desc[lidx].dst.mem.addr + done;
+          status->src_addr = rq->desc[lidx].src.mem.addr + done;
 
           return 0;
         }
--- a/arch/efm32/drivers/usart/usart_char_dma.c	Fri Jun 08 14:14:25 2018 +0200
+++ b/arch/efm32/drivers/usart/usart_char_dma.c	Fri Jun 08 20:52:58 2018 +0200
@@ -441,6 +441,7 @@
   pv->wptr = (uint8_t*)status.dst_addr;
   /* Check Overflow */
   efm32_usart_check_dma_ovf(pv);
+
   kroutine_exec(&pv->read_kr);
 }
 
@@ -714,7 +715,7 @@
   cpu_mem_write_32(addr + EFM32_TIMER_CC_CTRL_ADDR(CC_CHANNEL), endian_le32(x));
 
   struct dev_freq_s freq = {
-      .num   = CONFIG_DRIVER_EFM32_USART_RATE,
+      .num   = pv->cfg.baudrate,
       .denom = CONFIG_DRIVER_EFM32_USART_CHAR_DMA_TIMEOUT_SYMBOL,
     };