implement LPC1768 GPDMA API

Dependents:   LPC1768_DMA_implementation

Currently, only LPC1768 HAL level API have been implemented. You can also find the test code to test the m2p and m2m here http://mbed.org/users/steniu01/code/LPC1768_DMA_implementation/. The target is to implement the user side platform agnostic API to make it more easily to use DMA.

There are still quite a few things undone (list in priority order):

1. Implement user side API to provide platform agnostic user friendly API

2. Tidy up the codes and add more comments

3. Create more test cases

4. Fully test the codes using mbed sdk automated test suits

5. Implement LLI

Revision:
1:86b13bfcbe46
Parent:
0:226ca65983a2
diff -r 226ca65983a2 -r 86b13bfcbe46 LPC1768_dma.h
--- a/LPC1768_dma.h	Thu Aug 14 01:58:45 2014 +0000
+++ b/LPC1768_dma.h	Thu Aug 21 00:03:00 2014 +0000
@@ -1,4 +1,7 @@
-#ifdef TARGET_LPC1768
+#ifndef LPC1768_DMA_H
+#define LPC1768_DMA_H
+
+#include "mbed.h"
 /** 
   * @brief  DMA Init structure definition
   */
@@ -23,15 +26,33 @@
 #define DMA_CCxConfig_A_Pos 17
 #define DMA_CCxConfig_H_Pos 18
 
+/*DMA Interrupt*/
+#define DMA_IE                        ((uint32_t)0x00004000)
+#define DMA_ITC                       ((uint32_t)0x00008000) 
+
+typedef enum
+{
+    M2M = 0x00,
+    M2P = 0x01,
+    P2M = 0x02,
+    P2P = 0x03
+} TransferType;
 
 
+typedef struct
+{
+    uint32_t DestAddr;
+    uint32_t SrcAddr;
+    uint32_t next;
+    uint32_t control;
+} DMA_LLI;
 
 typedef struct
 {
     uint32_t DMA_DestAddr; /*!< Specifies the destination base address for DMAy Channelx. */
     uint32_t DMA_SrcAddr;     /*!< Specifies the source base address for DMAy Channelx. */
-    DMA_LLI LLI; /*!< Specifies the next linked item   */
-    uint32_t DMA_TransSize;/*!< Specifies the source  transfer size    */
+//    DMA_LLI LLI; /UNDO *!< Specifies the next linked item   */
+    uint32_t DMA_TransferSize;/*!< Specifies the source  transfer size    */
     uint32_t DMA_SrcBurst; /*!< Specifies the source  burst size    */
     uint32_t DMA_DestBurst; /*!< Specifies the destination burst size   */
     uint32_t DMA_SrcWidth; /*!< Specifies the source transfer width   */
@@ -43,18 +64,21 @@
     /*!< Specifies the features set by channel config register */
     uint32_t  DMA_SrcPeripheral;
     uint32_t  DMA_DestPeripheral;
-    uint32_t  DMA_TransferType;       
-
-}DMA_InitTypeDef;
+    TransferType  DMA_TransferType;       
+} DMA_InitTypeDef;
 
-typedef struct
-{
-    uint32_t DestAddr;
-    uint32_t SrcAddr;
-    uint32_t next;
-    uint32_t control;
-    
-}DMA_LLI;
+
 
 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
-#endif
\ No newline at end of file
+typedef enum {COUNTER, ERR} DMA_IT;
+
+
+void DMA_init(LPC_GPDMACH_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct);
+void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
+void DMA_Cmd(LPC_GPDMACH_TypeDef*  DMAy_Channelx, FunctionalState NewState);
+void DMA_ITConfig (LPC_GPDMACH_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState);
+void DMA_ClearITPendingBit(LPC_GPDMACH_TypeDef* DMAy_Channelx, uint32_t DMA_IT);
+uint32_t DMA_EnabledChannels(void);
+bool DMA_ChannelActive (LPC_GPDMACH_TypeDef* DMAy_Channelx);
+
+#endif