]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_ip/gpdma_001.h
Add extra debug comment into list.c.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_ip / gpdma_001.h
1 /*\r
2  * @brief GPDMA Registers and control functions\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\r
9  * Software that is described herein is for illustrative purposes only\r
10  * which provides customers with programming information regarding the\r
11  * LPC products.  This software is supplied "AS IS" without any warranties of\r
12  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
13  * all warranties, express or implied, including all implied warranties of\r
14  * merchantability, fitness for a particular purpose and non-infringement of\r
15  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
16  * or liability for the use of the software, conveys no license or rights under any\r
17  * patent, copyright, mask work right, or any other intellectual property rights in\r
18  * or to any products. NXP Semiconductors reserves the right to make changes\r
19  * in the software without notification. NXP Semiconductors also makes no\r
20  * representation or warranty that such application will be suitable for the\r
21  * specified use without further testing or modification.\r
22  *\r
23  * @par\r
24  * Permission to use, copy, modify, and distribute this software and its\r
25  * documentation is hereby granted, under NXP Semiconductors' and its\r
26  * licensor's relevant copyrights in the software, without fee, provided that it\r
27  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
28  * copyright, permission, and disclaimer notice must appear in all copies of\r
29  * this code.\r
30  */\r
31 \r
32 #ifndef __GPDMA_001_H_\r
33 #define __GPDMA_001_H_\r
34 \r
35 #include "sys_config.h"\r
36 #include "cmsis.h"\r
37 \r
38 #ifdef __cplusplus\r
39 extern "C" {\r
40 #endif\r
41 \r
42 /** @defgroup IP_GPDMA_001 IP: GPDMA register block and driver\r
43  * @ingroup IP_Drivers\r
44  * General Purpose DMA\r
45  * @{\r
46  */\r
47 \r
48 /**\r
49  * @brief GPDMA Channel register block structure\r
50  */\r
51 typedef struct {\r
52         __IO uint32_t  SRCADDR;                         /*!< DMA Channel Source Address Register */\r
53         __IO uint32_t  DESTADDR;                        /*!< DMA Channel Destination Address Register */\r
54         __IO uint32_t  LLI;                                     /*!< DMA Channel Linked List Item Register */\r
55         __IO uint32_t  CONTROL;                         /*!< DMA Channel Control Register */\r
56         __IO uint32_t  CONFIG;                          /*!< DMA Channel Configuration Register */\r
57         __I  uint32_t  RESERVED1[3];\r
58 } IP_GPDMA_001_CH_T;\r
59 \r
60 #define GPDMA_CHANNELS 8\r
61 \r
62 /**\r
63  * @brief GPDMA register block\r
64  */\r
65 typedef struct {                                                /*!< GPDMA Structure */\r
66         __I  uint32_t  INTSTAT;                         /*!< DMA Interrupt Status Register */\r
67         __I  uint32_t  INTTCSTAT;                       /*!< DMA Interrupt Terminal Count Request Status Register */\r
68         __O  uint32_t  INTTCCLEAR;                      /*!< DMA Interrupt Terminal Count Request Clear Register */\r
69         __I  uint32_t  INTERRSTAT;                      /*!< DMA Interrupt Error Status Register */\r
70         __O  uint32_t  INTERRCLR;                       /*!< DMA Interrupt Error Clear Register */\r
71         __I  uint32_t  RAWINTTCSTAT;            /*!< DMA Raw Interrupt Terminal Count Status Register */\r
72         __I  uint32_t  RAWINTERRSTAT;           /*!< DMA Raw Error Interrupt Status Register */\r
73         __I  uint32_t  ENBLDCHNS;                       /*!< DMA Enabled Channel Register */\r
74         __IO uint32_t  SOFTBREQ;                        /*!< DMA Software Burst Request Register */\r
75         __IO uint32_t  SOFTSREQ;                        /*!< DMA Software Single Request Register */\r
76         __IO uint32_t  SOFTLBREQ;                       /*!< DMA Software Last Burst Request Register */\r
77         __IO uint32_t  SOFTLSREQ;                       /*!< DMA Software Last Single Request Register */\r
78         __IO uint32_t  CONFIG;                          /*!< DMA Configuration Register */\r
79         __IO uint32_t  SYNC;                            /*!< DMA Synchronization Register */\r
80         __I  uint32_t  RESERVED0[50];\r
81         IP_GPDMA_001_CH_T CH[GPDMA_CHANNELS];\r
82 } IP_GPDMA_001_T;\r
83 \r
84 /**\r
85  * @brief Macro defines for DMA channel control registers\r
86  */\r
87 #define GPDMA_DMACCxControl_TransferSize(n) (((n & 0xFFF) << 0))        /*!< Transfer size*/\r
88 #define GPDMA_DMACCxControl_SBSize(n)       (((n & 0x07) << 12))        /*!< Source burst size*/\r
89 #define GPDMA_DMACCxControl_DBSize(n)       (((n & 0x07) << 15))        /*!< Destination burst size*/\r
90 #define GPDMA_DMACCxControl_SWidth(n)       (((n & 0x07) << 18))        /*!< Source transfer width*/\r
91 #define GPDMA_DMACCxControl_DWidth(n)       (((n & 0x07) << 21))        /*!< Destination transfer width*/\r
92 #define GPDMA_DMACCxControl_SI              ((1UL << 26))                       /*!< Source increment*/\r
93 #define GPDMA_DMACCxControl_DI              ((1UL << 27))                       /*!< Destination increment*/\r
94 #if defined(CHIP_LPC43XX) || defined(CHIP_LPC18XX)\r
95 #define GPDMA_DMACCxControl_SrcTransUseAHBMaster1   ((1UL << 24))       /*!< Source AHB master select in 18xx43xx*/\r
96 #define GPDMA_DMACCxControl_DestTransUseAHBMaster1  ((1UL << 25))       /*!< Destination AHB master select in 18xx43xx*/\r
97 #else\r
98 #define GPDMA_DMACCxControl_SrcTransUseAHBMaster1   0\r
99 #define GPDMA_DMACCxControl_DestTransUseAHBMaster1  0\r
100 #endif\r
101 #define GPDMA_DMACCxControl_Prot1           ((1UL << 28))                       /*!< Indicates that the access is in user mode or privileged mode*/\r
102 #define GPDMA_DMACCxControl_Prot2           ((1UL << 29))                       /*!< Indicates that the access is bufferable or not bufferable*/\r
103 #define GPDMA_DMACCxControl_Prot3           ((1UL << 30))                       /*!< Indicates that the access is cacheable or not cacheable*/\r
104 #define GPDMA_DMACCxControl_I               ((1UL << 31))                       /*!< Terminal count interrupt enable bit */\r
105 \r
106 /**\r
107  * @brief Macro defines for DMA Configuration register\r
108  */\r
109 #define GPDMA_DMACConfig_E              ((0x01))        /*!< DMA Controller enable*/\r
110 #define GPDMA_DMACConfig_M              ((0x02))        /*!< AHB Master endianness configuration*/\r
111 #define GPDMA_DMACConfig_BITMASK        ((0x03))\r
112 \r
113 /**\r
114  * @brief Macro defines for DMA Channel Configuration registers\r
115  */\r
116 #define GPDMA_DMACCxConfig_E                    ((1UL << 0))                    /*!< DMA control enable*/\r
117 #define GPDMA_DMACCxConfig_SrcPeripheral(n)     (((n & 0x1F) << 1))             /*!< Source peripheral*/\r
118 #define GPDMA_DMACCxConfig_DestPeripheral(n)    (((n & 0x1F) << 6))             /*!< Destination peripheral*/\r
119 #define GPDMA_DMACCxConfig_TransferType(n)      (((n & 0x7) << 11))             /*!< This value indicates the type of transfer*/\r
120 #define GPDMA_DMACCxConfig_IE                   ((1UL << 14))                   /*!< Interrupt error mask*/\r
121 #define GPDMA_DMACCxConfig_ITC                  ((1UL << 15))                   /*!< Terminal count interrupt mask*/\r
122 #define GPDMA_DMACCxConfig_L                    ((1UL << 16))                   /*!< Lock*/\r
123 #define GPDMA_DMACCxConfig_A                    ((1UL << 17))                   /*!< Active*/\r
124 #define GPDMA_DMACCxConfig_H                    ((1UL << 18))                   /*!< Halt*/\r
125 \r
126 /**\r
127  * @brief GPDMA Interrupt Clear Status\r
128  */\r
129 typedef enum IP_GPDMA_STATECLEAR {\r
130         GPDMA_STATCLR_INTTC,    /*!< GPDMA Interrupt Terminal Count Request Clear */\r
131         GPDMA_STATCLR_INTERR    /*!< GPDMA Interrupt Error Clear */\r
132 } IP_GPDMA_STATECLEAR_T;\r
133 \r
134 /**\r
135  * @brief GPDMA Type of Interrupt Status\r
136  */\r
137 typedef enum IP_GPDMA_STATUS {\r
138         GPDMA_STAT_INT,                 /*!< GPDMA Interrupt Status */\r
139         GPDMA_STAT_INTTC,               /*!< GPDMA Interrupt Terminal Count Request Status */\r
140         GPDMA_STAT_INTERR,              /*!< GPDMA Interrupt Error Status */\r
141         GPDMA_STAT_RAWINTTC,    /*!< GPDMA Raw Interrupt Terminal Count Status */\r
142         GPDMA_STAT_RAWINTERR,   /*!< GPDMA Raw Error Interrupt Status */\r
143         GPDMA_STAT_ENABLED_CH   /*!< GPDMA Enabled Channel Status */\r
144 } IP_GPDMA_STATUS_T;\r
145 \r
146 /**\r
147  * @brief GPDMA Type of DMA controller\r
148  */\r
149 typedef enum IP_GPDMA_FLOW_CONTROL {\r
150         GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA              = ((0UL)),   /*!< Memory to memory - DMA control */\r
151         GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA              = ((1UL)),   /*!< Memory to peripheral - DMA control */\r
152         GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA              = ((2UL)),   /*!< Peripheral to memory - DMA control */\r
153         GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DMA              = ((3UL)),   /*!< Source peripheral to destination peripheral - DMA control */\r
154         GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DestPERIPHERAL   = ((4UL)),   /*!< Source peripheral to destination peripheral - destination peripheral control */\r
155         GPDMA_TRANSFERTYPE_M2P_CONTROLLER_PERIPHERAL       = ((5UL)),   /*!< Memory to peripheral - peripheral control */\r
156         GPDMA_TRANSFERTYPE_P2M_CONTROLLER_PERIPHERAL       = ((6UL)),   /*!< Peripheral to memory - peripheral control */\r
157         GPDMA_TRANSFERTYPE_P2P_CONTROLLER_SrcPERIPHERAL    = ((7UL))    /*!< Source peripheral to destination peripheral - source peripheral control */\r
158 } IP_GPDMA_FLOW_CONTROL_T;\r
159 \r
160 /**\r
161  * @brief GPDMA structure using for DMA configuration\r
162  */\r
163 typedef struct {\r
164         uint32_t ChannelNum;    /*!< DMA channel number, should be in\r
165                                                          *  range from 0 to 7.\r
166                                                          *  Note: DMA channel 0 has the highest priority\r
167                                                          *  and DMA channel 7 the lowest priority.\r
168                                                          */\r
169         uint32_t TransferSize;  /*!< Length/Size of transfer */\r
170         uint32_t TransferWidth; /*!< Transfer width - used for TransferType is GPDMA_TRANSFERTYPE_M2M only */\r
171         uint32_t SrcAddr;               /*!< Physical Source Address, used in case TransferType is chosen as\r
172                                                          *   GPDMA_TRANSFERTYPE_M2M or GPDMA_TRANSFERTYPE_M2P */\r
173         uint32_t DstAddr;               /*!< Physical Destination Address, used in case TransferType is chosen as\r
174                                                          *   GPDMA_TRANSFERTYPE_M2M or GPDMA_TRANSFERTYPE_P2M */\r
175         uint32_t TransferType;  /*!< Transfer Type, should be one of the following:\r
176                                                          * - GPDMA_TRANSFERTYPE_M2M: Memory to memory - DMA control\r
177                                                          * - GPDMA_TRANSFERTYPE_M2P: Memory to peripheral - DMA control\r
178                                                          * - GPDMA_TRANSFERTYPE_P2M: Peripheral to memory - DMA control\r
179                                                          * - GPDMA_TRANSFERTYPE_P2P: Source peripheral to destination peripheral - DMA control\r
180                                                          */\r
181 } GPDMA_Channel_CFG_T;\r
182 \r
183 /**\r
184  * @brief       Initialize the GPDMA\r
185  * @param       pGPDMA  : The Base Address of GPDMA on the chip\r
186  * @return      Nothing\r
187  */\r
188 void IP_GPDMA_Init(IP_GPDMA_001_T *pGPDMA);\r
189 \r
190 /**\r
191  * @brief       Create the Control word based on given parameters\r
192  * @param       GPDMAChannelConfig                      : Configuration struct\r
193  * @param       GPDMA_LUTPerBurstSrcConn        : Peripheral Source burst size\r
194  * @param       GPDMA_LUTPerBurstDstConn        : Peripheral Destination burst size\r
195  * @param       GPDMA_LUTPerWidSrcConn          : Peripheral Source transfer width\r
196  * @param       GPDMA_LUTPerWidDstConn          : Peripheral Destination transfer width\r
197  * @return      32-bit unsigned control value, *can be used while calling IP_GPDMA_Setup()*,\r
198  *              ERROR if the transfer type specified in GPDMAChannelConfig is invalid\r
199  * @note    Control Word is a 32-bit unsigned value that provides the transfer\r
200  *          information like the peripheral number, transfer size etc.,\r
201  */\r
202 uint32_t IP_GPDMA_MakeCtrlWord(const GPDMA_Channel_CFG_T *GPDMAChannelConfig,\r
203                                                            uint32_t GPDMA_LUTPerBurstSrcConn,\r
204                                                            uint32_t GPDMA_LUTPerBurstDstConn,\r
205                                                            uint32_t GPDMA_LUTPerWidSrcConn,\r
206                                                            uint32_t GPDMA_LUTPerWidDstConn);\r
207 \r
208 /**\r
209  * @brief       Set up the GPDMA according to the specification configuration details\r
210  * @param       pGPDMA                          : The Base Address of GPDMA on the chip\r
211  * @param       GPDMAChannelConfig      : Pointer to Configuration struct\r
212  * @param       CtrlWord                        : Control Word *can be obtained using IP_GPDMA_MakeCtrlWord()*\r
213  * @param       LinkListItem            : Pointer to next descriptor *[0 if no linked list is used]*\r
214  * @param       SrcPeripheral           : Peripheral Source ID\r
215  * @param       DstPeripheral           : Peripheral Destination ID\r
216  * @return      SUCCESS or ERROR on setup failure\r
217  */\r
218 Status IP_GPDMA_Setup(IP_GPDMA_001_T *pGPDMA,\r
219                                           GPDMA_Channel_CFG_T *GPDMAChannelConfig,\r
220                                           uint32_t CtrlWord,\r
221                                           uint32_t LinkListItem,\r
222                                           uint8_t SrcPeripheral,\r
223                                           uint8_t DstPeripheral);\r
224 \r
225 /**\r
226  * @brief       Read the status from different registers according to the type\r
227  * @param       pGPDMA          : The Base Address of GPDMA on the chip\r
228  * @param       type            : Status mode, should be:\r
229  *                                                      - GPDMA_STAT_INT                : GPDMA Interrupt Status\r
230  *                                                      - GPDMA_STAT_INTTC              : GPDMA Interrupt Terminal Count Request Status\r
231  *                                                      - GPDMA_STAT_INTERR             : GPDMA Interrupt Error Status\r
232  *                                                      - GPDMA_STAT_RAWINTTC   : GPDMA Raw Interrupt Terminal Count Status\r
233  *                                                      - GPDMA_STAT_RAWINTERR  : GPDMA Raw Error Interrupt Status\r
234  *                                                      - GPDMA_STAT_ENABLED_CH : GPDMA Enabled Channel Status\r
235  * @param       channel         : The GPDMA channel : 0 - 7\r
236  * @return      SET is interrupt is pending or RESET if not pending\r
237  */\r
238 IntStatus IP_GPDMA_IntGetStatus(IP_GPDMA_001_T *pGPDMA, IP_GPDMA_STATUS_T type, uint8_t channel);\r
239 \r
240 /**\r
241  * @brief       Clear the Interrupt Flag from different registers according to the type\r
242  * @param       pGPDMA  : The Base Address of GPDMA on the chip\r
243  * @param       type    : Flag mode, should be:\r
244  *                                              - GPDMA_STATCLR_INTTC   : GPDMA Interrupt Terminal Count Request\r
245  *                                              - GPDMA_STATCLR_INTERR  : GPDMA Interrupt Error\r
246  * @param       channel : The GPDMA channel : 0 - 7\r
247  * @return      Nothing\r
248  */\r
249 void IP_GPDMA_ClearIntPending(IP_GPDMA_001_T *pGPDMA, IP_GPDMA_STATECLEAR_T type, uint8_t channel);\r
250 \r
251 /**\r
252  * @brief       Enable or Disable the GPDMA Channel\r
253  * @param       pGPDMA          : The Base Address of GPDMA on the chip\r
254  * @param       channelNum      : The GPDMA channel : 0 - 7\r
255  * @param       NewState        : ENABLE to enable GPDMA or DISABLE to disable GPDMA\r
256  * @return      Nothing\r
257  */\r
258 void IP_GPDMA_ChannelCmd(IP_GPDMA_001_T *pGPDMA, uint8_t channelNum, FunctionalState NewState);\r
259 \r
260 /**\r
261  * @}\r
262  */\r
263 \r
264 #ifdef __cplusplus\r
265 }\r
266 #endif\r
267 \r
268 #endif /* __GPDMA_001_H_ */\r