PDK: UART EDMA mode fixes updated.
authorChitresh Gupta <chitresh.g@pathpartnertech.com>
Mon, 3 Oct 2016 10:37:43 +0000 (16:07 +0530)
committerFrank Livingston <frank-livingston@ti.com>
Wed, 5 Oct 2016 18:03:13 +0000 (13:03 -0500)
psdk_cust/pdk_k2g_1_0_1_0_eng/packages/ti/drv/uart/makefile
psdk_cust/pdk_k2g_1_0_1_0_eng/packages/ti/drv/uart/src/v0/UARTDMA_v0.c

index ca41d3244f798d0d3590829d30fa7ee8df246682..85c440ae9f88b6775808bf4059f2a6610ddfbc4c 100644 (file)
@@ -171,13 +171,13 @@ clean ::
 #      $(RM) $(LIBDIR)/k2g/armv7/ti.drv.uart.profiling.k2g.aa15fg
 
 
-## Make rule to create $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66 library
-#.libraries: $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66
-#$(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66: FORCE
-#      $(MAKE) -f ./build/k2g/c66/ti.drv.uart.k2g.dma.ae66.mk $@
-## Rule to clean $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66 library
-#clean ::
-#      $(RM) $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66
+# Make rule to create $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66 library
+.libraries: $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66
+$(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66: FORCE
+       $(MAKE) -f ./build/k2g/c66/ti.drv.uart.k2g.dma.ae66.mk $@
+# Rule to clean $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66 library
+clean ::
+       $(RM) $(LIBDIR)/k2g/c66/ti.drv.uart.k2g.dma.ae66
 
 
 ## Make rule to create $(LIBDIR)/k2g/c66/ti.drv.uart.profiling.k2g.dma.ae66 library
index b86059c9e096eee0442a029eb088c02803c512f7..8831e5e45a9b14818913ac99eb86d8c48a3f2728 100644 (file)
@@ -324,6 +324,14 @@ static void UARTDMA_close_v0(UART_Handle handle)
     UART_intDisable_v0(hwAttrs->baseAddr, UART_INT_RHR_CTI | UART_INT_THR);
     UART_operatingModeSelect_v0(hwAttrs->baseAddr, UART_DISABLED_MODE);
 
+    EDMA3_DRV_unlinkChannel(
+            hwAttrs->edmaHandle,
+            object->edmaLinkChId);
+
+    EDMA3_DRV_freeChannel(
+                hwAttrs->edmaHandle,
+                object->edmaLinkChId);
+
     EDMA3_DRV_freeChannel(
             hwAttrs->edmaHandle,
             hwAttrs->rxDmaEventNumber);
@@ -652,7 +660,14 @@ static void UARTDMA_transmitDMA(UART_Handle handle,const void *buffer, size_t si
     EDMA3_DRV_PaRAMRegs paramSet   = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
     hwAttrs = handle->hwAttrs;
-    actualThreshold = UART_DMA_TX_THLD;
+    if (size >= UART_DMA_TX_THLD)
+    {
+        actualThreshold = UART_DMA_TX_THLD;
+    }
+    else
+    {
+        actualThreshold = 1;
+    }
     object = ((UART_Handle)handle)->object;
     if (result == EDMA3_DRV_SOK)
     {
@@ -687,14 +702,14 @@ static void UARTDMA_transmitDMA(UART_Handle handle,const void *buffer, size_t si
          */
 
         if ((size <= UART_EDMA3CC_COUNT_VALUE) &&
-            (size > actualThreshold))
+            (size >= actualThreshold))
         {
             paramSet.cCnt = (uint16_t)(UART_EDMA3CC_COUNT_VALUE &
                                   (size / actualThreshold));
         }
-        else if ((size <= actualThreshold) && (size > 0))
+        else if ((size < actualThreshold) && (size > 0))
         {
-            paramSet.cCnt = 1;
+            paramSet.cCnt = size;
         }
         else
         {
@@ -946,16 +961,34 @@ static void UARTDMA_txIsrHandler(uint32_t tcc, EDMA3_RM_TccStatus status, void*
         hwAttrs = handle->hwAttrs;
         object = ((UART_Handle)handle)->object;
 
-        object->writeCount = object->writeSize;
-        /* if (EDMA3_RM_XFER_COMPLETE == status) */
+        if (EDMA3_RM_XFER_COMPLETE == status)
         {
-            object->writeCount = object->writeSize;
-            EDMA3_DRV_disableLogicalChannel(
+            if (object->writeSize >= UART_DMA_TX_THLD)
+            {
+                bytesRemain = object->writeSize % UART_DMA_TX_THLD;
+                object->writeCount = object->writeSize - bytesRemain;
+                object->writeSize = bytesRemain;
+                if (object->writeSize)
+                    UARTDMA_transmitDMA(handle,
+                                    (void*)(object->writeBuf + object->writeCount),
+                                    object->writeSize);
+                else
+                    object->params.writeCallback((UART_Handle)handle, (uint8_t*)object->writeBuf,
+                                    object->writeCount);
+            }
+            else
+            {
+                object->writeCount += object->writeSize;
+                EDMA3_DRV_disableLogicalChannel(
                             (EDMA3_DRV_Handle) hwAttrs->edmaHandle,
                             (uint32_t) hwAttrs->txDmaEventNumber,
                             (EDMA3_DRV_TrigMode) EDMA3_DRV_TRIG_MODE_EVENT);
+                object->writeSize = 0;
+                object->params.writeCallback((UART_Handle)handle, (uint8_t*)object->writeBuf,
+                                object->writeCount);
+            }
         }
-        if (EDMA3_RM_XFER_COMPLETE != status)
+        else
         {
             /* Ensure to clear the error bits of EDMA channel                 */
             EDMA3_DRV_clearErrorBits((EDMA3_DRV_Handle)hwAttrs->edmaHandle,
@@ -967,10 +1000,10 @@ static void UARTDMA_txIsrHandler(uint32_t tcc, EDMA3_RM_TccStatus status, void*
                                          /* calculate the amount of bytes remaining                        */
             bytesRemain = (paramSet.aCnt * paramSet.bCnt * paramSet.cCnt);
             object->writeCount = object->writeSize - bytesRemain ;
+            object->writeSize = 0;
+            object->params.writeCallback((UART_Handle)handle, (uint8_t*)object->writeBuf,
+                                         object->writeCount);
         }
-        object->writeSize = 0;
-        object->params.writeCallback((UART_Handle)handle, (uint8_t*)object->writeBuf,
-                                object->writeCount);
     }
 }