Contiki 3.x
dma.h
Go to the documentation of this file.
1 /**
2  * \file
3  * Header file for the cc2430 DMA controller
4  *
5  * \author
6  * Original: Martti Huttunen <martti@sensinode.com>
7  * Port: Zach Shelby <zach@sensinode.com>
8  * Further Modifications:
9  * George Oikonomou <oikonomou@users.sourceforge.net>
10  */
11 
12 #ifndef __DMA_H
13 #define __DMA_H
14 #include "cc2430_sfr.h"
15 
16 /* DMA triggers */
17 #define DMA_T_NONE 0 /* None, DMAREQ.DMAREQx bits start transfer */
18 #define DMA_T_PREV 1 /* completion of previous channel */
19 #define DMA_T_T1_CH0 2 /* Timer 1, compare, channel 0 */
20 #define DMA_T_T1_CH1 3 /* Timer 1, compare, channel 1 */
21 #define DMA_T_T1_CH2 4 /* Timer 1, compare, channel 2 */
22 #define DMA_T_T2_COMP 5 /* Timer 2, compare */
23 #define DMA_T_T2_OVFL 6 /* Timer 2, overflow */
24 #define DMA_T_T3_CH0 7 /* Timer 3, compare, channel 0 */
25 #define DMA_T_T3_CH1 8 /* Timer 3, compare, channel 1 */
26 #define DMA_T_T4_CH0 9 /* Timer 4, compare, channel 0 */
27 #define DMA_T_T4_CH1 10 /* Timer 4, compare, channel 1 */
28 #define DMA_T_ST 11 /* Sleep Timer compare */
29 #define DMA_T_IOC_0 12 /* Port 0 I/O pin input transition */
30 #define DMA_T_IOC_1 13 /* Port 1 I/O pin input transition */
31 #define DMA_T_URX0 14 /* USART0 RX complete */
32 #define DMA_T_UTX0 15 /* USART0 TX complete */
33 #define DMA_T_URX1 16 /* USART1 RX complete */
34 #define DMA_T_UTX1 17 /* USART1 TX complete */
35 #define DMA_T_FLASH 18 /* Flash data write complete */
36 #define DMA_T_RADIO 19 /* RF packet byte received/transmit */
37 #define DMA_T_ADC_CHALL 20 /* ADC end of a conversion in a sequence */
38 #define DMA_T_ADC_CH11 21 /* ADC end of conversion channel 0 in sequence */
39 #define DMA_T_ADC_CH21 22 /* ADC end of conversion channel 1 in sequence */
40 #define DMA_T_ADC_CH32 23 /* ADC end of conversion channel 2 in sequence */
41 #define DMA_T_ADC_CH42 24 /* ADC end of conversion channel 3 in sequence */
42 #define DMA_T_ADC_CH53 25 /* ADC end of conversion channel 4 in sequence */
43 #define DMA_T_ADC_CH63 26 /* ADC end of conversion channel 5 in sequence */
44 #define DMA_T_ADC_CH74 27 /* ADC end of conversion channel 6 in sequence */
45 #define DMA_T_ADC_CH84 28 /* ADC end of conversion channel 7 in sequence */
46 #define DMA_T_ENC_DW 29 /* AES processor requests download input data */
47 #define DMA_T_ENC_UP 30 /* AES processor requests upload output data */
48 
49 /* variable DMA length modes (VLEN) */
50 #define DMA_VLEN_LEN (0 << 5) /* Use LEN for transfer count*/
51 /*
52  * Transfer the number of bytes/words specified by first byte/word + 1
53  * (up to a maximum specified by LEN).
54  * Thus transfer count excludes length byte/word.
55  */
56 #define DMA_VLEN_N1 (1 << 5)
57  /*
58  * Transfer the number of bytes/words specified by first byte/word
59  * (up to a maximum specified by LEN).
60  * Thus transfer count includes length byte/word.
61  */
62 #define DMA_VLEN_N (2 << 5)
63  /*
64  * Transfer the number of bytes/words specified by first byte/word + 2
65  * (up to a maximum specified by LEN).
66  */
67 #define DMA_VLEN_N2 (3 << 5)
68  /*
69  * Transfer the number of bytes/words specified by first byte/word + 3
70  * (up to a maximum specified by LEN).
71  */
72 #define DMA_VLEN_N3 (4 << 5)
73 #define DMA_VLEN_RES1 (5 << 5) /* reserved */
74 #define DMA_VLEN_RES2 (6 << 5) /* reserved */
75 #define DMA_VLEN_LEN2 (7 << 5) /* Use LEN for transfer count */
76 
77 /* Transfer Types (Byte 6 [6:5]) */
78 #define DMA_SINGLE 0x00 /* Single */
79 #define DMA_BLOCK 0x20 /* Block */
80 #define DMA_RPT_SINGLE 0x40 /* Repeated single */
81 #define DMA_RPT_BLOCK 0x60 /* Repeated block */
82 
83 /* Source Increment Modes (Byte 7 [7:6])*/
84 #define DMA_SRC_INC_NO 0x00 /* Source No increment */
85 #define DMA_SRC_INC_1 0x40 /* Source Increment 1 */
86 #define DMA_SRC_INC_2 0x80 /* Source Increment 2 */
87 #define DMA_SRC_DEC 0xC0 /* Source Decrement 1 */
88 /* Source Increment Modes (Byte 7 [5:4])*/
89 #define DMA_DST_INC_NO 0x00 /* DestinationNo increment */
90 #define DMA_DST_INC_1 0x10 /* Destination Increment 1 */
91 #define DMA_DST_INC_2 0x20 /* Destination Increment 2 */
92 #define DMA_DST_DEC 0x30 /* Destination Decrement 1 */
93 
94 /* Descriptor Byte 7, Bits[3:0] */
95 #define DMA_IRQ_MASK_ENABLE 0x08
96 #define DMA_MODE_7_BIT 0x04
97 #define DMA_PRIO_HIGHEST 0x03
98 #define DMA_PRIO_HIGH 0x02
99 #define DMA_PRIO_GUARANTEED 0x01
100 #define DMA_PRIO_LOW 0x00
101 
102 /** DMA configuration structure */
103 typedef struct dma_config {
104  uint8_t src_h; /* source address high byte*/
105  uint8_t src_l; /* source address low byte*/
106  uint8_t dst_h; /* dest. address high byte*/
107  uint8_t dst_l; /* dest. address low byte*/
108  uint8_t len_h; /* [7:5] VLEN, [4:0] length high byte, 5 lowest bits*/
109  uint8_t len_l; /* length low byte*/
110  uint8_t wtt; /* 7: wordsize, [6:5] transfer mode, [4:0] trigger */
111  /* [7:6] src inc, [5:4] dst_inc, 3: IRQ, 2: M8(vlen), [1-0] prio */
112  uint8_t inc_prio;
113 } dma_config_t;
114 
115 #ifdef DMA_CONF_ON
116 #define DMA_ON DMA_CONF_ON
117 #else
118 #define DMA_ON 0
119 #endif
120 
121 /* Number of DMA Channels and their Descriptors */
122 #if DMA_ON
123 #define DMA_CHANNEL_COUNT 2
124 extern dma_config_t dma_conf[DMA_CHANNEL_COUNT];
125 #endif
126 
127 /* DMA-Related Macros */
128 #define DMA_ARM(c) (DMAARM |= (1 << c)) /* Arm DMA Channel C */
129 #define DMA_TRIGGER(c) (DMAREQ |= (1 << c)) /* Trigger DMA Channel C */
130 /*
131  * Check Channel C for Transfer Status
132  * 1: Complete, Pending Interrupt, 0: Incomplete
133  */
134 #define DMA_STATUS(c) (DMAIRQ &(1 << c))
135 /* Abort Ongoing DMA Transfers on Channel C */
136 #define DMA_ABORT(c) (DMAARM = ABORT | (1 << c))
137 #define DMA_ABORT_ALL() (DMAARM = 0x9F) /* Abort ALL Ongoing DMA Transfers */
138 
139 /* Functions Declarations */
140 void dma_init(void);
141 void dma_associate_process(struct process *p, uint8_t c);
142 
143 /* Only link the ISR when DMA_ON is .... on */
144 #if DMA_ON
145 void dma_ISR(void) __interrupt(DMA_VECTOR);
146 #endif
147 
148 #endif /*__DMA_H*/
CC2430 registers header file for CC2430.
struct dma_config dma_config_t
DMA configuration structure.
void dma_ISR(void)
DMA interrupt service routine.
Definition: dma_intr.c:40
DMA configuration structure.
Definition: dma.h:103