BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
dma.h
Go to the documentation of this file.
1 /* Copyright 2012-2014, Peter A. Bigot
2  *
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 are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
63 #ifndef BSP430_PERIPH_DMA_H
64 #define BSP430_PERIPH_DMA_H
65 
66 #include <bsp430/periph.h>
67 
76 #define BSP430_MODULE_DMAX (defined(__MSP430_HAS_DMAX_3__) \
77  || defined(__MSP430_HAS_DMAX_6__))
78 
88 #define BSP430_MODULE_DMA (defined(__MSP430_HAS_DMA_1__) \
89  || defined(__MSP430_HAS_DMA_6__) \
90  || (BSP430_MODULE_DMAX - 0))
91 
92 /* Only provide declarations if module is supported */
93 #if defined(BSP430_DOXYGEN) || (BSP430_MODULE_DMA - 0)
94 
95 /* !BSP430! periph=dma instance=dma */
96 
101 #define BSP430_DMA_HAL_HPL_VARIANT_DMA 1
102 
107 #define BSP430_DMA_HAL_HPL_VARIANT_DMAX 2
108 
112 #if defined(__MSP430_HAS_DMA_1__)
113 #define BSP430_DMA_NUM_CHANNELS 1
114 #elif defined(BSP430_DOXYGEN) || defined(__MSP430_HAS_DMA_3__) || defined(__MSP430_HAS_DMAX_3__)
115 #define BSP430_DMA_NUM_CHANNELS 3
116 #elif defined(__MSP430_HAS_DMAX_6__)
117 #define BSP430_DMA_NUM_CHANNELS 6
118 #endif /* MCU DMA */
119 
120 #if defined(BSP430_DOXYGEN) || (BSP430_MODULE_DMAX - 0)
121 
125 typedef struct sBSP430hplDMAchannel {
126  unsigned int ctl;
127  unsigned long sa;
128  unsigned long da;
129  unsigned int sz;
130  unsigned int _reserved_x0c;
131  unsigned int _reserved_x0e;
133 
134 #if (BSP430_CORE_FAMILY_IS_5XX - 0)
135 
136 typedef struct sBSP430hplDMA {
137  unsigned int ctl0;
138  unsigned int ctl1;
139  unsigned int ctl2;
140  unsigned int ctl3;
141  unsigned int ctl4;
142  unsigned int _reserved_x0a;
143  unsigned int _reserved_x0c;
144  unsigned int iv;
146 } sBSP430hplDMA;
147 #else /* BSP430_CORE_FAMILY_IS_5XX */
148 
149 typedef struct sBSP430hplDMA {
150  unsigned int ctl0;
151  unsigned int ctl1;
152  unsigned int iv;
153  unsigned int _reserved_skip[(0x1D0 - 0x128) / sizeof(unsigned int)];
155 } sBSP430hplDMA;
156 #endif /* BSP430_CORE_FAMILY_IS_5XX */
157 
158 #else /* BSP430_MODULE_DMAX */
159 
161 typedef struct sBSP430hplDMAchannel {
162  unsigned int ctl;
163  unsigned int sa;
164  unsigned int da;
165  unsigned int sz;
167 
169 typedef struct sBSP430hplDMA {
170  unsigned int ctl0;
171  unsigned int ctl1;
172  unsigned int _reserved_skip[(0x1E0 - 0x126) / sizeof(unsigned int)];
173  sBSP430hplDMAchannel ch[DMA_NUM_CHANNELS];
174 } sBSP430hplDMA;
175 
176 #endif /* BSP430_MODULE_DMAX */
177 
181 #if defined(BSP430_DOXYGEN) || defined(__MSP430_HAS_DMA_1__) || defined(__MSP430_HAS_DMA_3__)
182 #define BSP430_PERIPH_DMA_BASEADDRESS_ 0x0122
183 #elif defined(__MSP430_HAS_DMAX_3__)
184 #if defined(__MSP430_BASEADDRESS_DMAX_3__)
185 #define BSP430_PERIPH_DMA_BASEADDRESS_ __MSP430_BASEADDRESS_DMAX_3__
186 #else /* __MSP430_BASEADDRESS_DMAX_3__ */
187 #define BSP430_PERIPH_DMA_BASEADDRESS_ 0x0122
188 #endif /* __MSP430_BASEADDRESS_DMAX_3__ */
189 #elif defined(__MSP430_HAS_DMAX_6__)
190 #define BSP430_PERIPH_DMA_BASEADDRESS_ __MSP430_BASEADDRESS_DMAX_6__
191 #endif /* MCU DMA */
192 
195 typedef struct sBSP430halDMA {
201 
203  volatile sBSP430hplDMA * const hpl;
204 
206  const struct sBSP430halISRIndexedChainNode * volatile * const ch_cbchain_ni;
207 } sBSP430halDMA;
208 
210 typedef struct sBSP430halDMA * hBSP430halDMA;
211 
212 /* !BSP430! insert=hal_decl with_lookup=0 */
213 /* BEGIN AUTOMATICALLY GENERATED CODE---DO NOT MODIFY [hal_decl] */
227 #ifndef configBSP430_HAL_DMA
228 #define configBSP430_HAL_DMA 0
229 #endif /* configBSP430_HAL_DMA */
230 
232 #if (configBSP430_HAL_DMA - 0)
233 /* You do not need to know about this */
234 extern sBSP430halDMA xBSP430hal_DMA_;
235 #endif /* configBSP430_HAL_DMA */
236 
244 #if defined(BSP430_DOXYGEN) || (configBSP430_HAL_DMA - 0)
245 #define BSP430_HAL_DMA (&xBSP430hal_DMA_)
246 #endif /* configBSP430_HAL_DMA */
247 
248 /* END AUTOMATICALLY GENERATED CODE [hal_decl] */
249 /* !BSP430! end=hal_decl */
250 
251 /* !BSP430! insert=periph_decl with_lookup=0 */
252 /* BEGIN AUTOMATICALLY GENERATED CODE---DO NOT MODIFY [periph_decl] */
265 #ifndef configBSP430_HPL_DMA
266 #define configBSP430_HPL_DMA (configBSP430_HAL_DMA - 0)
267 #endif /* configBSP430_HPL_DMA */
268 
269 #if (configBSP430_HAL_DMA - 0) && ! (configBSP430_HPL_DMA - 0)
270 #warning configBSP430_HAL_DMA requested without configBSP430_HPL_DMA
271 #endif /* HAL and not HPL */
272 
279 #if defined(BSP430_DOXYGEN) || (configBSP430_HPL_DMA - 0)
280 #define BSP430_PERIPH_DMA ((tBSP430periphHandle)(BSP430_PERIPH_DMA_BASEADDRESS_))
281 #endif /* configBSP430_HPL_DMA */
282 
283 /* END AUTOMATICALLY GENERATED CODE [periph_decl] */
284 /* !BSP430! end=periph_decl */
285 
286 /* !BSP430! insert=hpl_decl */
287 /* BEGIN AUTOMATICALLY GENERATED CODE---DO NOT MODIFY [hpl_decl] */
295 #if defined(BSP430_DOXYGEN) || (configBSP430_HPL_DMA - 0)
296 #define BSP430_HPL_DMA ((volatile sBSP430hplDMA *)BSP430_PERIPH_DMA)
297 #endif /* configBSP430_HPL_DMA */
298 
299 /* END AUTOMATICALLY GENERATED CODE [hpl_decl] */
300 /* !BSP430! end=hpl_decl */
301 
302 /* !BSP430! insert=hal_isr_decl */
303 /* BEGIN AUTOMATICALLY GENERATED CODE---DO NOT MODIFY [hal_isr_decl] */
319 #ifndef configBSP430_HAL_DMA_ISR
320 #define configBSP430_HAL_DMA_ISR (configBSP430_HAL_DMA - 0)
321 #endif /* configBSP430_HAL_DMA_ISR */
322 
323 #if (configBSP430_HAL_DMA_ISR - 0) && ! (configBSP430_HAL_DMA - 0)
324 #warning configBSP430_HAL_DMA_ISR requested without configBSP430_HAL_DMA
325 #endif /* HAL_ISR and not HAL */
326 
327 /* END AUTOMATICALLY GENERATED CODE [hal_isr_decl] */
328 /* !BSP430! end=hal_isr_decl */
329 
330 #endif /* BSP430_MODULE_DMA */
331 
332 #endif /* BSP430_PERIPH_DMA_H */
struct sBSP430halDMA * hBSP430halDMA
Definition: dma.h:210
unsigned int sz
Definition: dma.h:129
unsigned int ctl
Definition: dma.h:126
volatile sBSP430hplDMA *const hpl
Definition: dma.h:203
const struct sBSP430halISRIndexedChainNode *volatile *const ch_cbchain_ni
Definition: dma.h:206
Definition: dma.h:195
Definition: dma.h:149
sBSP430hplDMAchannel ch[BSP430_DMA_NUM_CHANNELS]
Definition: dma.h:154
Definition: dma.h:125
struct sBSP430hplDMAchannel sBSP430hplDMAchannel
unsigned int ctl1
Definition: dma.h:151
struct sBSP430hplDMA sBSP430hplDMA
struct sBSP430halDMA sBSP430halDMA
Generic peripheral support for MSP430 MCUs.
Definition: periph.h:437
unsigned long sa
Definition: dma.h:127
unsigned int ctl0
Definition: dma.h:150
#define BSP430_DMA_NUM_CHANNELS
Definition: dma.h:115
unsigned long da
Definition: dma.h:128
sBSP430hplHALStatePrefix hal_state
Definition: dma.h:200
Definition: periph.h:272
unsigned int iv
Definition: dma.h:152