Contiki-NG
Loading...
Searching...
No Matches
udma.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013, Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31/**
32 * \addtogroup cc2538
33 * @{
34 *
35 * \defgroup cc2538-udma cc2538 micro-DMA
36 *
37 * Driver for the cc2538 uDMA controller
38 * @{
39 *
40 * \file
41 * Header file with register, macro and function declarations for the cc2538
42 * micro-DMA controller module
43 */
44#ifndef UDMA_H_
45#define UDMA_H_
46
47#include "contiki.h"
48#include <stdbool.h>
49
50/*
51 * Enable all uDMA channels unless a conf file tells us to do otherwise.
52 * Using all 31 channels will consume a lot of RAM for the channel control
53 * data structure. Thus it's wise to set this define to the number of the
54 * highest channel in use
55 */
56#ifndef UDMA_CONF_MAX_CHANNEL
57#define UDMA_CONF_MAX_CHANNEL 31
58#endif
59/*---------------------------------------------------------------------------*/
60/**
61 * \name uDMA Register offset declarations
62 * @{
63 */
64#define UDMA_STAT 0x400FF000 /**< DMA status */
65#define UDMA_CFG 0x400FF004 /**< DMA configuration */
66#define UDMA_CTLBASE 0x400FF008 /**< DMA channel control base pointer */
67#define UDMA_ALTBASE 0x400FF00C /**< DMA alternate channel control base pointer */
68#define UDMA_WAITSTAT 0x400FF010 /**< DMA channel wait-on-request status */
69#define UDMA_SWREQ 0x400FF014 /**< DMA channel software request */
70#define UDMA_USEBURSTSET 0x400FF018 /**< DMA channel useburst set */
71#define UDMA_USEBURSTCLR 0x400FF01C /**< DMA channel useburst clear */
72#define UDMA_REQMASKSET 0x400FF020 /**< DMA channel request mask set */
73#define UDMA_REQMASKCLR 0x400FF024 /**< DMA channel request mask clear */
74#define UDMA_ENASET 0x400FF028 /**< DMA channel enable set */
75#define UDMA_ENACLR 0x400FF02C /**< DMA channel enable clear */
76#define UDMA_ALTSET 0x400FF030 /**< DMA channel primary alternate set */
77#define UDMA_ALTCLR 0x400FF034 /**< DMA channel primary alternate clear */
78#define UDMA_PRIOSET 0x400FF038 /**< DMA channel priority set */
79#define UDMA_PRIOCLR 0x400FF03C /**< DMA channel priority clear */
80#define UDMA_ERRCLR 0x400FF04C /**< DMA bus error clear */
81#define UDMA_CHASGN 0x400FF500 /**< DMA channel assignment */
82#define UDMA_CHIS 0x400FF504 /**< DMA channel interrupt status */
83#define UDMA_CHMAP0 0x400FF510 /**< DMA channel map select 0 */
84#define UDMA_CHMAP1 0x400FF514 /**< DMA channel map select 1 */
85#define UDMA_CHMAP2 0x400FF518 /**< DMA channel map select 2 */
86#define UDMA_CHMAP3 0x400FF51C /**< DMA channel map select 3 */
87/** @} */
88/*---------------------------------------------------------------------------*/
89/**
90 * \name UDMA_STAT register bit masks
91 * @{
92 */
93#define UDMA_STAT_DMACHANS 0x001F0000 /**< Available uDMA channels minus 1 */
94#define UDMA_STAT_STATE 0x000000F0 /**< Control state machine status */
95#define UDMA_STAT_MASTEN 0x00000001 /**< Master enable status */
96/** @} */
97/*---------------------------------------------------------------------------*/
98/**
99 * \name UDMA_CFG register bit masks
100 * @{
101 */
102#define UDMA_CFG_MASTEN 0x00000001 /**< Controller master enable */
103/** @} */
104/*---------------------------------------------------------------------------*/
105/**
106 * \name UDMA_CTLBASE register bit masks
107 * @{
108 */
109#define UDMA_CTLBASE_ADDR 0xFFFFFC00 /**< Channel control base address */
110/** @} */
111/*---------------------------------------------------------------------------*/
112/**
113 * \name UDMA_ALTBASE register bit masks
114 * @{
115 */
116#define UDMA_ALTBASE_ADDR 0xFFFFFFFF /**< Alternate channel address pointer */
117/** @} */
118/*---------------------------------------------------------------------------*/
119/**
120 * \name UDMA_WAITSTAT register bit masks
121 * @{
122 */
123#define UDMA_WAITSTAT_WAITREQ 0xFFFFFFFF /**< Channel [n] wait status */
124/** @} */
125/*---------------------------------------------------------------------------*/
126/**
127 * \name UDMA_SWREQ register bit masks
128 * @{
129 */
130#define UDMA_SWREQ_SWREQ 0xFFFFFFFF /**< Channel [n] software request */
131/** @} */
132/*---------------------------------------------------------------------------*/
133/**
134 * \name UDMA_USEBURSTSET register bit masks
135 * @{
136 */
137#define UDMA_USEBURSTSET_SET 0xFFFFFFFF /**< Channel [n] useburst set */
138/** @} */
139/*---------------------------------------------------------------------------*/
140/**
141 * \name UDMA_USEBURSTCLR register bit masks
142 * @{
143 */
144#define UDMA_USEBURSTCLR_CLR 0xFFFFFFFF /**< Channel [n] useburst clear */
145/** @} */
146/*---------------------------------------------------------------------------*/
147/**
148 * \name UDMA_REQMASKSET register bit masks
149 * @{
150 */
151#define UDMA_REQMASKSET_SET 0xFFFFFFFF /**< Channel [n] request mask set */
152/** @} */
153/*---------------------------------------------------------------------------*/
154/**
155 * \name UDMA_REQMASKCLR register bit masks
156 * @{
157 */
158#define UDMA_REQMASKCLR_CLR 0xFFFFFFFF /**< Channel [n] request mask clear */
159/** @} */
160/*---------------------------------------------------------------------------*/
161/**
162 * \name UDMA_ENASET register bit masks
163 * @{
164 */
165#define UDMA_ENASET_SET 0xFFFFFFFF /**< Channel [n] enable set */
166/** @} */
167/*---------------------------------------------------------------------------*/
168/**
169 * \name UDMA_ENACLR register bit masks
170 * @{
171 */
172#define UDMA_ENACLR_CLR 0xFFFFFFFF /**< Channel [n] enable clear */
173/** @} */
174/*---------------------------------------------------------------------------*/
175/**
176 * \name UDMA_ALTSET register bit masks
177 * @{
178 */
179#define UDMA_ALTSET_SET 0xFFFFFFFF /**< Channel [n] alternate set */
180/** @} */
181/*---------------------------------------------------------------------------*/
182/**
183 * \name UDMA_ALTCLR register bit masks
184 * @{
185 */
186#define UDMA_ALTCLR_CLR 0xFFFFFFFF /**< Channel [n] alternate clear */
187/** @} */
188/*---------------------------------------------------------------------------*/
189/**
190 * \name UDMA_PRIOSET register bit masks
191 * @{
192 */
193#define UDMA_PRIOSET_SET 0xFFFFFFFF /**< Channel [n] priority set */
194/** @} */
195/*---------------------------------------------------------------------------*/
196/**
197 * \name UDMA_PRIOCLR register bit masks
198 * @{
199 */
200#define UDMA_PRIOCLR_CLR 0xFFFFFFFF /**< Channel [n] priority clear */
201/** @} */
202/*---------------------------------------------------------------------------*/
203/**
204 * \name UDMA_ERRCLR register bit masks
205 * @{
206 */
207#define UDMA_ERRCLR_ERRCLR 0x00000001 /**< uDMA bus error status */
208/** @} */
209/*---------------------------------------------------------------------------*/
210/**
211 * \name UDMA_CHASGN register bit masks
212 * @{
213 */
214#define UDMA_CHASGN_CHASGN 0xFFFFFFFF /**< Channel [n] assignment select */
215/** @} */
216/*---------------------------------------------------------------------------*/
217/**
218 * \name UDMA_CHIS register bit masks
219 * @{
220 */
221#define UDMA_CHIS_CHIS 0xFFFFFFFF /**< Channel [n] interrupt status */
222/** @} */
223/*---------------------------------------------------------------------------*/
224/**
225 * \name UDMA_CHMAP0 register bit masks
226 * @{
227 */
228#define UDMA_CHMAP0_CH7SEL 0xF0000000 /**< uDMA channel 7 source select */
229#define UDMA_CHMAP0_CH6SEL 0x0F000000 /**< uDMA channel 6 source select */
230#define UDMA_CHMAP0_CH5SEL 0x00F00000 /**< uDMA channel 5 source select */
231#define UDMA_CHMAP0_CH4SEL 0x000F0000 /**< uDMA channel 4 source select */
232#define UDMA_CHMAP0_CH3SEL 0x0000F000 /**< uDMA channel 3 source select */
233#define UDMA_CHMAP0_CH2SEL 0x00000F00 /**< uDMA channel 2 source select */
234#define UDMA_CHMAP0_CH1SEL 0x000000F0 /**< uDMA channel 1 source select */
235#define UDMA_CHMAP0_CH0SEL 0x0000000F /**< uDMA channel 0 source select */
236/** @} */
237/*---------------------------------------------------------------------------*/
238/** \name UDMA_CHMAP1 register bit masks
239 * @{
240 */
241#define UDMA_CHMAP1_CH15SEL 0xF0000000 /**< uDMA channel 15 source select */
242#define UDMA_CHMAP1_CH14SEL 0x0F000000 /**< uDMA channel 14 source select */
243#define UDMA_CHMAP1_CH13SEL 0x00F00000 /**< uDMA channel 13 source select */
244#define UDMA_CHMAP1_CH12SEL 0x000F0000 /**< uDMA channel 12 source select */
245#define UDMA_CHMAP1_CH11SEL 0x0000F000 /**< uDMA channel 11 source select */
246#define UDMA_CHMAP1_CH10SEL 0x00000F00 /**< uDMA channel 10 source select */
247#define UDMA_CHMAP1_CH9SEL 0x000000F0 /**< uDMA channel 9 source select */
248#define UDMA_CHMAP1_CH8SEL 0x0000000F /**< uDMA channel 8 source select */
249/** @} */
250/*---------------------------------------------------------------------------*/
251/**
252 * \name UDMA_CHMAP2 register bit masks
253 * @{
254 */
255#define UDMA_CHMAP2_CH23SEL 0xF0000000 /**< uDMA channel 23 source select */
256#define UDMA_CHMAP2_CH22SEL 0x0F000000 /**< uDMA channel 22 source select */
257#define UDMA_CHMAP2_CH21SEL 0x00F00000 /**< uDMA channel 21 source select */
258#define UDMA_CHMAP2_CH20SEL 0x000F0000 /**< uDMA channel 20 source select */
259#define UDMA_CHMAP2_CH19SEL 0x0000F000 /**< uDMA channel 19 source select */
260#define UDMA_CHMAP2_CH18SEL 0x00000F00 /**< uDMA channel 18 source select */
261#define UDMA_CHMAP2_CH17SEL 0x000000F0 /**< uDMA channel 17 source select */
262#define UDMA_CHMAP2_CH16SEL 0x0000000F /**< uDMA channel 16 source select */
263/** @} */
264/*---------------------------------------------------------------------------*/
265/**
266 * \name UDMA_CHMAP3 register bit masks
267 * @{
268 */
269#define UDMA_CHMAP3_CH31SEL 0xF0000000 /**< uDMA channel 31 source select */
270#define UDMA_CHMAP3_CH30SEL 0x0F000000 /**< uDMA channel 30 source select */
271#define UDMA_CHMAP3_CH29SEL 0x00F00000 /**< uDMA channel 29 source select */
272#define UDMA_CHMAP3_CH28SEL 0x000F0000 /**< uDMA channel 28 source select */
273#define UDMA_CHMAP3_CH27SEL 0x0000F000 /**< uDMA channel 27 source select */
274#define UDMA_CHMAP3_CH26SEL 0x00000F00 /**< uDMA channel 26 source select */
275#define UDMA_CHMAP3_CH25SEL 0x000000F0 /**< uDMA channel 25 source select */
276#define UDMA_CHMAP3_CH24SEL 0x0000000F /**< uDMA channel 24 source select */
277/** @} */
278/*---------------------------------------------------------------------------*/
279/**
280 * \name uDMA Channel encoding assignments
281 * @{
282 */
283/* Channel 0 */
284#define UDMA_CH0_RESERVED0 0x00
285#define UDMA_CH0_RESERVED1 0x01
286#define UDMA_CH0_RESERVED2 0x02
287#define UDMA_CH0_RESERVED3 0x03
288#define UDMA_CH0_USB 0x04
289
290/* Channel 1 */
291#define UDMA_CH1_RESERVED0 0x00
292#define UDMA_CH1_RESERVED1 0x01
293#define UDMA_CH1_RESERVED2 0x02
294#define UDMA_CH1_RESERVED3 0x03
295#define UDMA_CH1_ADC 0x04
296
297/* Channel 2 */
298#define UDMA_CH2_RESERVED0 0x00
299#define UDMA_CH2_TIMER3A 0x01
300#define UDMA_CH2_RESERVED2 0x02
301#define UDMA_CH2_RESERVED3 0x03
302#define UDMA_CH2_FLASH 0x04
303
304/* Channel 3 */
305#define UDMA_CH3_RESERVED0 0x00
306#define UDMA_CH3_TIMER3B 0x01
307#define UDMA_CH3_RESERVED2 0x02
308#define UDMA_CH3_RESERVED3 0x03
309#define UDMA_CH3_RFCORETRG1 0x04
310
311/* Channel 4 */
312#define UDMA_CH4_RESERVED0 0x00
313#define UDMA_CH4_TIMER2A 0x01
314#define UDMA_CH4_RESERVED2 0x02
315#define UDMA_CH4_RESERVED3 0x03
316#define UDMA_CH4_RFCORETRG2 0x04
317
318/* Channel 5 */
319#define UDMA_CH5_RESERVED0 0x00
320#define UDMA_CH5_TIMER2B 0x01
321#define UDMA_CH5_RESERVED2 0x02
322#define UDMA_CH5_RESERVED3 0x03
323#define UDMA_CH5_RESERVED4 0x04
324
325/* Channel 6 */
326#define UDMA_CH6_RESERVED0 0x00
327#define UDMA_CH6_TIMER2A 0x01
328#define UDMA_CH6_RESERVED2 0x02
329#define UDMA_CH6_RESERVED3 0x03
330#define UDMA_CH6_RESERVED4 0x04
331
332/* Channel 7 */
333#define UDMA_CH7_RESERVED0 0x00
334#define UDMA_CH7_TIMER2B 0x01
335#define UDMA_CH7_RESERVED2 0x02
336#define UDMA_CH7_RESERVED3 0x03
337#define UDMA_CH7_RESERVED4 0x04
338
339/* Channel 8 */
340#define UDMA_CH8_UART0RX 0x00
341#define UDMA_CH8_UART1RX 0x01
342#define UDMA_CH8_RESERVED2 0x02
343#define UDMA_CH8_RESERVED3 0x03
344#define UDMA_CH8_RESERVED4 0x04
345
346/* Channel 9 */
347#define UDMA_CH9_UART0TX 0x00
348#define UDMA_CH9_UART1TX 0x01
349#define UDMA_CH9_RESERVED2 0x02
350#define UDMA_CH9_RESERVED3 0x03
351#define UDMA_CH9_RESERVED4 0x04
352
353/* Channel 10 */
354#define UDMA_CH10_SSI0RX 0x00
355#define UDMA_CH10_SSI1RX 0x01
356#define UDMA_CH10_RESERVED2 0x02
357#define UDMA_CH10_RESERVED3 0x03
358#define UDMA_CH10_RESERVED4 0x04
359
360/* Channel 11 */
361#define UDMA_CH11_SSI0TX 0x00
362#define UDMA_CH11_SSI1TX 0x01
363#define UDMA_CH11_RESERVED2 0x02
364#define UDMA_CH11_RESERVED3 0x03
365#define UDMA_CH11_RESERVED4 0x04
366
367/* Channel 12 */
368#define UDMA_CH12_RESERVED0 0x00
369#define UDMA_CH12_RESERVED1 0x01
370#define UDMA_CH12_RESERVED2 0x02
371#define UDMA_CH12_RESERVED3 0x03
372#define UDMA_CH12_RESERVED4 0x04
373
374/* Channel 13 */
375#define UDMA_CH13_RESERVED0 0x00
376#define UDMA_CH13_RESERVED1 0x01
377#define UDMA_CH13_RESERVED2 0x02
378#define UDMA_CH13_RESERVED3 0x03
379#define UDMA_CH13_RESERVED4 0x04
380
381/* Channel 14 */
382#define UDMA_CH14_ADC0 0x00
383#define UDMA_CH14_TIMER2A 0x01
384#define UDMA_CH14_RESERVED2 0x02
385#define UDMA_CH14_RESERVED3 0x03
386#define UDMA_CH14_RESERVED4 0x04
387
388/* Channel 15 */
389#define UDMA_CH15_ADC1 0x00
390#define UDMA_CH15_TIMER2B 0x01
391#define UDMA_CH15_RESERVED2 0x02
392#define UDMA_CH15_RESERVED3 0x03
393#define UDMA_CH15_RESERVED4 0x04
394
395/* Channel 16 */
396#define UDMA_CH16_ADC2 0x00
397#define UDMA_CH16_RESERVED1 0x01
398#define UDMA_CH16_RESERVED2 0x02
399#define UDMA_CH16_RESERVED3 0x03
400#define UDMA_CH16_RESERVED4 0x04
401
402/* Channel 17 */
403#define UDMA_CH17_ADC3 0x00
404#define UDMA_CH17_RESERVED1 0x01
405#define UDMA_CH17_RESERVED2 0x02
406#define UDMA_CH17_RESERVED3 0x03
407#define UDMA_CH17_RESERVED4 0x04
408
409/* Channel 18 */
410#define UDMA_CH18_TIMER0A 0x00
411#define UDMA_CH18_TIMER1A 0x01
412#define UDMA_CH18_RESERVED2 0x02
413#define UDMA_CH18_RESERVED3 0x03
414#define UDMA_CH18_RESERVED4 0x04
415
416/* Channel 19 */
417#define UDMA_CH19_TIMER0B 0x00
418#define UDMA_CH19_TIMER1B 0x01
419#define UDMA_CH19_RESERVED2 0x02
420#define UDMA_CH19_RESERVED3 0x03
421#define UDMA_CH19_RESERVED4 0x04
422
423/* Channel 20 */
424#define UDMA_CH20_TIMER1A 0x00
425#define UDMA_CH20_RESERVED1 0x01
426#define UDMA_CH20_RESERVED2 0x02
427#define UDMA_CH20_RESERVED3 0x03
428#define UDMA_CH20_RESERVED4 0x04
429
430/* Channel 21 */
431#define UDMA_CH21_TIMER1B 0x00
432#define UDMA_CH21_RESERVED1 0x01
433#define UDMA_CH21_RESERVED2 0x02
434#define UDMA_CH21_RESERVED3 0x03
435#define UDMA_CH21_RESERVED4 0x04
436
437/* Channel 22 */
438#define UDMA_CH22_UART1RX 0x00
439#define UDMA_CH22_RESERVED1 0x01
440#define UDMA_CH22_RESERVED2 0x02
441#define UDMA_CH22_RESERVED3 0x03
442#define UDMA_CH22_RESERVED4 0x04
443
444/* Channel 23 */
445#define UDMA_CH23_UART1TX 0x00
446#define UDMA_CH23_RESERVED1 0x01
447#define UDMA_CH23_RESERVED2 0x02
448#define UDMA_CH23_RESERVED3 0x03
449#define UDMA_CH23_RESERVED4 0x04
450
451/* Channel 24 */
452#define UDMA_CH24_SSI1RX 0x00
453#define UDMA_CH24_ADC4 0x01
454#define UDMA_CH24_RESERVED2 0x02
455#define UDMA_CH24_RESERVED3 0x03
456#define UDMA_CH24_RESERVED4 0x04
457
458/* Channel 25 */
459#define UDMA_CH25_SSI1TX 0x00
460#define UDMA_CH25_ADC5 0x01
461#define UDMA_CH25_RESERVED2 0x02
462#define UDMA_CH25_RESERVED3 0x03
463#define UDMA_CH25_RESERVED4 0x04
464
465/* Channel 26 */
466#define UDMA_CH26_RESERVED0 0x00
467#define UDMA_CH26_ADC6 0x01
468#define UDMA_CH26_RESERVED2 0x02
469#define UDMA_CH26_RESERVED3 0x03
470#define UDMA_CH26_RESERVED4 0x04
471
472/* Channel 27 */
473#define UDMA_CH27_RESERVED0 0x00
474#define UDMA_CH27_ADC7 0x01
475#define UDMA_CH27_RESERVED2 0x02
476#define UDMA_CH27_RESERVED3 0x03
477#define UDMA_CH27_RESERVED4 0x04
478
479/* Channel 28 */
480#define UDMA_CH28_RESERVED0 0x00
481#define UDMA_CH28_RESERVED1 0x01
482#define UDMA_CH28_RESERVED2 0x02
483#define UDMA_CH28_RESERVED3 0x03
484#define UDMA_CH28_RESERVED4 0x04
485
486/* Channel 29 */
487#define UDMA_CH29_RESERVED0 0x00
488#define UDMA_CH29_RESERVED1 0x01
489#define UDMA_CH29_RESERVED2 0x02
490#define UDMA_CH29_RESERVED3 0x03
491#define UDMA_CH29_RFCORET2TRG1 0x04
492
493/* Channel 30 */
494#define UDMA_CH30_SW 0x00
495#define UDMA_CH30_RESERVED1 0x01
496#define UDMA_CH30_RESERVED2 0x02
497#define UDMA_CH30_RESERVED3 0x03
498#define UDMA_CH30_RFCORET2TRG2 0x04
499
500/* Channel 31 */
501#define UDMA_CH31_RESERVED0 0x00
502#define UDMA_CH31_RESERVED1 0x01
503#define UDMA_CH31_RESERVED2 0x02
504#define UDMA_CH31_RESERVED3 0x03
505#define UDMA_CH31_RESERVED4 0x04
506/** @} */
507/*---------------------------------------------------------------------------*/
508/**
509 * \name Values to ORd together as the ctrl argument of
510 * udma_set_channel_control_word()
511 * @{
512 */
513#define UDMA_CHCTL_DSTINC_NONE 0xC0000000 /**< Dst address no increment */
514#define UDMA_CHCTL_DSTINC_32 0x80000000 /**< Dst address increment 32 bit */
515#define UDMA_CHCTL_DSTINC_16 0x40000000 /**< Dst address increment 16 bit */
516#define UDMA_CHCTL_DSTINC_8 0x00000000 /**< Dst address increment 8 bit */
517
518#define UDMA_CHCTL_DSTSIZE_32 0x20000000 /**< Destination size 32 bit */
519#define UDMA_CHCTL_DSTSIZE_16 0x10000000 /**< Destination size 16 bit */
520#define UDMA_CHCTL_DSTSIZE_8 0x00000000 /**< Destination size 8 bit */
521
522#define UDMA_CHCTL_SRCINC_NONE 0x0C000000 /**< Source address no increment */
523#define UDMA_CHCTL_SRCINC_32 0x08000000 /**< Source address increment 32 bit */
524#define UDMA_CHCTL_SRCINC_16 0x04000000 /**< Source address increment 16 bit */
525#define UDMA_CHCTL_SRCINC_8 0x00000000 /**< Source address increment 8 bit */
526
527#define UDMA_CHCTL_SRCSIZE_32 0x02000000 /**< Source size 32 bit */
528#define UDMA_CHCTL_SRCSIZE_16 0x01000000 /**< Source size 16 bit */
529#define UDMA_CHCTL_SRCSIZE_8 0x00000000 /**< Source size 8 bit */
530
531#define UDMA_CHCTL_ARBSIZE_1 0x00000000 /**< Arbitration size 1 Transfer */
532#define UDMA_CHCTL_ARBSIZE_2 0x00004000 /**< Arbitration size 2 Transfers */
533#define UDMA_CHCTL_ARBSIZE_4 0x00008000 /**< Arbitration size 4 Transfers */
534#define UDMA_CHCTL_ARBSIZE_8 0x0000C000 /**< Arbitration size 8 Transfers */
535#define UDMA_CHCTL_ARBSIZE_16 0x00010000 /**< Arbitration size 16 Transfers */
536#define UDMA_CHCTL_ARBSIZE_32 0x00014000 /**< Arbitration size 32 Transfers */
537#define UDMA_CHCTL_ARBSIZE_64 0x00018000 /**< Arbitration size 64 Transfers */
538#define UDMA_CHCTL_ARBSIZE_128 0x0001C000 /**< Arbitration size 128 Transfers */
539#define UDMA_CHCTL_ARBSIZE_256 0x00020000 /**< Arbitration size 256 Transfers */
540#define UDMA_CHCTL_ARBSIZE_512 0x00024000 /**< Arbitration size 512 Transfers */
541#define UDMA_CHCTL_ARBSIZE_1024 0x00028000 /**< Arbitration size 1024 Transfers */
542
543#define UDMA_CHCTL_XFERMODE_STOP 0x00000000 /**< Stop */
544#define UDMA_CHCTL_XFERMODE_BASIC 0x00000001 /**< Basic */
545#define UDMA_CHCTL_XFERMODE_AUTO 0x00000002 /**< Auto-Request */
546#define UDMA_CHCTL_XFERMODE_PINGPONG 0x00000003 /**< Ping-Pong */
547#define UDMA_CHCTL_XFERMODE_MEM_SG 0x00000004 /**< Memory Scatter-Gather */
548#define UDMA_CHCTL_XFERMODE_MEM_SGA 0x00000005 /**< Memory Scatter-Gather Alt */
549#define UDMA_CHCTL_XFERMODE_PER_SG 0x00000006 /**< Peripheral Scatter-Gather */
550#define UDMA_CHCTL_XFERMODE_PER_SGA 0x00000007 /**< Peripheral Scatter-Gather Alt */
551/** @} */
552/*---------------------------------------------------------------------------*/
553
554/**
555 * \brief Checks if data can be DMAed from the given address
556 */
557bool udma_is_valid_source_address(uintptr_t address);
558
559/**
560 * \brief Initialise the uDMA driver
561 *
562 * Prepares the channel control structure and enables the controller
563 */
564void udma_init(void);
565
566/**
567 * \brief Sets the channels source address
568 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
569 * \param src_end The source's end address
570 */
571void udma_set_channel_src(uint8_t channel, uint32_t src_end);
572
573/**
574 * \brief Sets the channel's destination address
575 * \param dst_end The destination's end address
576 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
577 */
578void udma_set_channel_dst(uint8_t channel, uint32_t dst_end);
579
580/**
581 * \brief Configure the channel's control word
582 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
583 * \param ctrl The value of the control word
584 *
585 * The value of the control word is generated by ORing the values defined as
586 * UDMA_CHCTL_xyz
587 *
588 * For example, to configure a channel with 8 bit source and destination size,
589 * 0 source increment and 8 bit destination increment, one would need to pass
590 * UDMA_CHCTL_DSTINC_8 | UDMA_CHCTL_SRCINC_NONE | UDMA_CHCTL_SRCSIZE_8 |
591 * UDMA_CHCTL_DSTSIZE_8
592 *
593 * Macros defined as 0 can be omitted.
594 */
595void udma_set_channel_control_word(uint8_t channel, uint32_t ctrl);
596
597/**
598 * \brief Choose an encoding for a uDMA channel
599 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
600 * \param enc A value in [0 , 4]
601 *
602 * Possible values for the \e encoding param are defined as UDMA_CHnn_xyz
603 */
604void udma_set_channel_assignment(uint8_t channel, uint8_t enc);
605
606/**
607 * \brief Enables a uDMA channel
608 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
609 */
610void udma_channel_enable(uint8_t channel);
611
612/**
613 * \brief Disables a uDMA channel
614 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
615 */
616void udma_channel_disable(uint8_t channel);
617
618/**
619 * \brief Use the alternate control data structure for a channel
620 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
621 *
622 * \note Currently, the driver only reserves memory space for primary contrl
623 * data structures
624 */
625void udma_channel_use_alternate(uint8_t channel);
626
627/**
628 * \brief Use the primary control data structure for a channel
629 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
630 */
631void udma_channel_use_primary(uint8_t channel);
632
633/**
634 * \brief Set a uDMA channel to high priority
635 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
636 */
637void udma_channel_prio_set_high(uint8_t channel);
638
639/**
640 * \brief Set a uDMA channel to default priority
641 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
642 */
643void udma_channel_prio_set_default(uint8_t channel);
644
645/**
646 * \brief Configure a channel to only use burst transfers
647 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
648 *
649 * \note The uDMA controller may under certain conditions automatically disable
650 * burst mode, in which case this function will need to be called again to
651 * re-enable them
652 */
653void udma_channel_use_burst(uint8_t channel);
654
655/**
656 * \brief Configure a channel to use single as well as burst requests
657 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
658 */
659void udma_channel_use_single(uint8_t channel);
660
661/**
662 * \brief Disable peripheral triggers for a uDMA channel
663 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
664 *
665 * Calling this function will result in the uDMA controller not acknowledging
666 * peripheral-generated transfer triggers. Afterwards, the channel may be used
667 * with software triggers
668 */
669void udma_channel_mask_set(uint8_t channel);
670
671/**
672 * \brief Enable peripheral triggers for a uDMA channel
673 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
674 */
675void udma_channel_mask_clr(uint8_t channel);
676
677/**
678 * \brief Generate a software trigger to start a transfer
679 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
680 */
681void udma_channel_sw_request(uint8_t channel);
682
683/**
684 * \brief Retrieve the current mode for a channel
685 * \param channel The channel as a value in [0 , UDMA_CONF_MAX_CHANNEL]
686 * \return The channel's current mode
687 *
688 * The return value will be one of the UDMA_CHCTL_XFERMODE_xyz defines. This
689 * function is useful to determine whether a uDMA transfer has completed, in
690 * which case the return value will be UDMA_CHCTL_XFERMODE_STOP
691 */
692uint8_t udma_channel_get_mode(uint8_t channel);
693
694/**
695 * \brief Calculate the value of the xfersize field in the control structure
696 * \param len The number of items to be transferred
697 * \return The value to be written to the control structure to achieve the
698 * desired transfer size
699 *
700 * If we want to transfer \e len items, we will normally do something like
701 * udma_set_channel_control_word(OTHER_FLAGS | udma_xfer_size(len))
702 */
703#define udma_xfer_size(len) ((len - 1) << 4)
704
705#endif /* UDMA_H_ */
706
707/**
708 * @}
709 * @}
710 */
bool udma_is_valid_source_address(uintptr_t source_address)
Checks if data can be DMAed from the given address.
Definition udma.c:59
void udma_set_channel_dst(uint8_t channel, uint32_t dst_end)
Sets the channel's destination address.
Definition udma.c:88
void udma_init()
Initialise the uDMA driver.
Definition udma.c:65
void udma_channel_mask_set(uint8_t channel)
Disable peripheral triggers for a uDMA channel.
Definition udma.c:212
void udma_channel_enable(uint8_t channel)
Enables a uDMA channel.
Definition udma.c:128
uint8_t udma_channel_get_mode(uint8_t channel)
Retrieve the current mode for a channel.
Definition udma.c:243
void udma_channel_sw_request(uint8_t channel)
Generate a software trigger to start a transfer.
Definition udma.c:233
void udma_channel_use_burst(uint8_t channel)
Configure a channel to only use burst transfers.
Definition udma.c:191
void udma_channel_disable(uint8_t channel)
Disables a uDMA channel.
Definition udma.c:138
void udma_channel_prio_set_high(uint8_t channel)
Set a uDMA channel to high priority.
Definition udma.c:170
void udma_channel_mask_clr(uint8_t channel)
Enable peripheral triggers for a uDMA channel.
Definition udma.c:222
void udma_set_channel_control_word(uint8_t channel, uint32_t ctrl)
Configure the channel's control word.
Definition udma.c:98
void udma_set_channel_assignment(uint8_t channel, uint8_t enc)
Choose an encoding for a uDMA channel.
Definition udma.c:108
void udma_channel_use_single(uint8_t channel)
Configure a channel to use single as well as burst requests.
Definition udma.c:201
void udma_channel_use_primary(uint8_t channel)
Use the primary control data structure for a channel.
Definition udma.c:159
void udma_channel_prio_set_default(uint8_t channel)
Set a uDMA channel to default priority.
Definition udma.c:180
void udma_set_channel_src(uint8_t channel, uint32_t src_end)
Sets the channels source address.
Definition udma.c:78
void udma_channel_use_alternate(uint8_t channel)
Use the alternate control data structure for a channel.
Definition udma.c:149