TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
UDMACC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Texas Instruments Incorporated
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  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
111 #ifndef ti_drivers_UDMACC26XX__include
112 #define ti_drivers_UDMACC26XX__include
113 
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117 
118 #include <stdint.h>
119 #include <stdbool.h>
120 #include "driverlib/udma.h"
121 #include "inc/hw_types.h"
122 
123 #include <ti/sysbios/family/arm/cc26xx/Power.h>
124 #include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
125 
127 #ifndef UDMACC26XX_CONFIG_BASE
128  #define UDMACC26XX_CONFIG_BASE 0x20000400
129 #endif
130 
132 #if(UDMACC26XX_CONFIG_BASE & 0x3FF)
133  #error "Base address for DMA control table 'UDMACC26XX_CONFIG_BASE' must be 1024 bytes aligned."
134 #endif
135 
137 #if defined(__IAR_SYSTEMS_ICC__)
138 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
139 __no_init static volatile tDMAControlTable ENTRY_NAME @ UDMACC26XX_CONFIG_BASE + CHANNEL_INDEX * sizeof(tDMAControlTable)
140 #elif defined(__TI_COMPILER_VERSION__)
141 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
142 PRAGMA(LOCATION( ENTRY_NAME , UDMACC26XX_CONFIG_BASE + CHANNEL_INDEX * sizeof(tDMAControlTable) );)\
143 static volatile tDMAControlTable ENTRY_NAME
144 #define PRAGMA(x) _Pragma(#x)
145 #elif defined(__GNUC__)
146 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
147  extern int UDMACC26XX_ ## ENTRY_NAME ## _is_placed; __attribute__ ((section("."#ENTRY_NAME))) static volatile tDMAControlTable ENTRY_NAME = {&UDMACC26XX_ ## ENTRY_NAME ## _is_placed}
148 #else
149 #error "don't know how to define ALLOCATE_CONTROL_TABLE_ENTRY for this toolchain"
150 #endif
151 
153 #define UDMACC26XX_SET_TRANSFER_SIZE(SIZE) (((SIZE - 1) << UDMA_XFER_SIZE_S) & UDMA_XFER_SIZE_M)
154 
155 #define UDMACC26XX_GET_TRANSFER_SIZE(CONTROL) (((CONTROL & UDMA_XFER_SIZE_M) >> UDMA_XFER_SIZE_S) + 1)
156 
160 typedef struct UDMACC26XX_Object {
161  bool isOpen;
162  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
164 
168 typedef struct UDMACC26XX_HWAttrs {
169  uint32_t baseAddr;
170  Power_Resource powerMngrId;
171  uint8_t intNum;
195  uint8_t intPriority;
197 
201 typedef struct UDMACC26XX_Config {
202  void *object;
203  void const *hwAttrs;
205 
210 
211 /* Extern'd hwiIntFxn */
212 extern void UDMACC26XX_hwiIntFxn(UArg callbacks);
213 
226 __STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
227 {
229 
230  /* Get the pointer to the object */
231  object = handle->object;
232 
233  /* mark the module as available */
234  object->isOpen = FALSE;
235 }
236 
252 extern UDMACC26XX_Handle UDMACC26XX_open();
253 
267 __STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
268 {
270 
271  /* Get the pointer to the hwAttrs */
272  hwAttrs = handle->hwAttrs;
273 
274  /* Enable DMA channel */
275  HWREG(hwAttrs->baseAddr + UDMA_O_SETCHANNELEN) = channelBitMask;
276 }
277 
296 __STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
297 {
299 
300  /* Get the pointer to the hwAttrs */
301  hwAttrs = handle->hwAttrs;
302 
303  /* Check if REQDONE is set for a specific channel */
304  return (uDMAIntStatus(hwAttrs->baseAddr) & channelBitMask) ? true : false;
305 }
306 
324 __STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
325 {
327 
328  /* Get the pointer to the hwAttrs and object */
329  hwAttrs = handle->hwAttrs;
330 
331  /* Clear UDMA done interrupt */
332  uDMAIntClear(hwAttrs->baseAddr, channelBitMask);
333 }
334 
352 __STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
353 {
355 
356  /* Get the pointer to the hwAttrs and object */
357  hwAttrs = handle->hwAttrs;
358 
359  /* disable DMA channel */
360  uDMAChannelDisable(hwAttrs->baseAddr, channelBitMask);
361 }
362 
378 extern void UDMACC26XX_close(UDMACC26XX_Handle handle);
379 
380 #ifdef __cplusplus
381 }
382 #endif
383 
384 #endif /* ti_drivers_UDMACC26XX__include */
bool isOpen
Definition: UDMACC26XX.h:161
void UDMACC26XX_close(UDMACC26XX_Handle handle)
Function to close the DMA driver.
__STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:324
__STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:267
uint8_t intNum
Definition: UDMACC26XX.h:171
__STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
Function to initialize the CC26XX DMA driver.
Definition: UDMACC26XX.h:226
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:201
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UDMACC26XX.h:162
struct UDMACC26XX_Object UDMACC26XX_Object
UDMACC26XX object.
Power_Resource powerMngrId
Definition: UDMACC26XX.h:170
UDMACC26XX_Handle UDMACC26XX_open()
Function to initialize the CC26XX DMA peripheral.
struct UDMACC26XX_Config UDMACC26XX_Config
UDMACC26XX Global configuration.
UDMACC26XX hardware attributes.
Definition: UDMACC26XX.h:168
void * object
Definition: UDMACC26XX.h:202
uint8_t intPriority
UDMACC26XX error interrupt priority. intPriority is the DMA peripheral's interrupt priority...
Definition: UDMACC26XX.h:195
__STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:352
__STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:296
uint32_t baseAddr
Definition: UDMACC26XX.h:169
void UDMACC26XX_hwiIntFxn(UArg callbacks)
UDMACC26XX object.
Definition: UDMACC26XX.h:160
struct UDMACC26XX_Config * UDMACC26XX_Handle
A handle that is returned from a UDMACC26XX_open() call.
Definition: UDMACC26XX.h:209
void const * hwAttrs
Definition: UDMACC26XX.h:203
struct UDMACC26XX_HWAttrs UDMACC26XX_HWAttrs
UDMACC26XX hardware attributes.
Copyright 2015, Texas Instruments Incorporated