dma.h
Go to the documentation of this file.
1 #ifndef __DMA_H__
2 #define __DMA_H__
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 #include <stdbool.h>
23 #include <msp.h>
24 
25 //*****************************************************************************
26 //
27 // A structure that defines an entry in the channel control table. These
28 // fields are used by the DMA controller and normally it is not necessary for
29 // software to directly read or write fields in the table.
30 //
31 //*****************************************************************************
32 typedef struct _DMA_ControlTable
33 {
34  //
35  // The ending source address of the data transfer.
36  //
37  volatile void *srcEndAddr;
38 
39  //
40  // The ending destination address of the data transfer.
41  //
42  volatile void *dstEndAddr;
43 
44  //
45  // The channel control mode.
46  //
47  volatile uint32_t control;
48 
49  //
50  // An unused location.
51  //
52  volatile uint32_t spare;
54 
55 //*****************************************************************************
56 //
122 //
123 //*****************************************************************************
124 #define DMA_TaskStructEntry(transferCount, \
125  itemSize, \
126  srcIncrement, \
127  srcAddr, \
128  dstIncrement, \
129  dstAddr, \
130  arbSize, \
131  mode) \
132  { \
133  (((srcIncrement) == UDMA_SRC_INC_NONE) ? (void *)(srcAddr) : \
134  ((void *)(&((uint8_t *)(srcAddr))[((transferCount) << \
135  ((srcIncrement) >> 26)) - 1]))), \
136  (((dstIncrement) == UDMA_DST_INC_NONE) ? (void *)(dstAddr) : \
137  ((void *)(&((uint8_t *)(dstAddr))[((transferCount) << \
138  ((dstIncrement) >> 30)) - 1]))), \
139  (srcIncrement) | (dstIncrement) | (itemSize) | (arbSize) | \
140  (((transferCount) - 1) << 4) | \
141  ((((mode) == UDMA_MODE_MEM_SCATTER_GATHER) || \
142  ((mode) == UDMA_MODE_PER_SCATTER_GATHER)) ? \
143  (mode) | UDMA_MODE_ALT_SELECT : (mode)), 0 \
144  }
145 
146 //*****************************************************************************
147 //
148 // Flags that can be passed to DMA_enableChannelAttribute(),
149 // DMA_disableChannelAttribute(), and returned from DMA_getChannelAttribute().
150 //
151 //*****************************************************************************
152 #define UDMA_ATTR_USEBURST 0x00000001
153 #define UDMA_ATTR_ALTSELECT 0x00000002
154 #define UDMA_ATTR_HIGH_PRIORITY 0x00000004
155 #define UDMA_ATTR_REQMASK 0x00000008
156 #define UDMA_ATTR_ALL 0x0000000F
157 
158 //*****************************************************************************
159 //
160 // DMA control modes that can be passed to DMAModeSet() and returned
161 // DMAModeGet().
162 //
163 //*****************************************************************************
164 #define UDMA_MODE_STOP 0x00000000
165 #define UDMA_MODE_BASIC 0x00000001
166 #define UDMA_MODE_AUTO 0x00000002
167 #define UDMA_MODE_PINGPONG 0x00000003
168 #define UDMA_MODE_MEM_SCATTER_GATHER \
169  0x00000004
170 #define UDMA_MODE_PER_SCATTER_GATHER \
171  0x00000006
172 #define UDMA_MODE_ALT_SELECT 0x00000001
173 
174 //*****************************************************************************
175 //
176 // Channel configuration values that can be passed to DMAControlSet().
177 //
178 //*****************************************************************************
179 #define UDMA_DST_INC_8 0x00000000
180 #define UDMA_DST_INC_16 0x40000000
181 #define UDMA_DST_INC_32 0x80000000
182 #define UDMA_DST_INC_NONE 0xc0000000
183 #define UDMA_SRC_INC_8 0x00000000
184 #define UDMA_SRC_INC_16 0x04000000
185 #define UDMA_SRC_INC_32 0x08000000
186 #define UDMA_SRC_INC_NONE 0x0c000000
187 #define UDMA_SIZE_8 0x00000000
188 #define UDMA_SIZE_16 0x11000000
189 #define UDMA_SIZE_32 0x22000000
190 #define UDMA_DST_PROT_PRIV 0x00200000
191 #define UDMA_SRC_PROT_PRIV 0x00040000
192 #define UDMA_ARB_1 0x00000000
193 #define UDMA_ARB_2 0x00004000
194 #define UDMA_ARB_4 0x00008000
195 #define UDMA_ARB_8 0x0000c000
196 #define UDMA_ARB_16 0x00010000
197 #define UDMA_ARB_32 0x00014000
198 #define UDMA_ARB_64 0x00018000
199 #define UDMA_ARB_128 0x0001c000
200 #define UDMA_ARB_256 0x00020000
201 #define UDMA_ARB_512 0x00024000
202 #define UDMA_ARB_1024 0x00028000
203 #define UDMA_NEXT_USEBURST 0x00000008
204 
205 //*****************************************************************************
206 //
207 // Flags to be OR'd with the channel ID to indicate if the primary or alternate
208 // control structure should be used.
209 //
210 //*****************************************************************************
211 #define UDMA_PRI_SELECT 0x00000000
212 #define UDMA_ALT_SELECT 0x00000008
213 
214 //*****************************************************************************
215 //
216 // Values that can be passed to DMA_assignChannel() to select peripheral
217 // mapping for each channel. The channels named RESERVED may be assigned
218 // to a peripheral in future parts.
219 //
220 //*****************************************************************************
221 //
222 // Channel 0
223 //
224 #define DMA_CH0_RESERVED0 0x00000000
225 #define DMA_CH0_EUSCIA0TX 0x01000000
226 #define DMA_CH0_EUSCIB0TX0 0x02000000
227 #define DMA_CH0_EUSCIB3TX1 0x03000000
228 #define DMA_CH0_EUSCIB2TX2 0x04000000
229 #define DMA_CH0_EUSCIB1TX3 0x05000000
230 #define DMA_CH0_TIMERA0CCR0 0x06000000
231 #define DMA_CH0_AESTRIGGER0 0x07000000
232 
233 //
234 // Channel 1
235 //
236 #define DMA_CH1_RESERVED0 0x00000001
237 #define DMA_CH1_EUSCIA0RX 0x01000001
238 #define DMA_CH1_EUSCIB0RX0 0x02000001
239 #define DMA_CH1_EUSCIB3RX1 0x03000001
240 #define DMA_CH1_EUSCIB2RX2 0x04000001
241 #define DMA_CH1_EUSCIB1RX3 0x05000001
242 #define DMA_CH1_TIMERA0CCR2 0x06000001
243 #define DMA_CH1_AESTRIGGER1 0x07000001
244 
245 //
246 // Channel 2
247 //
248 #define DMA_CH2_RESERVED0 0x00000002
249 #define DMA_CH2_EUSCIA1TX 0x01000002
250 #define DMA_CH2_EUSCIB1TX0 0x02000002
251 #define DMA_CH2_EUSCIB0TX1 0x03000002
252 #define DMA_CH2_EUSCIB3TX2 0x04000002
253 #define DMA_CH2_EUSCIB2TX3 0x05000002
254 #define DMA_CH2_TIMERA1CCR0 0x06000002
255 #define DMA_CH2_AESTRIGGER2 0x07000002
256 
257 //
258 // Channel 3
259 //
260 #define DMA_CH3_RESERVED0 0x00000003
261 #define DMA_CH3_EUSCIA1RX 0x01000003
262 #define DMA_CH3_EUSCIB1RX0 0x02000003
263 #define DMA_CH3_EUSCIB0RX1 0x03000003
264 #define DMA_CH3_EUSCIB3RX2 0x04000003
265 #define DMA_CH3_EUSCIB2RX3 0x05000003
266 #define DMA_CH3_TIMERA1CCR2 0x06000003
267 #define DMA_CH3_RESERVED1 0x07000003
268 
269 //
270 // Channel 4
271 //
272 #define DMA_CH4_RESERVED0 0x00000004
273 #define DMA_CH4_EUSCIA2TX 0x01000004
274 #define DMA_CH4_EUSCIB2TX0 0x02000004
275 #define DMA_CH4_EUSCIB1TX1 0x03000004
276 #define DMA_CH4_EUSCIB0TX2 0x04000004
277 #define DMA_CH4_EUSCIB3TX3 0x05000004
278 #define DMA_CH4_TIMERA2CCR0 0x06000004
279 #define DMA_CH4_RESERVED1 0x07000004
280 
281 //
282 // Channel 5
283 //
284 #define DMA_CH5_RESERVED0 0x00000005
285 #define DMA_CH5_EUSCIA2RX 0x01000005
286 #define DMA_CH5_EUSCIB2RX0 0x02000005
287 #define DMA_CH5_EUSCIB1RX1 0x03000005
288 #define DMA_CH5_EUSCIB0RX2 0x04000005
289 #define DMA_CH5_EUSCIB3RX3 0x05000005
290 #define DMA_CH5_TIMERA2CCR2 0x06000005
291 #define DMA_CH5_RESERVED1 0x07000005
292 
293 //
294 // Channel 6
295 //
296 #define DMA_CH6_RESERVED0 0x00000006
297 #define DMA_CH6_EUSCIA3TX 0x01000006
298 #define DMA_CH6_EUSCIB3TX0 0x02000006
299 #define DMA_CH6_EUSCIB2TX1 0x03000006
300 #define DMA_CH6_EUSCIB1TX2 0x04000006
301 #define DMA_CH6_EUSCIB0TX3 0x05000006
302 #define DMA_CH6_TIMERA3CCR0 0x06000006
303 #define DMA_CH6_EXTERNALPIN 0x07000006
304 
305 //
306 // Channel 7
307 //
308 #define DMA_CH7_RESERVED0 0x00000007
309 #define DMA_CH7_EUSCIA3RX 0x01000007
310 #define DMA_CH7_EUSCIB3RX0 0x02000007
311 #define DMA_CH7_EUSCIB2RX1 0x03000007
312 #define DMA_CH7_EUSCIB1RX2 0x04000007
313 #define DMA_CH7_EUSCIB0RX3 0x05000007
314 #define DMA_CH7_TIMERA3CCR2 0x06000007
315 #define DMA_CH7_ADC14 0x07000007
316 
317 //
318 // Different interrupt handlers to pass into DMA_registerInterrupt and
319 // DMA_unregisterInterrupt and other Int functions
320 //
321 #define DMA_INT0 INT_DMA_INT0
322 #define DMA_INT1 INT_DMA_INT1
323 #define DMA_INT2 INT_DMA_INT2
324 #define DMA_INT3 INT_DMA_INT3
325 #define DMA_INTERR INT_DMA_ERR
326 
327 #define DMA_CHANNEL_0 0
328 #define DMA_CHANNEL_1 1
329 #define DMA_CHANNEL_2 2
330 #define DMA_CHANNEL_3 3
331 #define DMA_CHANNEL_4 4
332 #define DMA_CHANNEL_5 5
333 #define DMA_CHANNEL_6 6
334 #define DMA_CHANNEL_7 7
335 
336 //*****************************************************************************
337 //
338 // API Function prototypes
339 //
340 //*****************************************************************************
341 
342 //*****************************************************************************
343 //
350 //
351 //*****************************************************************************
352 extern void DMA_enableModule(void);
353 
354 //*****************************************************************************
355 //
362 //
363 //*****************************************************************************
364 extern void DMA_disableModule(void);
365 
366 //*****************************************************************************
367 //
375 //
376 //*****************************************************************************
377 extern uint32_t DMA_getErrorStatus(void);
378 
379 //*****************************************************************************
380 //
388 //
389 //*****************************************************************************
390 extern void DMA_clearErrorStatus(void);
391 
392 //*****************************************************************************
393 //
403 //
404 //*****************************************************************************
405 extern void DMA_enableChannel(uint32_t channelNum);
406 
407 //*****************************************************************************
408 //
418 //
419 //*****************************************************************************
420 extern void DMA_disableChannel(uint32_t channelNum);
421 
422 //*****************************************************************************
423 //
433 //
434 //*****************************************************************************
435 extern bool DMA_isChannelEnabled(uint32_t channelNum);
436 
437 //*****************************************************************************
438 //
455 //
456 //*****************************************************************************
457 extern void DMA_setControlBase(void *controlTable);
458 
459 //*****************************************************************************
460 //
468 //
469 //*****************************************************************************
470 extern void* DMA_getControlBase(void);
471 
472 //*****************************************************************************
473 //
481 //
482 //*****************************************************************************
483 extern void* DMA_getControlAlternateBase(void);
484 
485 //*****************************************************************************
486 //
498 //
499 //*****************************************************************************
500 extern void DMA_requestChannel(uint32_t channelNum);
501 
502 //*****************************************************************************
503 //
522 //
523 //*****************************************************************************
524 extern void DMA_enableChannelAttribute(uint32_t channelNum, uint32_t attr);
525 
526 //*****************************************************************************
527 //
546 //
547 //*****************************************************************************
548 extern void DMA_disableChannelAttribute(uint32_t channelNum, uint32_t attr);
549 
550 //*****************************************************************************
551 //
568 //
569 //*****************************************************************************
570 extern uint32_t DMA_getChannelAttribute(uint32_t channelNum);
571 
572 //*****************************************************************************
573 //
618 //
619 //*****************************************************************************
620 extern void DMA_setChannelControl(uint32_t channelStructIndex,
621  uint32_t control);
622 
623 //*****************************************************************************
624 //
690 //
691 //*****************************************************************************
692 extern void DMA_setChannelTransfer(uint32_t channelStructIndex, uint32_t mode,
693  void *srcAddr, void *dstAddr, uint32_t transferSize);
694 
695 //*****************************************************************************
696 //
717 //
718 //*****************************************************************************
719 extern void DMA_setChannelScatterGather(uint32_t channelNum, uint32_t taskCount,
720  void *taskList, uint32_t isPeriphSG);
721 
722 //*****************************************************************************
723 //
736 //
737 //*****************************************************************************
738 extern uint32_t DMA_getChannelSize(uint32_t channelStructIndex);
739 
740 //*****************************************************************************
741 //
755 //
756 //*****************************************************************************
757 extern uint32_t DMA_getChannelMode(uint32_t channelStructIndex);
758 
759 //*****************************************************************************
760 //
778 //
779 //*****************************************************************************
780 extern void DMA_assignChannel(uint32_t mapping);
781 
782 //*****************************************************************************
783 //
793 //
794 //*****************************************************************************
795 extern void DMA_requestSoftwareTransfer(uint32_t channel);
796 
797 //*****************************************************************************
798 //
818 //
819 //*****************************************************************************
820 extern void DMA_assignInterrupt(uint32_t interruptNumber, uint32_t channel);
821 
822 //*****************************************************************************
823 //
839 //
840 //*****************************************************************************
841 extern void DMA_enableInterrupt(uint32_t interruptNumber);
842 
843 //*****************************************************************************
844 //
861 //
862 //*****************************************************************************
863 extern void DMA_disableInterrupt(uint32_t interruptNumber);
864 
865 //*****************************************************************************
866 //
883 //
884 //*****************************************************************************
885 extern uint32_t DMA_getInterruptStatus(void);
886 
887 //*****************************************************************************
888 //
900 //
901 //*****************************************************************************
902 extern void DMA_clearInterruptFlag(uint32_t intChannel);
903 
904 //*****************************************************************************
905 //
926 //
927 //*****************************************************************************
928 extern void DMA_registerInterrupt(uint32_t intChannel,
929  void (*intHandler)(void));
930 
931 //*****************************************************************************
932 //
950 //
951 //*****************************************************************************
952 extern void DMA_unregisterInterrupt(uint32_t intChannel);
953 
954 //*****************************************************************************
955 //
956 // Mark the end of the C bindings section for C++ compilers.
957 //
958 //*****************************************************************************
959 #ifdef __cplusplus
960 }
961 #endif
962 
963 //*****************************************************************************
964 //
965 // Close the Doxygen group.
967 //
968 //*****************************************************************************
969 
970 #endif // __UDMA_H__
uint32_t DMA_getChannelSize(uint32_t channelStructIndex)
Definition: dma.c:507
struct _DMA_ControlTable DMA_ControlTable
Definition: dma.h:32
void DMA_disableChannelAttribute(uint32_t channelNum, uint32_t attr)
Definition: dma.c:177
volatile uint32_t spare
Definition: dma.h:52
void DMA_enableModule(void)
Definition: dma.c:7
void DMA_assignChannel(uint32_t mapping)
Definition: dma.c:604
uint32_t DMA_getChannelMode(uint32_t channelStructIndex)
Definition: dma.c:559
void DMA_setChannelControl(uint32_t channelStructIndex, uint32_t control)
Definition: dma.c:284
void DMA_assignInterrupt(uint32_t interruptNumber, uint32_t channel)
Definition: dma.c:694
void DMA_setControlBase(void *controlTable)
Definition: dma.c:79
uint32_t DMA_getInterruptStatus(void)
Definition: dma.c:723
volatile uint32_t control
Definition: dma.h:47
volatile void * dstEndAddr
Definition: dma.h:42
void DMA_requestChannel(uint32_t channelNum)
Definition: dma.c:111
volatile void * srcEndAddr
Definition: dma.h:37
uint32_t DMA_getChannelAttribute(uint32_t channelNum)
Definition: dma.c:230
void * DMA_getControlBase(void)
Definition: dma.c:93
void DMA_enableChannel(uint32_t channelNum)
Definition: dma.c:39
bool DMA_isChannelEnabled(uint32_t channelNum)
Definition: dma.c:65
void DMA_setChannelScatterGather(uint32_t channelNum, uint32_t taskCount, void *taskList, uint32_t isPeriphSG)
Definition: dma.c:438
void DMA_enableChannelAttribute(uint32_t channelNum, uint32_t attr)
Definition: dma.c:124
void DMA_registerInterrupt(uint32_t intChannel, void(*intHandler)(void))
Definition: dma.c:772
void DMA_disableChannel(uint32_t channelNum)
Definition: dma.c:52
void DMA_requestSoftwareTransfer(uint32_t channel)
Definition: dma.c:718
void DMA_disableInterrupt(uint32_t interruptNumber)
Definition: dma.c:753
void DMA_setChannelTransfer(uint32_t channelStructIndex, uint32_t mode, void *srcAddr, void *dstAddr, uint32_t transferSize)
Definition: dma.c:316
uint32_t DMA_getErrorStatus(void)
Definition: dma.c:23
void DMA_unregisterInterrupt(uint32_t intChannel)
Definition: dma.c:796
void DMA_clearInterruptFlag(uint32_t intChannel)
Definition: dma.c:728
void DMA_enableInterrupt(uint32_t interruptNumber)
Definition: dma.c:733
void * DMA_getControlAlternateBase(void)
Definition: dma.c:102
void DMA_clearErrorStatus(void)
Definition: dma.c:31
void DMA_disableModule(void)
Definition: dma.c:15

Copyright 2016, Texas Instruments Incorporated