UDMACC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2021, 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  */
102 #ifndef ti_drivers_UDMACC26XX__include
103 #define ti_drivers_UDMACC26XX__include
104 
105 #include <stdint.h>
106 #include <stdbool.h>
107 
108 #include <ti/drivers/Power.h>
110 
111 #include <ti/devices/DeviceFamily.h>
112 #include DeviceFamily_constructPath(inc/hw_types.h)
113 #include DeviceFamily_constructPath(driverlib/udma.h)
114 
115 #ifdef __cplusplus
116 extern "C" {
117 #endif
118 
129 /* Add DMACC26XX_STATUS_* macros here */
130 
143 /* Add DMACC26XX_CMD_* macros here */
144 
148 #if !defined(UDMACC26XX_CONFIG_BASE) && \
149  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
150  /* On CC13X2, CC13X2X7, CC26X2, and CC26X2X7 devices, the uDMA table needs
151  * to be offset a few kB since the ROM area of SRAM is placed at the start
152  * of SRAM on those devices.
153  */
154  #define UDMACC26XX_CONFIG_BASE 0x20001800
155 #elif !defined(UDMACC26XX_CONFIG_BASE) && \
156  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X1_CC26X1 || \
157  DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)
158  /* Since there is no ROM area of SRAM on the CC13X1, CC26X1, CC13X4, and
159  * CC26X4 devices, we can move the uDMA table closer to the start of SRAM.
160  * This improves the linker efficiency when using dynamically sized heaps.
161  */
162  #define UDMACC26XX_CONFIG_BASE 0x20000400
163 #elif !defined(UDMACC26XX_CONFIG_BASE)
164  #define UDMACC26XX_CONFIG_BASE 0x20000400
165 #endif
166 
168 #if(UDMACC26XX_CONFIG_BASE & 0x3FF)
169  #error "Base address for DMA control table 'UDMACC26XX_CONFIG_BASE' must be 1024 bytes aligned."
170 #endif
171 
173 #if defined(__IAR_SYSTEMS_ICC__)
174 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
175 __no_init static volatile tDMAControlTable ENTRY_NAME @ UDMACC26XX_CONFIG_BASE + CHANNEL_INDEX * sizeof(tDMAControlTable)
176 #elif defined(__TI_COMPILER_VERSION__) || defined(__clang__)
177 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
178 static volatile tDMAControlTable ENTRY_NAME __attribute__((retain, location(\
179  UDMACC26XX_CONFIG_BASE + CHANNEL_INDEX * sizeof(tDMAControlTable))))
180 #elif defined(__GNUC__)
181 #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
182  extern int UDMACC26XX_ ## ENTRY_NAME ## _is_placed; __attribute__ ((section("."#ENTRY_NAME))) static volatile tDMAControlTable ENTRY_NAME = {&UDMACC26XX_ ## ENTRY_NAME ## _is_placed}
183 #else
184 #error "don't know how to define ALLOCATE_CONTROL_TABLE_ENTRY for this toolchain"
185 #endif
186 
188 #define UDMACC26XX_SET_TRANSFER_SIZE(SIZE) (((SIZE - 1) << UDMA_XFER_SIZE_S) & UDMA_XFER_SIZE_M)
189 
190 #define UDMACC26XX_GET_TRANSFER_SIZE(CONTROL) (((CONTROL & UDMA_XFER_SIZE_M) >> UDMA_XFER_SIZE_S) + 1)
191 
195 typedef struct {
196  bool isOpen;
197  HwiP_Struct hwi;
199 
203 typedef struct {
204  uint32_t baseAddr;
205  PowerCC26XX_Resource powerMngrId;
206  uint8_t intNum;
228  uint8_t intPriority;
230 
234 typedef struct {
235  void *object;
236  void const *hwAttrs;
238 
243 
244 /* Extern'd hwiIntFxn */
245 extern void UDMACC26XX_hwiIntFxn(uintptr_t callbacks);
246 
259 __STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
260 {
261  UDMACC26XX_Object *object;
262 
263  /* Get the pointer to the object */
264  object = (UDMACC26XX_Object *)(handle->object);
265 
266  /* mark the module as available */
267  object->isOpen = false;
268 }
269 
285 extern UDMACC26XX_Handle UDMACC26XX_open();
286 
300 __STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
301 {
302  UDMACC26XX_HWAttrs const *hwAttrs;
303 
304  /* Get the pointer to the hwAttrs */
305  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
306 
307  /* Enable DMA channel */
308  HWREG(hwAttrs->baseAddr + UDMA_O_SETCHANNELEN) = channelBitMask;
309 }
310 
329 __STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
330 {
331  UDMACC26XX_HWAttrs const *hwAttrs;
332 
333  /* Get the pointer to the hwAttrs */
334  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
335 
336  /* Check if REQDONE is set for a specific channel */
337  return (uDMAIntStatus(hwAttrs->baseAddr) & channelBitMask) ? true : false;
338 }
339 
357 __STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
358 {
359  UDMACC26XX_HWAttrs const *hwAttrs;
360 
361  /* Get the pointer to the hwAttrs and object */
362  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
363 
364  /* Clear UDMA done interrupt */
365  uDMAIntClear(hwAttrs->baseAddr, channelBitMask);
366 }
367 
385 __STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
386 {
387  UDMACC26XX_HWAttrs const *hwAttrs;
388 
389  /* Get the pointer to the hwAttrs */
390  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
391 
392  HWREG(hwAttrs->baseAddr + UDMA_O_CLEARCHANNELEN) = channelBitMask;
393 }
394 
415 __STATIC_INLINE void UDMACC26XX_disableAttribute(UDMACC26XX_Handle handle,
416  uint32_t channelNum, uint32_t attr)
417 {
418  UDMACC26XX_HWAttrs const *hwAttrs;
419 
420  /* Get the pointer to the hwAttrs */
421  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
422 
423  uDMAChannelAttributeDisable(hwAttrs->baseAddr, channelNum, attr);
424 }
425 
441 extern void UDMACC26XX_close(UDMACC26XX_Handle handle);
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 #endif /* ti_drivers_UDMACC26XX__include */
bool isOpen
Definition: UDMACC26XX.h:196
HwiP_Struct hwi
Definition: UDMACC26XX.h:197
void UDMACC26XX_hwiIntFxn(uintptr_t callbacks)
PowerCC26XX_Resource powerMngrId
Definition: UDMACC26XX.h:205
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:357
Power Manager.
__STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:300
uint8_t intNum
Definition: UDMACC26XX.h:206
__STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
Function to initialize the CC26XX DMA driver.
Definition: UDMACC26XX.h:259
__STATIC_INLINE void UDMACC26XX_disableAttribute(UDMACC26XX_Handle handle, uint32_t channelNum, uint32_t attr)
Definition: UDMACC26XX.h:415
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:234
Power manager interface for CC26XX/CC13XX.
UDMACC26XX_Handle UDMACC26XX_open()
Function to initialize the CC26XX DMA peripheral.
UDMACC26XX hardware attributes.
Definition: UDMACC26XX.h:203
void * object
Definition: UDMACC26XX.h:235
uint8_t intPriority
UDMACC26XX error interrupt priority. intPriority is the DMA peripheral&#39;s interrupt priority...
Definition: UDMACC26XX.h:228
__STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:385
__STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:329
uint32_t baseAddr
Definition: UDMACC26XX.h:204
UDMACC26XX object.
Definition: UDMACC26XX.h:195
UDMACC26XX_Config * UDMACC26XX_Handle
A handle that is returned from a UDMACC26XX_open() call.
Definition: UDMACC26XX.h:242
void const * hwAttrs
Definition: UDMACC26XX.h:236
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale