UDMACC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2023, 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  */
104 #ifndef ti_drivers_UDMACC26XX__include
105 #define ti_drivers_UDMACC26XX__include
106 
107 #include <stdint.h>
108 #include <stdbool.h>
109 
110 #include <ti/drivers/Power.h>
112 
113 #include <ti/devices/DeviceFamily.h>
114 #include DeviceFamily_constructPath(inc/hw_types.h)
115 #include DeviceFamily_constructPath(driverlib/udma.h)
116 
117 #ifdef __cplusplus
118 extern "C" {
119 #endif
120 
131 /* Add DMACC26XX_STATUS_* macros here */
132 
145 /* Add DMACC26XX_CMD_* macros here */
146 
150 #if !defined(UDMACC26XX_CONFIG_BASE)
151  #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
152  /* On CC13X2, CC13X2X7, CC26X2, and CC26X2X7 devices, the uDMA table needs
153  * to be offset a few kB since the ROM area of SRAM is placed at the start
154  * of SRAM on those devices.
155  */
156  #define UDMACC26XX_CONFIG_BASE 0x20001800
157  #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X1_CC26X1)
158  /*
159  * Since there is no ROM area of SRAM on the CC13X1 and CC26X1 devices, we
160  * can move the uDMA table closer to the start of SRAM. This improves the
161  * linker efficiency when using dynamically sized heaps.
162  */
163  #define UDMACC26XX_CONFIG_BASE 0x20000400
164  #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)
165  /*
166  * Since there is no ROM area of SRAM on the CC13X4 and CC26X4 devices, we
167  * can move the uDMA table closer to the start of SRAM. This improves the
168  * linker efficiency when using dynamically sized heaps.
169  */
170  #if (TFM_ENABLED == 0)
171  #define UDMACC26XX_CONFIG_BASE 0x20000400
172  #else
173  #define UDMACC26XX_CONFIG_BASE 0x2000C400
174  #endif
175  #else
176  #define UDMACC26XX_CONFIG_BASE 0x20000400
177  #endif
178 #endif
179 
181 #if (UDMACC26XX_CONFIG_BASE & 0x3FF)
182  #error "Base address for DMA control table 'UDMACC26XX_CONFIG_BASE' must be 1024 bytes aligned."
183 #endif
184 
186 #if defined(__IAR_SYSTEMS_ICC__)
187  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
188  __no_init __root static volatile tDMAControlTable ENTRY_NAME @UDMACC26XX_CONFIG_BASE + \
189  (CHANNEL_INDEX) * sizeof(tDMAControlTable)
190 #elif defined(__TI_COMPILER_VERSION__) || defined(__clang__)
191  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
192  static volatile tDMAControlTable ENTRY_NAME \
193  __attribute__((retain, location((UDMACC26XX_CONFIG_BASE) + (CHANNEL_INDEX) * sizeof(tDMAControlTable))))
194 #elif defined(__GNUC__)
195  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
196  extern int UDMACC26XX_##ENTRY_NAME##_is_placed; \
197  __attribute__((section("." #ENTRY_NAME), used)) static volatile tDMAControlTable ENTRY_NAME = { \
198  &UDMACC26XX_##ENTRY_NAME##_is_placed}
199 #else
200  #error "don't know how to define ALLOCATE_CONTROL_TABLE_ENTRY for this toolchain"
201 #endif
202 
204 #define UDMACC26XX_SET_TRANSFER_SIZE(SIZE) (((SIZE - 1) << UDMA_XFER_SIZE_S) & UDMA_XFER_SIZE_M)
205 
206 #define UDMACC26XX_GET_TRANSFER_SIZE(CONTROL) (((CONTROL & UDMA_XFER_SIZE_M) >> UDMA_XFER_SIZE_S) + 1)
207 
211 typedef struct
212 {
213  bool isOpen;
214  HwiP_Struct hwi;
216 
220 typedef struct
221 {
222  uint32_t baseAddr;
223  PowerCC26XX_Resource powerMngrId;
224  uint8_t intNum;
247  uint8_t intPriority;
249 
253 typedef struct
254 {
255  void *object;
256  void const *hwAttrs;
258 
263 
264 /* Extern'd hwiIntFxn */
265 extern void UDMACC26XX_hwiIntFxn(uintptr_t callbacks);
266 
279 __STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
280 {
281  UDMACC26XX_Object *object;
282 
283  /* Get the pointer to the object */
284  object = (UDMACC26XX_Object *)(handle->object);
285 
286  /* mark the module as available */
287  object->isOpen = false;
288 }
289 
305 extern UDMACC26XX_Handle UDMACC26XX_open(void);
306 
320 __STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
321 {
322  UDMACC26XX_HWAttrs const *hwAttrs;
323 
324  /* Get the pointer to the hwAttrs */
325  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
326 
327  /* Enable DMA channel */
328  HWREG(hwAttrs->baseAddr + UDMA_O_SETCHANNELEN) = channelBitMask;
329 }
330 
349 __STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
350 {
351  UDMACC26XX_HWAttrs const *hwAttrs;
352 
353  /* Get the pointer to the hwAttrs */
354  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
355 
356  /* Check if REQDONE is set for a specific channel */
357  return (uDMAIntStatus(hwAttrs->baseAddr) & channelBitMask) ? true : false;
358 }
359 
377 __STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
378 {
379  UDMACC26XX_HWAttrs const *hwAttrs;
380 
381  /* Get the pointer to the hwAttrs and object */
382  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
383 
384  /* Clear UDMA done interrupt */
385  uDMAIntClear(hwAttrs->baseAddr, channelBitMask);
386 }
387 
405 __STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
406 {
407  UDMACC26XX_HWAttrs const *hwAttrs;
408 
409  /* Get the pointer to the hwAttrs */
410  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
411 
412  HWREG(hwAttrs->baseAddr + UDMA_O_CLEARCHANNELEN) = channelBitMask;
413 }
414 
435 __STATIC_INLINE void UDMACC26XX_disableAttribute(UDMACC26XX_Handle handle, uint32_t channelNum, uint32_t attr)
436 {
437  UDMACC26XX_HWAttrs const *hwAttrs;
438 
439  /* Get the pointer to the hwAttrs */
440  hwAttrs = (UDMACC26XX_HWAttrs *)(handle->hwAttrs);
441 
442  uDMAChannelAttributeDisable(hwAttrs->baseAddr, channelNum, attr);
443 }
444 
460 extern void UDMACC26XX_close(UDMACC26XX_Handle handle);
461 
462 #ifdef __cplusplus
463 }
464 #endif
465 
466 #endif /* ti_drivers_UDMACC26XX__include */
bool isOpen
Definition: UDMACC26XX.h:213
HwiP_Struct hwi
Definition: UDMACC26XX.h:214
void UDMACC26XX_hwiIntFxn(uintptr_t callbacks)
PowerCC26XX_Resource powerMngrId
Definition: UDMACC26XX.h:223
void UDMACC26XX_close(UDMACC26XX_Handle handle)
Function to close the DMA driver.
UDMACC26XX_Handle UDMACC26XX_open(void)
Function to initialize the CC26XX DMA peripheral.
__STATIC_INLINE void UDMACC26XX_clearInterrupt(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:377
Power Manager.
__STATIC_INLINE void UDMACC26XX_channelEnable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:320
uint8_t intNum
Definition: UDMACC26XX.h:224
__STATIC_INLINE void UDMACC26XX_init(UDMACC26XX_Handle handle)
Function to initialize the CC26XX DMA driver.
Definition: UDMACC26XX.h:279
__STATIC_INLINE void UDMACC26XX_disableAttribute(UDMACC26XX_Handle handle, uint32_t channelNum, uint32_t attr)
Definition: UDMACC26XX.h:435
UDMACC26XX Global configuration.
Definition: UDMACC26XX.h:253
Power manager interface for CC26XX/CC13XX.
UDMACC26XX hardware attributes.
Definition: UDMACC26XX.h:220
void * object
Definition: UDMACC26XX.h:255
uint8_t intPriority
UDMACC26XX error interrupt priority. intPriority is the DMA peripheral&#39;s interrupt priority...
Definition: UDMACC26XX.h:247
__STATIC_INLINE void UDMACC26XX_channelDisable(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:405
__STATIC_INLINE bool UDMACC26XX_channelDone(UDMACC26XX_Handle handle, uint32_t channelBitMask)
Definition: UDMACC26XX.h:349
uint32_t baseAddr
Definition: UDMACC26XX.h:222
UDMACC26XX object.
Definition: UDMACC26XX.h:211
UDMACC26XX_Config * UDMACC26XX_Handle
A handle that is returned from a UDMACC26XX_open() call.
Definition: UDMACC26XX.h:262
void const * hwAttrs
Definition: UDMACC26XX.h:256
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale