TI-RTOS for SimpleLink Wireless MCUs  2.14.02.22
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 #endif
141 #if defined(__TI_COMPILER_VERSION__)
142 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
143 PRAGMA(LOCATION( ENTRY_NAME , UDMACC26XX_CONFIG_BASE + CHANNEL_INDEX * sizeof(tDMAControlTable) );)\
144 static volatile tDMAControlTable ENTRY_NAME
145 #define PRAGMA(x) _Pragma(#x)
146 #endif
147 
149 #define UDMACC26XX_SET_TRANSFER_SIZE(SIZE) (((SIZE - 1) << UDMA_XFER_SIZE_S) & UDMA_XFER_SIZE_M)
150 
151 #define UDMACC26XX_GET_TRANSFER_SIZE(CONTROL) (((CONTROL & UDMA_XFER_SIZE_M) >> UDMA_XFER_SIZE_S) + 1)
152 
156 typedef struct UDMACC26XX_Object {
157  bool isOpen;
158  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
160 
164 typedef struct UDMACC26XX_HWAttrs {
165  uint32_t baseAddr;
166  Power_Resource powerMngrId;
167  uint8_t intNum;
175  uint8_t intPriority;
177 
181 typedef struct UDMACC26XX_Config {
182  void *object;
183  void const *hwAttrs;
185 
190 
191 /* Extern'd hwiIntFxn */
192 extern void UDMACC26XX_hwiIntFxn(UArg callbacks);
193 
206 __STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
207 {
209 
210  /* Get the pointer to the object */
211  object = handle->object;
212 
213  /* mark the module as available */
214  object->isOpen = FALSE;
215 }
216 
232 extern UDMACC26XX_Handle UDMACC26XX_open();
233 
247 __STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
248 {
250 
251  /* Get the pointer to the hwAttrs */
252  hwAttrs = handle->hwAttrs;
253 
254  /* Enable DMA channel */
255  HWREG(hwAttrs->baseAddr + UDMA_O_SETCHANNELEN) = channelBitMask;
256 }
257 
276 __STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
277 {
279 
280  /* Get the pointer to the hwAttrs */
281  hwAttrs = handle->hwAttrs;
282 
283  /* Check if REQDONE is set for a specific channel */
284  return (uDMAIntStatus(hwAttrs->baseAddr) & channelBitMask) ? true : false;
285 }
286 
304 __STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
305 {
307 
308  /* Get the pointer to the hwAttrs and object */
309  hwAttrs = handle->hwAttrs;
310 
311  /* Clear UDMA done interrupt */
312  uDMAIntClear(hwAttrs->baseAddr, channelBitMask);
313 }
314 
332 __STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
333 {
335 
336  /* Get the pointer to the hwAttrs and object */
337  hwAttrs = handle->hwAttrs;
338 
339  /* disable DMA channel */
340  uDMAChannelDisable(hwAttrs->baseAddr, channelBitMask);
341 }
342 
358 extern void UDMACC26XX_close(UDMACC26XX_Handle handle);
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 
364 #endif /* ti_drivers_UDMACC26XX__include */
bool isOpen
Definition: UDMACC26XX.h:157
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:304
__STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:247
uint8_t intNum
Definition: UDMACC26XX.h:167
__STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
Function to initialize the CC26XX DMA driver.
Definition: UDMACC26XX.h:206
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:181
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: UDMACC26XX.h:158
struct UDMACC26XX_Object UDMACC26XX_Object
UDMACC26XX object.
Power_Resource powerMngrId
Definition: UDMACC26XX.h:166
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:164
void * object
Definition: UDMACC26XX.h:182
uint8_t intPriority
UDMACC26XX error interrupt priority.
Definition: UDMACC26XX.h:175
__STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:332
__STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:276
uint32_t baseAddr
Definition: UDMACC26XX.h:165
void UDMACC26XX_hwiIntFxn(UArg callbacks)
UDMACC26XX object.
Definition: UDMACC26XX.h:156
struct UDMACC26XX_Config * UDMACC26XX_Handle
A handle that is returned from a UDMACC26XX_open() call.
Definition: UDMACC26XX.h:189
void const * hwAttrs
Definition: UDMACC26XX.h:183
struct UDMACC26XX_HWAttrs UDMACC26XX_HWAttrs
UDMACC26XX hardware attributes.
Copyright 2015, Texas Instruments Incorporated