60 #include "../inc/hw_types.h" 61 #include "../inc/hw_ints.h" 62 #include "../inc/hw_memmap.h" 63 #include "../inc/hw_dma.h" 151 #define uDMATaskStructEntry(transferCount, itemSize, srcIncrement, pSrcAddr, dstIncrement, pDstAddr, arbSize, mode) \ 153 (((srcIncrement) == UDMA_SRC_INC_NONE) \ 155 : ((void *)(&((uint8_t *)(pSrcAddr))[((transferCount) << ((srcIncrement) >> 26)) - 1]))), \ 156 (((dstIncrement) == UDMA_DST_INC_NONE) \ 158 : ((void *)(&((uint8_t *)(pDstAddr))[((transferCount) << ((dstIncrement) >> 30)) - 1]))), \ 159 (srcIncrement) | (dstIncrement) | (itemSize) | (arbSize) | (((transferCount)-1) << 4) | \ 160 ((((mode) == UDMA_MODE_MEM_SCATTER_GATHER) || ((mode) == UDMA_MODE_PER_SCATTER_GATHER)) \ 161 ? (mode) | UDMA_MODE_ALT_SELECT \ 171 #define UDMA_NUM_CHANNELS 8 178 #define UDMA_PRIORITY_LOW 0x00000000 179 #define UDMA_PRIORITY_HIGH 0x00000001 187 #define UDMA_ATTR_USEBURST 0x00000001 188 #define UDMA_ATTR_ALTSELECT 0x00000002 189 #define UDMA_ATTR_HIGH_PRIORITY 0x00000004 190 #define UDMA_ATTR_REQMASK 0x00000008 191 #define UDMA_ATTR_ALL 0x0000000F 199 #define UDMA_MODE_STOP 0x00000000 200 #define UDMA_MODE_BASIC 0x00000001 201 #define UDMA_MODE_AUTO 0x00000002 202 #define UDMA_MODE_PINGPONG 0x00000003 203 #define UDMA_MODE_MEM_SCATTER_GATHER 0x00000004 204 #define UDMA_MODE_PER_SCATTER_GATHER 0x00000006 205 #define UDMA_MODE_M 0x00000007 // uDMA Transfer Mode 206 #define UDMA_MODE_ALT_SELECT 0x00000001 213 #define UDMA_DST_INC_8 0x00000000 214 #define UDMA_DST_INC_16 0x40000000 215 #define UDMA_DST_INC_32 0x80000000 216 #define UDMA_DST_INC_NONE 0xC0000000 217 #define UDMA_DST_INC_M 0xC0000000 // Destination Address Increment 218 #define UDMA_DST_INC_S 30 219 #define UDMA_SRC_INC_8 0x00000000 220 #define UDMA_SRC_INC_16 0x04000000 221 #define UDMA_SRC_INC_32 0x08000000 222 #define UDMA_SRC_INC_NONE 0x0c000000 223 #define UDMA_SRC_INC_M 0x0C000000 // Source Address Increment 224 #define UDMA_SRC_INC_S 26 225 #define UDMA_SIZE_8 0x00000000 226 #define UDMA_SIZE_16 0x11000000 227 #define UDMA_SIZE_32 0x22000000 228 #define UDMA_SIZE_M 0x33000000 // Data Size 229 #define UDMA_SIZE_S 24 230 #define UDMA_ARB_1 0x00000000 231 #define UDMA_ARB_2 0x00004000 232 #define UDMA_ARB_4 0x00008000 233 #define UDMA_ARB_8 0x0000c000 234 #define UDMA_ARB_16 0x00010000 235 #define UDMA_ARB_32 0x00014000 236 #define UDMA_ARB_64 0x00018000 237 #define UDMA_ARB_128 0x0001c000 238 #define UDMA_ARB_256 0x00020000 239 #define UDMA_ARB_512 0x00024000 240 #define UDMA_ARB_1024 0x00028000 241 #define UDMA_ARB_M 0x0003C000 // Arbitration Size 242 #define UDMA_ARB_S 14 243 #define UDMA_NEXT_USEBURST 0x00000008 244 #define UDMA_XFER_SIZE_MAX 1024 245 #define UDMA_XFER_SIZE_M 0x00003FF0 // Transfer size 246 #define UDMA_XFER_SIZE_S 4 258 #define UDMA_CHANNEL_0_M 0x01 259 #define UDMA_CHANNEL_1_M 0x02 260 #define UDMA_CHANNEL_2_M 0x04 261 #define UDMA_CHANNEL_3_M 0x08 262 #define UDMA_CHANNEL_4_M 0x10 263 #define UDMA_CHANNEL_5_M 0x20 264 #define UDMA_CHANNEL_6_M 0x40 265 #define UDMA_CHANNEL_7_M 0x80 273 #define UDMA_PRI_SELECT 0x00000000 274 #define UDMA_ALT_SELECT 0x00000008 295 HWREG(DMA_BASE + DMA_O_CFG) = DMA_CFG_MASTERENABLE;
311 HWREG(DMA_BASE + DMA_O_CFG) = 0;
328 return (HWREG(DMA_BASE + DMA_O_ERROR));
344 HWREG(DMA_BASE + DMA_O_ERROR) = DMA_ERROR_STATUS;
366 HWREG(DMA_BASE + DMA_O_SETCHANNELEN) = channelBitMask;
384 HWREG(DMA_BASE + DMA_O_CLEARCHANNELEN) = channelBitMask;
406 return ((HWREG(DMA_BASE + DMA_O_SETCHANNELEN) & (channelBitMask)) ?
true :
false);
439 ASSERT(((uint32_t)pControlTable & ~0x3FF) == (uint32_t)pControlTable);
440 ASSERT((uint32_t)pControlTable >= SRAM_BASE);
443 HWREG(DMA_BASE + DMA_O_CTRL) = (uint32_t)pControlTable;
461 return ((
void *)HWREG(DMA_BASE + DMA_O_CTRL));
479 return ((
void *)HWREG(DMA_BASE + DMA_O_ALTCTRL));
505 HWREG(DMA_BASE + DMA_O_SOFTREQ) = channelBitMask;
674 uint32_t transferSize);
746 ASSERT(intChannel == INT_DMA_DONE_COMB);
775 ASSERT(intChannel == INT_DMA_DONE_COMB);
801 HWREG(DMA_BASE + DMA_O_REQDONE) = channelBitMask;
818 return (HWREG(DMA_BASE + DMA_O_REQDONE));
844 HWREG(DMA_BASE + DMA_O_DONEMASK) |= intChannel;
868 HWREG(DMA_BASE + DMA_O_DONEMASK) &= ~intChannel;
883 return HWREG(DMA_BASE + DMA_O_STATUS);
901 HWREG(DMA_BASE + DMA_O_SETCHNLPRIORITY) = channelBitMask;
936 HWREG(DMA_BASE + DMA_O_CLEARCHNLPRIORITY) = channelBitMask;
void uDMASetChannelControl(volatile uDMAControlTableEntry *pChannelControlStruct, uint32_t control)
Sets the control parameters for a uDMA channel control structure.
Definition: udma.c:152
#define UDMA_NUM_CHANNELS
Definition: udma.h:171
void IntEnable(uint32_t intNum)
Enables an interrupt or system exception.
Definition: interrupt.c:248
__STATIC_INLINE void uDMAEnable(void)
Enables the uDMA controller for use.
Definition: udma.h:292
volatile uint32_t control
The channel control mode.
Definition: udma.h:79
__STATIC_INLINE void uDMAClearErrorStatus(void)
Clears the uDMA error interrupt.
Definition: udma.h:341
__STATIC_INLINE uint32_t uDMAGetErrorStatus(void)
Gets the uDMA error status.
Definition: udma.h:325
#define UDMA_PRIORITY_LOW
Definition: udma.h:178
__STATIC_INLINE void * uDMAGetControlBase(void)
Gets the base address for the channel control table.
Definition: udma.h:457
__STATIC_INLINE void uDMASetControlBase(void *pControlTable)
Sets the base address for the channel control table.
Definition: udma.h:436
volatile void * pDstEndAddr
The ending destination address of the data transfer.
Definition: udma.h:78
__STATIC_INLINE void uDMADisable(void)
Disables the uDMA controller for use.
Definition: udma.h:308
__STATIC_INLINE void uDMAEnableChannel(uint32_t channelBitMask)
Enables a uDMA channel for operation.
Definition: udma.h:364
__STATIC_INLINE void uDMAClearChannelPriority(uint32_t channelBitMask)
Clear the priority of a uDMA channel.
Definition: udma.h:933
__STATIC_INLINE bool uDMAGetChannelPriority(uint32_t channelBitMask)
Get the priority of a uDMA channel.
Definition: udma.h:915
volatile uint32_t spare
An unused location.
Definition: udma.h:80
__STATIC_INLINE void * uDMAGetControlAlternateBase(void)
Gets the base address for the channel control table alternate structures.
Definition: udma.h:475
__STATIC_INLINE void uDMARegisterInt(uint32_t intChannel, void(*pfnHandler)(void))
Registers an interrupt handler for the uDMA controller in the dynamic interrupt table.
Definition: udma.h:742
uint32_t uDMAGetChannelSize(volatile uDMAControlTableEntry const *pChannelControlStruct)
Gets the current transfer size for a uDMA channel control structure.
Definition: udma.c:275
__STATIC_INLINE void uDMAUnregisterInt(uint32_t intChannel)
Unregisters an interrupt handler for the uDMA controller in the dynamic interrupt table...
Definition: udma.h:772
__STATIC_INLINE void uDMADisableSwEventInt(uint32_t intChannel)
Disable interrupt on software event driven uDMA transfers.
Definition: udma.h:862
__STATIC_INLINE void uDMARequestChannel(uint32_t channelBitMask)
Requests a uDMA channel to start a transfer.
Definition: udma.h:502
__STATIC_INLINE void uDMAEnableSwEventInt(uint32_t intChannel)
Enable interrupt on software event driven uDMA transfers.
Definition: udma.h:838
#define ASSERT(expr)
Definition: debug.h:71
void uDMADisableChannelAttribute(uint32_t channelBitMask, uint32_t attr)
Disables attributes of an uDMA channel.
Definition: udma.c:79
__STATIC_INLINE void uDMADisableChannel(uint32_t channelBitMask)
Disables a uDMA channel for operation.
Definition: udma.h:382
uint32_t uDMAGetChannelMode(volatile uDMAControlTableEntry const *pChannelControlStruct)
Gets the transfer mode for a uDMA channel control structure.
Definition: udma.c:307
A structure that defines an entry in the channel control table.
Definition: udma.h:75
__STATIC_INLINE uint32_t uDMAGetStatus(void)
Return the status of the uDMA module.
Definition: udma.h:880
void IntUnregister(uint32_t intNum)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:124
__STATIC_INLINE bool uDMAIsChannelEnabled(uint32_t channelBitMask)
Checks if a uDMA channel is enabled for operation.
Definition: udma.h:404
void IntRegister(uint32_t intNum, void(*handler)(void))
Registers a function as an interrupt handler in the dynamic vector table.
__STATIC_INLINE uint32_t uDMAIntStatus(void)
Get the uDMA interrupt status.
Definition: udma.h:815
void uDMASetChannelTransfer(volatile uDMAControlTableEntry *pChannelControlStruct, uint32_t mode, void *pSrcAddr, void *pDstAddr, uint32_t transferSize)
Sets the transfer parameters for a uDMA channel control structure.
Definition: udma.c:170
__STATIC_INLINE void uDMAClearInt(uint32_t channelBitMask)
Clears uDMA interrupt done status.
Definition: udma.h:798
uint32_t uDMAGetChannelAttribute(uint32_t channelBitMask)
Gets the enabled attributes of a uDMA channel.
Definition: udma.c:115
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
volatile void * pSrcEndAddr
The ending source address of the data transfer.
Definition: udma.h:77
void IntDisable(uint32_t intNum)
Disables an interrupt or system exception.
Definition: interrupt.c:271
void uDMAEnableChannelAttribute(uint32_t channelBitMask, uint32_t attr)
Enables attributes of a uDMA channel.
Definition: udma.c:43
#define UDMA_PRIORITY_HIGH
Definition: udma.h:179
__STATIC_INLINE void uDMASetChannelPriority(uint32_t channelBitMask)
Set the priority of a uDMA channel.
Definition: udma.h:898