The MCUXpresso SDK provides a driver for the GDMA.
GDMA driver provides two types of APIs:
The first type is functional APIs, or the basic channel operation APIs. Such as GDMA_SetChannelSourceAddress, GDMA_StartChannel. Generally, functional APIs use the GDMA_Type *base as parameter. They are simple basic function blocks and does not handle the interrupts. Application should implement the ISR if only functional APIs used.
The second type is transactional APIs. Such as GDMA_SubmitTransfer. Generally these APIs uses the parameter gdma_handle_t. Transactional APIs handles the interrupts, user could get the interrupt status by registering callback.
The functional APIs and transactional APIs are very similar to each other, please refer the driver examples.
|
#define | GDMA_DESC_LLI(linkListAddr, stopAfterDescFinished, enableDescInterrupt) |
| Macro for GDMA link list descriptor LLI. More...
|
|
|
typedef void(* | gdma_callback_t )(struct _gdma_handle *handle, void *userData, uint32_t interrupts) |
| Define Callback function for GDMA. More...
|
|
|
enum | gdma_transfer_width_t {
kGDMA_TransferWidth1Byte = 1U,
kGDMA_TransferWidth2Byte = 2U,
kGDMA_TransferWidth4Byte = 3U
} |
| GDMA transfer width. More...
|
|
enum | gdma_burst_size_t {
kGDMA_BurstSize1 = 0U,
kGDMA_BurstSize4 = 1U,
kGDMA_BurstSize8 = 2U,
kGDMA_BurstSize16 = 3U,
kGDMA_BurstSizeWrap4 = 5U,
kGDMA_BurstSizeWrap8 = 6U,
kGDMA_BurstSizeWrap16 = 7U
} |
| GDMA burst size. More...
|
|
enum | _gdma_ahb_prot {
kGDMA_ProtUserMode = (0U << 0U),
kGDMA_ProtPrevilegedMode = (1U << 0U),
kGDMA_ProtUnbufferable = (0U << 1U),
kGDMA_ProtBufferable = (1U << 1U),
kGDMA_ProtUncacheable = (0U << 2U),
kGDMA_ProtCacheable = (1U << 2U)
} |
| GDMA AHB HPROT flags. More...
|
|
enum | gdma_priority_t {
kGDMA_ChannelPriority0 = 0,
kGDMA_ChannelPriority1,
kGDMA_ChannelPriority2,
kGDMA_ChannelPriority3,
kGDMA_ChannelPriority4,
kGDMA_ChannelPriority5,
kGDMA_ChannelPriority6,
kGDMA_ChannelPriority7,
kGDMA_ChannelPriority8,
kGDMA_ChannelPriority9,
kGDMA_ChannelPriority10,
kGDMA_ChannelPriority11,
kGDMA_ChannelPriority12,
kGDMA_ChannelPriority13,
kGDMA_ChannelPriority14,
kGDMA_ChannelPriority15
} |
| GDMA channel priority. More...
|
|
enum | _gdma_interrupt_enable {
kGDMA_DescriptorTransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_DESC_TFRINT_MASK,
kGDMA_AddressErrorInterruptEnable = GDMA_CHNL_INT_MASK_ADDRERRINT_MASK,
kGDMA_BusErrorInterruptEnable = GDMA_CHNL_INT_MASK_BUSERRINT_MASK,
kGDMA_TransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_TFRINT_MASK,
kGDMA_BlockTransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_BLOCKINT_MASK,
kGDMA_AllInterruptEnable
} |
| GDMA interrupts to enable. More...
|
|
enum | _gdma_interrupt_flags {
kGDMA_DescriptorTransferDoneFlag = GDMA_CHNL_INT_DESC_STATUS_TFRINT_MASK,
kGDMA_ChannelInterruptFlag = GDMA_CHNL_INT_STATUS_CHLINT_MASK,
kGDMA_AddressErrorFlag = GDMA_CHNL_INT_STATUS_ADDRERRINT_MASK,
kGDMA_BusErrorFlag = GDMA_CHNL_INT_STATUS_BUSERRINT_MASK,
kGDMA_TransferDoneFlag = GDMA_CHNL_INT_STATUS_TFRINT_MASK,
kGDMA_BlockTransferDoneFlag = GDMA_CHNL_INT_STATUS_BLOCKINT_MASK,
kGDMA_AllInterruptFlag
} |
| GDMA interrupt status flags. More...
|
|
|
struct | __ALIGNED (16) _gdma_descriptor |
| GDMA channel link list descriptor structure. More...
|
|
|
static void | GDMA_SetChannelSourceAddress (GDMA_Type *base, uint8_t channel, uint32_t addr) |
| Set GDMA channel source address. More...
|
|
static void | GDMA_SetChannelDestAddress (GDMA_Type *base, uint8_t channel, uint32_t addr) |
| Set GDMA channel destination address. More...
|
|
static void | GDMA_StartChannel (GDMA_Type *base, uint8_t channel) |
| Start GDMA channel to work. More...
|
|
static void | GDMA_StopChannel (GDMA_Type *base, uint8_t channel) |
| Stop GDMA channel. More...
|
|
static bool | GDMA_IsChannelBusy (GDMA_Type *base, uint8_t channel) |
| Return whether GDMA channel is processing transfer. More...
|
|
static void | GDMA_EnableChannelInterrupts (GDMA_Type *base, uint8_t channel, uint32_t interrupts) |
| Enables the interrupt for the GDMA transfer. More...
|
|
static void | GDMA_DisableChannelInterrupts (GDMA_Type *base, uint8_t channel, uint32_t interrupts) |
| Disables the interrupt for the GDMA transfer. More...
|
|
static uint32_t | GDMA_GetChannelInterruptFlags (GDMA_Type *base, uint8_t channel) |
| Get the GDMA channel interrupt flags. More...
|
|
static void | GDMA_ClearChannelInterruptFlags (GDMA_Type *base, uint8_t channel, uint32_t flags) |
| Clear the GDMA channel interrupt flags. More...
|
|
static uint32_t | GDMA_GetChannelFinishedDescriptorNumber (GDMA_Type *base, uint8_t channel) |
| Get the number of finished descriptor. More...
|
|
static void | GDMA_ClearChannelFinishedDescriptorNumber (GDMA_Type *base, uint8_t channel) |
| Clear the number of finished descriptor. More...
|
|
static void | GDMA_SetChannelPriority (GDMA_Type *base, uint8_t channel, gdma_priority_t priority) |
| Set priority of channel. More...
|
|
status_t | GDMA_SetChannelTransferConfig (GDMA_Type *base, uint8_t channel, const gdma_channel_xfer_config_t *config) |
| Set channel transfer configuration. More...
|
|
struct gdma_channel_xfer_config_t |
- Note
- The transfer configuration must follow the requirements:
- SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
- If wrap not used, the address should align with WIDTH
- If wrap used, the address should align with WIDTH * BURST_SIZE.
uint8_t gdma_channel_xfer_config_t::ahbProt |
bool gdma_channel_xfer_config_t::srcAddrInc |
bool gdma_channel_xfer_config_t::destAddrInc |
uint16_t gdma_channel_xfer_config_t::transferLen |
bool gdma_channel_xfer_config_t::enableLinkList |
bool gdma_channel_xfer_config_t::enableDescInterrupt |
bool gdma_channel_xfer_config_t::stopAfterDescFinished |
uint32_t gdma_channel_xfer_config_t::linkListAddr |
Invoked interrupt happens.
#define GDMA_DESC_LLI |
( |
|
linkListAddr, |
|
|
|
stopAfterDescFinished, |
|
|
|
enableDescInterrupt |
|
) |
| |
Value:(((uint32_t)(linkListAddr)&GDMA_LLI_LLI_MASK) | ((enableDescInterrupt) ? GDMA_LLI_DESC_INT_EN_MASK : 0UL) | \
((stopAfterDescFinished) ? GDMA_LLI_STOP_MASK : 0UL))
This macro constructs gdma_descriptor_t::lli.
- Parameters
-
linkListAddr | Address of next link list descriptor item. |
stopAfterDescFinished | Stop or not after this descriptor transfer done. |
enableDescInterrupt | Generate interrupt after this descriptor transfer done. |
typedef void(* gdma_callback_t)(struct _gdma_handle *handle, void *userData, uint32_t interrupts) |
handle: Pointer to the GDMA driver handle. userData: The userData registered using GDMA_SetCallback. interrupts: The interrupts flags of the specific channel.
Enumerator |
---|
kGDMA_TransferWidth1Byte |
1 byte.
|
kGDMA_TransferWidth2Byte |
2 bytes.
|
kGDMA_TransferWidth4Byte |
4 bytes.
|
Enumerator |
---|
kGDMA_BurstSize1 |
Burst 1.
|
kGDMA_BurstSize4 |
Burst 4.
|
kGDMA_BurstSize8 |
Burst 8.
|
kGDMA_BurstSize16 |
Burst 16.
|
kGDMA_BurstSizeWrap4 |
Wrap 4.
|
kGDMA_BurstSizeWrap8 |
Wrap 8.
|
kGDMA_BurstSizeWrap16 |
Wrap 16.
|
Enumerator |
---|
kGDMA_ProtUserMode |
The access is in user mode.
|
kGDMA_ProtPrevilegedMode |
The access is in previleged mode.
|
kGDMA_ProtUnbufferable |
The access is not bufferable.
|
kGDMA_ProtBufferable |
The access is bufferable.
|
kGDMA_ProtUncacheable |
The access is not cacheable.
|
kGDMA_ProtCacheable |
The access is cacheable.
|
Enumerator |
---|
kGDMA_ChannelPriority0 |
Lowest channel priority - priority 0.
|
kGDMA_ChannelPriority1 |
Channel priority 1.
|
kGDMA_ChannelPriority2 |
Channel priority 2.
|
kGDMA_ChannelPriority3 |
Channel priority 3.
|
kGDMA_ChannelPriority4 |
Channel priority 4.
|
kGDMA_ChannelPriority5 |
Channel priority 5.
|
kGDMA_ChannelPriority6 |
Channel priority 6.
|
kGDMA_ChannelPriority7 |
Channel priority 7.
|
kGDMA_ChannelPriority8 |
Channel priority 8.
|
kGDMA_ChannelPriority9 |
Channel priority 9.
|
kGDMA_ChannelPriority10 |
Channel priority 10.
|
kGDMA_ChannelPriority11 |
Channel priority 11.
|
kGDMA_ChannelPriority12 |
Channel priority 12.
|
kGDMA_ChannelPriority13 |
Channel priority 13.
|
kGDMA_ChannelPriority14 |
Channel priority 14.
|
kGDMA_ChannelPriority15 |
Highest channel priority - priority 15.
|
Enumerator |
---|
kGDMA_DescriptorTransferDoneInterruptEnable |
Descriptor transfer done interrupt.
This happens when the descriptor is configured to generate interrupt when transfer done.
|
kGDMA_AddressErrorInterruptEnable |
Channel source or destination address is not aligned to corresponding transfer width.
|
kGDMA_BusErrorInterruptEnable |
AHB bus interrupt.
|
kGDMA_TransferDoneInterruptEnable |
DMA transfer done interrupt.
|
kGDMA_BlockTransferDoneInterruptEnable |
DMA block single/burst transfer done interrupt.
|
kGDMA_AllInterruptEnable |
All interrupt enable.
|
Enumerator |
---|
kGDMA_DescriptorTransferDoneFlag |
Descriptor transfer done interrupt.
This happens when the descriptor is configured to generate interrupt when transfer done.
|
kGDMA_ChannelInterruptFlag |
OR of the content of the respective unmasked interrupt of channel.
|
kGDMA_AddressErrorFlag |
Channel source or destination address is not aligned to corresponding transfer width.
|
kGDMA_BusErrorFlag |
AHB bus interrupt.
|
kGDMA_TransferDoneFlag |
DMA transfer done interrupt.
|
kGDMA_BlockTransferDoneFlag |
DMA block single/burst transfer done interrupt.
|
kGDMA_AllInterruptFlag |
All interrupt flags.
|
< Source address.
< Destination address.
< Link list item.
< Transfer control.
void GDMA_Init |
( |
GDMA_Type * |
base | ) |
|
It ungates the GDMA access clock, after this function, the GDMA module is ready to be used.
- Parameters
-
base | GDMA peripheral base address. |
void GDMA_Deinit |
( |
GDMA_Type * |
base | ) |
|
- Parameters
-
base | GDMA peripheral base address. |
static void GDMA_SetChannelSourceAddress |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
uint32_t |
addr |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
addr | Source address. |
static void GDMA_SetChannelDestAddress |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
uint32_t |
addr |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
addr | Destination address. |
static void GDMA_StartChannel |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
static void GDMA_StopChannel |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
static bool GDMA_IsChannelBusy |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
When GDMA_StopChannel is called, if the channel is on service, it does not stop immediately, application could call this API to check whether the channel is stopped.
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
- Returns
- True if the channel is busy, false if not.
static void GDMA_EnableChannelInterrupts |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
uint32_t |
interrupts |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
interrupts | The interrupts to enable, it is OR'ed value of _gdma_interrupt_enable. |
static void GDMA_DisableChannelInterrupts |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
uint32_t |
interrupts |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
interrupts | The interrupts to disable, it is OR'ed value of _gdma_interrupt_enable. |
static uint32_t GDMA_GetChannelInterruptFlags |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
- Returns
- The interrupt flags, it is OR'ed value of _gdma_interrupt_flags.
static void GDMA_ClearChannelInterruptFlags |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
uint32_t |
flags |
|
) |
| |
|
inlinestatic |
The kGDMA_ChannelInterruptFlag is OR'ed status of all other unmasked interrupt flags, it could not be clear directly, it should be cleared by clear all other flags.
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
flags | The interrupt flags to clear, it is OR'ed value of _gdma_interrupt_flags. |
static uint32_t GDMA_GetChannelFinishedDescriptorNumber |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
The counter increases when an item of descriptor is done in linklist mode.
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
- Returns
- Number of finished descriptor.
static void GDMA_ClearChannelFinishedDescriptorNumber |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
static void GDMA_SetChannelPriority |
( |
GDMA_Type * |
base, |
|
|
uint8_t |
channel, |
|
|
gdma_priority_t |
priority |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | GDMA peripheral base address. |
channel | GDMA channel number. |
priority | Channel priority value. |
This function configures the channel transfer, after configured, GDMA_StartChannel could be called to start the transfer.
This function must be called when previous transfer finished. Application can use GDMA_IsChannelBusy to check whether the channel has finished the previous work.
- Note
- The transfer configuration must follow the requirements:
- SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
- If wrap not used, the address should align with WIDTH
- If wrap used, the address should align with WIDTH * BURST_SIZE.
- Parameters
-
base | GDMA base address. |
channel | GDMA channel number. Pointer to the transfer configuration. |
- Return values
-
kStatus_Fail | GDMA is busy with previous transfer. |
kStatus_Success | Configuration set successfully. |
kStatus_InvalidArgument | Configuration wrong. |
void GDMA_CreateHandle |
( |
gdma_handle_t * |
handle, |
|
|
GDMA_Type * |
base, |
|
|
uint8_t |
channel |
|
) |
| |
This function is called if using transaction API for GDMA. This function initializes the internal state of GDMA handle.
- Parameters
-
handle | GDMA handle pointer. It stores callback function and parameters. |
base | GDMA peripheral base address. |
channel | GDMA channel number. |
This callback is called in GDMA IRQ handler to inform user the interrupt status.
- Parameters
-
handle | GDMA handle pointer. |
callback | GDMA callback function pointer. |
userData | Parameter for callback function. |
After this function, user could call GDMA_StartTransfer to start GDMA transfer.
This function must be called when previous transfer finished. Application can use GDMA_IsChannelBusy to check whether the channel has finished the previous work.
- Note
- The transfer configuration must follow the requirements:
- SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
- If wrap not used, the address should align with WIDTH
- If wrap used, the address should align with WIDTH * BURST_SIZE.
- Parameters
-
handle | GDMA handle pointer. |
config | Pointer to GDMA transfer configuration structure. |
- Return values
-
kStatus_Fail | GDMA is busy with previous transfer. |
kStatus_Success | Configuration set successfully. |
kStatus_InvalidArgument | Configuration wrong. |
When this function is called, if the channel is on service, it only stops when service finished.
- Parameters
-
handle | GDMA handle pointer. |
void GDMA_IRQHandle |
( |
GDMA_Type * |
base | ) |
|
This function checks all GDMA channel interrupts and inform application the interrupt flags through user registered callback.
- Parameters
-