UDMALPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-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  */
100 #ifndef ti_drivers_UDMALPF3__include
101 #define ti_drivers_UDMALPF3__include
102 
103 #include <stdint.h>
104 #include <stdbool.h>
105 
106 #include <ti/drivers/Power.h>
107 
108 #include <ti/devices/DeviceFamily.h>
109 #include DeviceFamily_constructPath(inc/hw_types.h)
110 #include DeviceFamily_constructPath(driverlib/udma.h)
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
117 #if !defined(UDMALPF3_CONFIG_BASE)
118  #define UDMALPF3_CONFIG_BASE 0x20000400
119 #endif
120 
122 #if (UDMALPF3_CONFIG_BASE & 0x3FF)
123  #error "Base address for DMA control table 'UDMALPF3_CONFIG_BASE' must be 1024 bytes aligned."
124 #endif
125 
127 #if defined(__IAR_SYSTEMS_ICC__)
128  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
129  __no_init __root static volatile uDMAControlTableEntry ENTRY_NAME @UDMALPF3_CONFIG_BASE + \
130  (CHANNEL_INDEX) * sizeof(uDMAControlTableEntry)
131 #elif defined(__TI_COMPILER_VERSION__) || defined(__clang__)
132  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
133  static volatile uDMAControlTableEntry ENTRY_NAME \
134  __attribute__((retain, \
135  location((UDMALPF3_CONFIG_BASE) + (CHANNEL_INDEX) * sizeof(uDMAControlTableEntry))))
136 #elif defined(__GNUC__)
137  #define ALLOCATE_CONTROL_TABLE_ENTRY(ENTRY_NAME, CHANNEL_INDEX) \
138  extern int UDMALPF3_##ENTRY_NAME##_is_placed; \
139  __attribute__((section("." #ENTRY_NAME), used)) static volatile uDMAControlTableEntry ENTRY_NAME = { \
140  &UDMALPF3_##ENTRY_NAME##_is_placed}
141 #else
142  #error "don't know how to define ALLOCATE_CONTROL_TABLE_ENTRY for this toolchain"
143 #endif
144 
146 #define UDMALPF3_SET_TRANSFER_SIZE(SIZE) (((SIZE - 1) << UDMA_XFER_SIZE_S) & UDMA_XFER_SIZE_M)
147 
148 #define UDMALPF3_GET_TRANSFER_SIZE(CONTROL) (((CONTROL & UDMA_XFER_SIZE_M) >> UDMA_XFER_SIZE_S) + 1)
149 
153 typedef struct
154 {
155  uint32_t CtrlBaseAddr;
157 
158 /* Externs from ti_drivers_config.c */
159 extern const UDMALPF3_Config UDMALPF3_config;
160 
177 extern void UDMALPF3_init(void);
178 
190 __STATIC_INLINE void UDMALPF3_channelEnable(uint32_t channelBitMask)
191 {
192  /* Enable DMA channel */
193  uDMAEnableChannel(channelBitMask);
194 }
195 
212 __STATIC_INLINE bool UDMALPF3_channelDone(uint32_t channelBitMask)
213 {
214  /* Check if REQDONE is set for the specified channels */
215  return (uDMAIntStatus() & channelBitMask) ? true : false;
216 }
217 
230 __STATIC_INLINE void UDMALPF3_clearInterrupt(uint32_t channelBitMask)
231 {
232  /* Clear UDMA done interrupt */
233  uDMAClearInt(channelBitMask);
234 }
235 
250 __STATIC_INLINE void UDMALPF3_channelDisable(uint32_t channelBitMask)
251 {
252  /* Disable provided channels(s) */
253  uDMADisableChannel(channelBitMask);
254 }
255 
273 __STATIC_INLINE void UDMALPF3_disableAttribute(uint32_t channelBitMask, uint32_t attr)
274 {
275  /* disable provided attribute for the given channel */
276  uDMADisableChannelAttribute(channelBitMask, attr);
277 }
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* ti_drivers_UDMALPF3__include */
const UDMALPF3_Config UDMALPF3_config
__STATIC_INLINE bool UDMALPF3_channelDone(uint32_t channelBitMask)
Definition: UDMALPF3.h:212
__STATIC_INLINE void UDMALPF3_channelDisable(uint32_t channelBitMask)
Definition: UDMALPF3.h:250
Power Manager.
__STATIC_INLINE void UDMALPF3_channelEnable(uint32_t channelBitMask)
Definition: UDMALPF3.h:190
UDMALPF3 Global configuration.
Definition: UDMALPF3.h:153
__STATIC_INLINE void UDMALPF3_disableAttribute(uint32_t channelBitMask, uint32_t attr)
Definition: UDMALPF3.h:273
uint32_t CtrlBaseAddr
Definition: UDMALPF3.h:155
void UDMALPF3_init(void)
Function to initialize the LPF3 DMA driver and peripheral.
__STATIC_INLINE void UDMALPF3_clearInterrupt(uint32_t channelBitMask)
Definition: UDMALPF3.h:230
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale