uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc17xx_gpdma.h
Go to the documentation of this file.
1 /***********************************************************************/
21 /* Peripheral group ----------------------------------------------------------- */
27 #ifndef LPC17XX_GPDMA_H_
28 #define LPC17XX_GPDMA_H_
29 
30 /* Includes ------------------------------------------------------------------- */
31 #include "LPC17xx.h"
32 #include "lpc_types.h"
33 
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 /* Public Macros -------------------------------------------------------------- */
46 #define GPDMA_CONN_SSP0_Tx ((0UL))
47 #define GPDMA_CONN_SSP0_Rx ((1UL))
48 #define GPDMA_CONN_SSP1_Tx ((2UL))
49 #define GPDMA_CONN_SSP1_Rx ((3UL))
50 #define GPDMA_CONN_ADC ((4UL))
51 #define GPDMA_CONN_I2S_Channel_0 ((5UL))
52 #define GPDMA_CONN_I2S_Channel_1 ((6UL))
53 #define GPDMA_CONN_DAC ((7UL))
54 #define GPDMA_CONN_UART0_Tx ((8UL))
55 #define GPDMA_CONN_UART0_Rx ((9UL))
56 #define GPDMA_CONN_UART1_Tx ((10UL))
57 #define GPDMA_CONN_UART1_Rx ((11UL))
58 #define GPDMA_CONN_UART2_Tx ((12UL))
59 #define GPDMA_CONN_UART2_Rx ((13UL))
60 #define GPDMA_CONN_UART3_Tx ((14UL))
61 #define GPDMA_CONN_UART3_Rx ((15UL))
62 #define GPDMA_CONN_MAT0_0 ((16UL))
63 #define GPDMA_CONN_MAT0_1 ((17UL))
64 #define GPDMA_CONN_MAT1_0 ((18UL))
65 #define GPDMA_CONN_MAT1_1 ((19UL))
66 #define GPDMA_CONN_MAT2_0 ((20UL))
67 #define GPDMA_CONN_MAT2_1 ((21UL))
68 #define GPDMA_CONN_MAT3_0 ((22UL))
69 #define GPDMA_CONN_MAT3_1 ((23UL))
72 #define GPDMA_TRANSFERTYPE_M2M ((0UL))
73 #define GPDMA_TRANSFERTYPE_M2P ((1UL))
74 #define GPDMA_TRANSFERTYPE_P2M ((2UL))
75 #define GPDMA_TRANSFERTYPE_P2P ((3UL))
78 #define GPDMA_BSIZE_1 ((0UL))
79 #define GPDMA_BSIZE_4 ((1UL))
80 #define GPDMA_BSIZE_8 ((2UL))
81 #define GPDMA_BSIZE_16 ((3UL))
82 #define GPDMA_BSIZE_32 ((4UL))
83 #define GPDMA_BSIZE_64 ((5UL))
84 #define GPDMA_BSIZE_128 ((6UL))
85 #define GPDMA_BSIZE_256 ((7UL))
88 #define GPDMA_WIDTH_BYTE ((0UL))
89 #define GPDMA_WIDTH_HALFWORD ((1UL))
90 #define GPDMA_WIDTH_WORD ((2UL))
93 #define GPDMA_REQSEL_UART ((0UL))
94 #define GPDMA_REQSEL_TIMER ((1UL))
101 /* Private Macros ------------------------------------------------------------- */
102 
106 /* --------------------- BIT DEFINITIONS -------------------------------------- */
107 /*********************************************************************/
110 #define GPDMA_DMACIntStat_Ch(n) (((1UL<<n)&0xFF))
111 #define GPDMA_DMACIntStat_BITMASK ((0xFF))
112 
113 /*********************************************************************/
116 #define GPDMA_DMACIntTCStat_Ch(n) (((1UL<<n)&0xFF))
117 #define GPDMA_DMACIntTCStat_BITMASK ((0xFF))
118 
119 /*********************************************************************/
122 #define GPDMA_DMACIntTCClear_Ch(n) (((1UL<<n)&0xFF))
123 #define GPDMA_DMACIntTCClear_BITMASK ((0xFF))
124 
125 /*********************************************************************/
128 #define GPDMA_DMACIntErrStat_Ch(n) (((1UL<<n)&0xFF))
129 #define GPDMA_DMACIntErrStat_BITMASK ((0xFF))
130 
131 /*********************************************************************/
134 #define GPDMA_DMACIntErrClr_Ch(n) (((1UL<<n)&0xFF))
135 #define GPDMA_DMACIntErrClr_BITMASK ((0xFF))
136 
137 /*********************************************************************/
140 #define GPDMA_DMACRawIntTCStat_Ch(n) (((1UL<<n)&0xFF))
141 #define GPDMA_DMACRawIntTCStat_BITMASK ((0xFF))
142 
143 /*********************************************************************/
146 #define GPDMA_DMACRawIntErrStat_Ch(n) (((1UL<<n)&0xFF))
147 #define GPDMA_DMACRawIntErrStat_BITMASK ((0xFF))
148 
149 /*********************************************************************/
152 #define GPDMA_DMACEnbldChns_Ch(n) (((1UL<<n)&0xFF))
153 #define GPDMA_DMACEnbldChns_BITMASK ((0xFF))
154 
155 /*********************************************************************/
158 #define GPDMA_DMACSoftBReq_Src(n) (((1UL<<n)&0xFFFF))
159 #define GPDMA_DMACSoftBReq_BITMASK ((0xFFFF))
160 
161 /*********************************************************************/
164 #define GPDMA_DMACSoftSReq_Src(n) (((1UL<<n)&0xFFFF))
165 #define GPDMA_DMACSoftSReq_BITMASK ((0xFFFF))
166 
167 /*********************************************************************/
170 #define GPDMA_DMACSoftLBReq_Src(n) (((1UL<<n)&0xFFFF))
171 #define GPDMA_DMACSoftLBReq_BITMASK ((0xFFFF))
172 
173 /*********************************************************************/
176 #define GPDMA_DMACSoftLSReq_Src(n) (((1UL<<n)&0xFFFF))
177 #define GPDMA_DMACSoftLSReq_BITMASK ((0xFFFF))
178 
179 /*********************************************************************/
182 #define GPDMA_DMACConfig_E ((0x01))
183 #define GPDMA_DMACConfig_M ((0x02))
184 #define GPDMA_DMACConfig_BITMASK ((0x03))
185 
186 /*********************************************************************/
189 #define GPDMA_DMACSync_Src(n) (((1UL<<n)&0xFFFF))
190 #define GPDMA_DMACSync_BITMASK ((0xFFFF))
191 
192 /*********************************************************************/
195 #define GPDMA_DMAReqSel_Input(n) (((1UL<<(n-8))&0xFF))
196 #define GPDMA_DMAReqSel_BITMASK ((0xFF))
197 
198 /*********************************************************************/
202 #define GPDMA_DMACCxLLI_BITMASK ((0xFFFFFFFC))
203 
204 /*********************************************************************/
207 #define GPDMA_DMACCxControl_TransferSize(n) (((n&0xFFF)<<0))
208 #define GPDMA_DMACCxControl_SBSize(n) (((n&0x07)<<12))
209 #define GPDMA_DMACCxControl_DBSize(n) (((n&0x07)<<15))
210 #define GPDMA_DMACCxControl_SWidth(n) (((n&0x07)<<18))
211 #define GPDMA_DMACCxControl_DWidth(n) (((n&0x07)<<21))
212 #define GPDMA_DMACCxControl_SI ((1UL<<26))
213 #define GPDMA_DMACCxControl_DI ((1UL<<27))
214 #define GPDMA_DMACCxControl_Prot1 ((1UL<<28))
215 #define GPDMA_DMACCxControl_Prot2 ((1UL<<29))
216 #define GPDMA_DMACCxControl_Prot3 ((1UL<<30))
217 #define GPDMA_DMACCxControl_I ((1UL<<31))
219 #define GPDMA_DMACCxControl_BITMASK ((0xFCFFFFFF))
220 
221 /*********************************************************************/
224 #define GPDMA_DMACCxConfig_E ((1UL<<0))
225 #define GPDMA_DMACCxConfig_SrcPeripheral(n) (((n&0x1F)<<1))
226 #define GPDMA_DMACCxConfig_DestPeripheral(n) (((n&0x1F)<<6))
227 #define GPDMA_DMACCxConfig_TransferType(n) (((n&0x7)<<11))
228 #define GPDMA_DMACCxConfig_IE ((1UL<<14))
229 #define GPDMA_DMACCxConfig_ITC ((1UL<<15))
230 #define GPDMA_DMACCxConfig_L ((1UL<<16))
231 #define GPDMA_DMACCxConfig_A ((1UL<<17))
232 #define GPDMA_DMACCxConfig_H ((1UL<<18))
234 #define GPDMA_DMACCxConfig_BITMASK ((0x7FFFF))
235 
236 /* ---------------- CHECK PARAMETER DEFINITIONS ---------------------------- */
237 /* Macros check GPDMA channel */
238 #define PARAM_GPDMA_CHANNEL(n) ((n>=0) && (n<=7))
239 
240 /* Macros check GPDMA connection type */
241 #define PARAM_GPDMA_CONN(n) ((n==GPDMA_CONN_SSP0_Tx) || (n==GPDMA_CONN_SSP0_Rx) \
242 || (n==GPDMA_CONN_SSP1_Tx) || (n==GPDMA_CONN_SSP1_Rx) \
243 || (n==GPDMA_CONN_ADC) || (n==GPDMA_CONN_I2S_Channel_0) \
244 || (n==GPDMA_CONN_I2S_Channel_1) || (n==GPDMA_CONN_DAC) \
245 || (n==GPDMA_CONN_UART0_Tx) || (n==GPDMA_CONN_UART0_Rx) \
246 || (n==GPDMA_CONN_UART1_Tx) || (n==GPDMA_CONN_UART1_Rx) \
247 || (n==GPDMA_CONN_UART2_Tx) || (n==GPDMA_CONN_UART2_Rx) \
248 || (n==GPDMA_CONN_UART3_Tx) || (n==GPDMA_CONN_UART3_Rx) \
249 || (n==GPDMA_CONN_MAT0_0) || (n==GPDMA_CONN_MAT0_1) \
250 || (n==GPDMA_CONN_MAT1_0) || (n==GPDMA_CONN_MAT1_1) \
251 || (n==GPDMA_CONN_MAT2_0) || (n==GPDMA_CONN_MAT2_1) \
252 || (n==GPDMA_CONN_MAT3_0) || (n==GPDMA_CONN_MAT3_1))
253 
254 /* Macros check GPDMA burst size type */
255 #define PARAM_GPDMA_BSIZE(n) ((n==GPDMA_BSIZE_1) || (n==GPDMA_BSIZE_4) \
256 || (n==GPDMA_BSIZE_8) || (n==GPDMA_BSIZE_16) \
257 || (n==GPDMA_BSIZE_32) || (n==GPDMA_BSIZE_64) \
258 || (n==GPDMA_BSIZE_128) || (n==GPDMA_BSIZE_256))
259 
260 /* Macros check GPDMA width type */
261 #define PARAM_GPDMA_WIDTH(n) ((n==GPDMA_WIDTH_BYTE) || (n==GPDMA_WIDTH_HALFWORD) \
262 || (n==GPDMA_WIDTH_WORD))
263 
264 /* Macros check GPDMA status type */
265 #define PARAM_GPDMA_STAT(n) ((n==GPDMA_STAT_INT) || (n==GPDMA_STAT_INTTC) \
266 || (n==GPDMA_STAT_INTERR) || (n==GPDMA_STAT_RAWINTTC) \
267 || (n==GPDMA_STAT_RAWINTERR) || (n==GPDMA_STAT_ENABLED_CH))
268 
269 /* Macros check GPDMA transfer type */
270 #define PARAM_GPDMA_TRANSFERTYPE(n) ((n==GPDMA_TRANSFERTYPE_M2M)||(n==GPDMA_TRANSFERTYPE_M2P) \
271 ||(n==GPDMA_TRANSFERTYPE_P2M)||(n==GPDMA_TRANSFERTYPE_P2P))
272 
273 /* Macros check GPDMA state clear type */
274 #define PARAM_GPDMA_STATCLR(n) ((n==GPDMA_STATCLR_INTTC) || (n==GPDMA_STATCLR_INTERR))
275 
276 /* Macros check GPDMA request select type */
277 #define PARAM_GPDMA_REQSEL(n) ((n==GPDMA_REQSEL_UART) || (n==GPDMA_REQSEL_TIMER))
278 
283 /* Public Types --------------------------------------------------------------- */
291 typedef enum {
299 
303 typedef enum{
307 
311 typedef struct {
312  uint32_t ChannelNum;
317  uint32_t TransferSize;
318  uint32_t TransferWidth;
319  uint32_t SrcMemAddr;
321  uint32_t DstMemAddr;
323  uint32_t TransferType;
329  uint32_t SrcConn;
349  uint32_t DstConn;
369  uint32_t DMALLI;
373 
377 typedef struct {
378  uint32_t SrcAddr;
379  uint32_t DstAddr;
380  uint32_t NextLLI;
381  uint32_t Control;
383 
384 
389 /* Public Functions ----------------------------------------------------------- */
394 void GPDMA_Init(void);
395 //Status GPDMA_Setup(GPDMA_Channel_CFG_Type *GPDMAChannelConfig, fnGPDMACbs_Type *pfnGPDMACbs);
396 Status GPDMA_Setup(GPDMA_Channel_CFG_Type *GPDMAChannelConfig);
397 IntStatus GPDMA_IntGetStatus(GPDMA_Status_Type type, uint8_t channel);
398 void GPDMA_ClearIntPending(GPDMA_StateClear_Type type, uint8_t channel);
399 void GPDMA_ChannelCmd(uint8_t channelNum, FunctionalState NewState);
400 //void GPDMA_IntHandler(void);
401 
407 #ifdef __cplusplus
408 }
409 #endif
410 
411 #endif /* LPC17XX_GPDMA_H_ */
412 
417 /* --------------------------------- End Of File ------------------------------ */