GPDMA#
Introduction#
The GPDMA (General Purpose Direct Memory Access) peripheral enables efficient data transfers between memory and peripherals or between memory regions without CPU intervention. This offloads the CPU, reduces latency, and improves overall system performance.
Key Features:
Supports multiple independent DMA channels.
Configurable channel priorities.
Supports memory-to-memory, memory-to-peripheral, peripheral-to-memory, and peripheral-to-peripheral transfers.
Flexible data width and burst size configuration.
Linked list (descriptor-based) transfer support for complex or large data moves.
FIFO buffer allocation for optimized throughput.
Callback support for transfer completion and error handling.
Hardware flow control options.
Configuration#
The GPDMA can be configured for various transfer types and operational modes, including:
Memory-to-Memory: Direct transfer between two memory locations.
Memory-to-Peripheral: Transfer from memory to a peripheral register.
Peripheral-to-Memory: Transfer from a peripheral register to memory.
Peripheral-to-Peripheral: Transfer between two peripheral registers.
Linked List Mode: Use descriptors for chained or scatter-gather transfers.
FIFO Allocation: Assign FIFO buffers to channels for burst transfers.
Callback Registration: Register callbacks for transfer complete, descriptor fetch, and error events. These configurations are encapsulated in the sl_si91x_gpdma_channel_config_t and related structures, and initialized using the provided GPDMA APIs.
For more details on configuration parameters, see the respective peripheral example readme document.
Usage#
After defining the GPDMA configuration structures and passing the appropriate parameters, the following functions can be used to initialize and operate the GPDMA peripheral. The typical flow for implementation is as follows:
Initialize the GPDMA driver: sl_si91x_gpdma_init
Allocate a DMA channel: sl_si91x_gpdma_allocate_channel
Register callbacks for transfer and error events: sl_si91x_gpdma_register_callbacks
Allocate and configure descriptors as needed: sl_si91x_gpdma_allocate_descriptor, sl_si91x_gpdma_build_descriptor
Start a transfer: sl_si91x_gpdma_transfer
Optionally allocate FIFO buffers: sl_si91x_gpdma_allocate_fifo
Stop or deallocate the channel when done: sl_si91x_gpdma_stop_transfer, sl_si91x_gpdma_deallocate_channel
Modules#
sl_si91x_gpdma_resources_Data_t
Enumerations#
Enumeration that holds 8-bit codes used by the callback_type parameter in the sl_si91x_gpdma_unregister_callbacks function.
Typedefs#
Callback function type.
GPDMA descriptor structure.
GPDMA data context structure.
GPDMA descriptor configuration structure.
GPDMA handle type.
GPDMA channel configuration structure.
GPDMA initialization structure.
GPDMA transfer complete callback type.
Functions#
To initialize the GPDMA peripheral.
To allocate a GPDMA channel for the transfer.
To deallocate the GPDMA channel.
To register the GPDMA callbacks (transfer complete & error).
To unregister the GPDMA callbacks (transfer complete and error).
To start a simple memory-to-memory DMA transfer.
To stop the GPDMA transfer.
Allocates a GPDMA descriptor with default config for given channel based on tranfer size.
Deallocates a DMA descriptor for the specified channel number.
Builds a GPDMA descriptor with the specified configuration.
Allocates a FIFO buffer of the specified size to a GPDMA channel.
Gets the FIFO size of a specified GPDMA channel.
Gets the current status of a specified GPDMA channel.
Macros#
Status code indicates that the DMA channel already allocated for another transfer.
Status code indicates that no DMA channel is available for allocation.
Status code indicates that the DMA channel is already unallocated.
Status code indicates that channel is not allocated for DMA transfer.
Status code indicates that the channel is not available for allocation.
Status code indicates that no DMA channel is available for allocation.
Status code indicates that the descriptor memory buffer is already allocated.
Status code indicates that the descriptor memory buffer is not sufficient.
Status code indicates that the channel is not allocated for DMA transfer.
Status code indicates that Memory buffer is not allocated for the given channel.
Maximum GPDMA channel priority.
Data width 8 bits.
Data width 16 bits.
Data width 32 bits.
GPDMA controller.
Source peripheral.
Destination peripheral.
Source and destination peripherals.
Memory to memory transfer.
Memory to peripheral transfer.
Peripheral to memory transfer.
Peripheral to peripheral transfer.
Master 0.
Master 1.
AHB burst size 1.
AHB burst size 4.
AHB burst size 8.
AHB burst size 16.
AHB burst size 20.
AHB burst size 24.
AHB burst size 28.
AHB burst size 32.
Destination data burst size.
Source data burst size.
Enable link list fetch done interrupt.
Disable link list fetch done interrupt.
DMA controller controls flow control.
Source peripheral controls flow control.
Destination peripheral controls flow control.
Source and destination peripheral controls flow control.
Enable link list mode.
Disable link list mode.
Enable source FIFO mode.
Disable source FIFO mode.
Enable destination FIFO mode.
Disable destination FIFO mode.
Enable memory fill.
Disable memory fill.
Memory one fill.
Memory zero fill.
Enable DMA protection.
Disable DMA protection.
Maximum transfer size per descriptor.
Maximum FIFO size.
Maximum number of callback types.
Enumeration Documentation#
sl_gpdma_callback_code_t#
sl_gpdma_callback_code_t
Enumeration that holds 8-bit codes used by the callback_type parameter in the sl_si91x_gpdma_unregister_callbacks function.
This enumeration defines the 8-bit codes for different types of DMA callbacks that can be unregistered.
Enumerator | |
---|---|
SL_GPDMA_HRESP_ERROR_CB | HRESP error callback code. |
SL_GPDMA_DESCRIPTOR_FETCH_DONE_CB | Descriptor fetch done callback code. |
SL_GPDMA_TRANSFER_DONE_CB | Transfer done callback code. |
SL_GPDMA_GPDMAC_ERROR_CB | GPDMA controller error callback code. |
Typedef Documentation#
sl_si91x_gpdma_descriptor_t#
typedef RSI_GPDMA_DESC_T sl_si91x_gpdma_descriptor_t
GPDMA descriptor structure.
sl_si91x_gpdma_data_context_t#
typedef GPDMA_DATACONTEXT_T sl_si91x_gpdma_data_context_t
GPDMA data context structure.
sl_si91x_gpdma_descriptor_config_t#
typedef sl_si91x_gpdma_descriptor_t sl_si91x_gpdma_descriptor_config_t
GPDMA descriptor configuration structure.
sl_si91x_gpdma_channel_config_t#
typedef RSI_GPDMA_CHA_CFG_T sl_si91x_gpdma_channel_config_t
GPDMA channel configuration structure.
sl_si91x_gpdma_init_t#
typedef RSI_GPDMA_INIT_T sl_si91x_gpdma_init_t
GPDMA initialization structure.
sl_si91x_gpdma_transfer_complete_cb#
typedef gpdmaTransferCompleteCB sl_si91x_gpdma_transfer_complete_cb
GPDMA transfer complete callback type.
Function Documentation#
sl_si91x_gpdma_init#
sl_status_t sl_si91x_gpdma_init ()
To initialize the GPDMA peripheral.
This API
Enables the GPDMA clock
Clears GPDMA NVIC interrupt
Enables GPDMA NVIC interrupt
Masks GPDMA interruptsAssigns
Clears GPDMA interrupts
Returns
sl_status_t Initialization status:
SL_STATUS_OK - Initialization success.
SL_STATUS_NOT_INITIALIZED - Initialization failed.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_allocate_channel#
sl_status_t sl_si91x_gpdma_allocate_channel (uint32_t * channel_no, uint32_t priority, uint32_t max_transfer_size)
To allocate a GPDMA channel for the transfer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t * | [in] | channel_no | Pointer to the channel number variable:
|
uint32_t | [in] | priority | Priority of the channel:
|
uint32_t | [in] | max_transfer_size | Maximum transfer size in the given channel. |
This API checks the available GPDMA channels and allocates one. It sets the priority of the allocated channel and assigns the channel number to the channel_no variable. If no channel is available, it will return SL_GPDMA_NO_CHANNEL_AVAILABLE.
Note: Users can also initialize the desired channel number, and this API checks whether the desired channel is available and allocates the channel if available. If users want the driver to allocate an available channel, channel_no should be initialized to 0.
Pre-condition:
sl_si91x_dma_init must be called prior.
Returns
sl_status_t Channel allocation status:
SL_STATUS_OK - Channel allocated.
SL_STATUS_NOT_INITIALIZED - GPDMA not initialized.
SL_STATUS_INVALID_PARAMETER - Channel number is invalid.
SL_STATUS_GPDMA_NO_CHANNEL_AVAILABLE - All GPDMA channels are allocated.
SL_STATUS_GPDMA_CHANNEL_ALREADY_ALLOCATED - The desired channel is already allocated.
SL_STATUS_BUSY - Channel is busy.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_deallocate_channel#
sl_status_t sl_si91x_gpdma_deallocate_channel (uint32_t channel_no)
To deallocate the GPDMA channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | Channel number:
|
This API deallocates the GPDMA channel if there is no ongoing transfer on the channel. Deallocating the channel will also unregister the callbacks for transfer complete and error.
Pre-conditions:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_channel must be called prior.
Returns
sl_status_t Channel deallocation status:
SL_STATUS_OK - Channel deallocated.
SL_STATUS_BUSY - Cannot deallocate channel due to an ongoing transfer.
SL_STATUS_NOT_INITIALIZED - GPDMA not initialized.
SL_STATUS_INVALID_PARAMETER - Channel number is invalid.
SL_STATUS_GPDMA_CHANNEL_ALREADY_UNALLOCATED - Channel already deallocated For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_register_callbacks#
sl_status_t sl_si91x_gpdma_register_callbacks (uint32_t channel_no, sl_gpdma_callback_pointer_t * callback_t)
To register the GPDMA callbacks (transfer complete & error).
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | Channel number:
|
sl_gpdma_callback_pointer_t * | [in] | callback_t | Pointer to the structure containing callback functions. |
This API registers the GPDMA callbacks for transfer complete and error events. The user must update the sl_dma_callback_t structure and pass its address to this function. A separate callback can be present for transfer complete and error for each channel.
Pre-conditions:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_channel must be called prior.
Returns
sl_status_t Callback registration status:
SL_STATUS_OK - Callback registered successfully.
SL_STATUS_NOT_INITIALIZED - GPDMA peripheral not initialized.
SL_STATUS_INVALID_PARAMETER - Invalid channel number.
SL_STATUS_NULL_POINTER - Callback pointer is NULL.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED - Given channel is not allocated.
SL_STATUS_BUSY - channel is busy.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_unregister_callbacks#
sl_status_t sl_si91x_gpdma_unregister_callbacks (uint32_t channel_no, uint8_t callback_type)
To unregister the GPDMA callbacks (transfer complete and error).
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | Channel number:
|
uint8_t | [in] | callback_type | Unregister the GPDMA callbacks based on the callback type (8-bit callback number):
|
This API unregisters the DMA callbacks for transfer complete and error events. Users need to update the 8-bit variable callback_type and pass it to the function. Each bit is mapped to a specific callback.
Pre-conditions:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_channel must be called prior.
sl_si91x_gpdma_register_callbacks must be called prior.
Returns
sl_status_t Callback unregistration status:
SL_STATUS_OK - Callback unregistered successfully.
SL_STATUS_NOT_INITIALIZED - GPDMA peripheral not initialized.
SL_STATUS_INVALID_PARAMETER - Invalid channel number or callback type.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED - Given channel is not allocated.
SL_STATUS_BUSY - Channel is busy.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_transfer#
sl_status_t sl_si91x_gpdma_transfer (uint32_t channel, void * src, void * dest)
To start a simple memory-to-memory DMA transfer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel | Channel number: 0-7 |
void * | [in] | src | Source address. |
void * | [in] | dest | Destination address. |
This API configures the DMA channel descriptor and initiates a simple memory-to-memory DMA transfer. Users need to pass the source address and destination address of the transfer along with the channel number.
Pre-conditions:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_channel must be called prior.
sl_si91x_gpdma_register_callbacks must be called prior.
Returns
sl_status_t DMA transfer status:
SL_STATUS_OK - Transfer success.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED - Given channel is not allocated.
SL_STATUS_NOT_INITIALIZED - GPDMA peripheral not initialized.
SL_STATUS_SUSPENDED - Transfer initialization failed.
SL_STATUS_INVALID_PARAMETER - Channel number is invalid or source or destination is NULL.
SL_STATUS_BUSY - Channel is busy.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_stop_transfer#
sl_status_t sl_si91x_gpdma_stop_transfer (uint32_t channel_no)
To stop the GPDMA transfer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | Channel number:
|
This API stops any active transfer on the channel by disabling the GPDMA channel. If there is no active transfer on the channel, this function returns SL_STATUS_IDLE.
Pre-conditions:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_channel must be called prior.
sl_si91x_gpdma_transfer must be called prior.
Returns
sl_status_t DMA transfer status:
SL_STATUS_OK - Transfer stopped successfully.
SL_STATUS_IDLE - There is no active transfer on the channel.
SL_STATUS_NOT_INITIALIZED - GPDMA peripheral not initialized.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED - Given channel is not allocated.
SL_STATUS_INVALID_PARAMETER - Invalid channel number.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_allocate_descriptor#
sl_status_t sl_si91x_gpdma_allocate_descriptor (sl_si91x_gpdma_descriptor_t * pDesc_memory, uint32_t transfer_size, uint32_t channel_number)
Allocates a GPDMA descriptor with default config for given channel based on tranfer size.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_si91x_gpdma_descriptor_t * | [inout] | pDesc_memory | Pointer to the memory location where the descriptor will be allocated and initialized,this memory must be pre-allocated by the caller. |
uint32_t | [in] | transfer_size | Size of the data transfer in bytes. |
uint32_t | [in] | channel_number | GPDMA channel number 0-7 to be used for the transfer. |
This function allocates GPDMA descriptor in the provided memory location, fills the descriptors with default values, and attaches it to the given channel. The descriptor is configured for the specified transfer size and channel number.
Returns
sl_status_t
SL_STATUS_OK: Descriptor successfully allocated and initialized.
SL_STATUS_GPDMA_DESCRIPTOR_MEMORY_BUFFER_NOT_SUFFICIENT: descriptor memory buffer size is not sufficient.
SL_STATUS_GPDMA_DESCRIPTOR_MEMORY_BUFFER_ALREADY_ALLOCATED : descriptor memory buffer already allocated to given channel.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED: Given channel is not allocated.
SL_STATUS_INVALID_PARAMETER: Invalid input parameters.
SL_STATUS_BUSY - Channel is busy. For more information on status codes, see SL STATUS DOCUMENTATION.
sl_Si91x_gpdma_deallocate_descriptor#
sl_status_t sl_Si91x_gpdma_deallocate_descriptor (uint32_t channel_number)
Deallocates a DMA descriptor for the specified channel number.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_number | The channel number 0-7 from which to deallocate the descriptor. |
This function deallocates a previously allocated DMA descriptor associated with the given channel number.
Pre-condition:
sl_si91x_gpdma_init must be called prior.
sl_si91x_gpdma_allocate_descriptor must be called prior.
Returns
sl_status_t SL_STATUS_OK if the descriptor was successfully deallocated, SL_STATUS_INVALID_PARAMETER if the channel number is invalid, SL_STATUS_BUSY if the transfer is still in progress in given channel, SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED given channel is not allocated,
Note
The channel must be disabled before calling this function to avoid unpredictable behavior. For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_build_descriptor#
sl_status_t sl_si91x_gpdma_build_descriptor (sl_si91x_gpdma_descriptor_t * pDescriptor_memory, sl_si91x_gpdma_descriptor_config_t * pDesc_config, uint32_t transfer_size, uint32_t channel_number)
Builds a GPDMA descriptor with the specified configuration.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_si91x_gpdma_descriptor_t * | [inout] | pDescriptor_memory | Pointer to the memory location where the descriptor will be built. This memory must be pre-allocated by the caller. |
sl_si91x_gpdma_descriptor_config_t * | [in] | pDesc_config | Pointer to the configuration structure containing the descriptor settings. |
uint32_t | [in] | transfer_size | The size of the data transfer in bytes. |
uint32_t | [in] | channel_number | The GPDMA 0-7 channel number to be used for the transfer. |
This function initializes a GPDMA descriptor with the provided configuration. The descriptor can then be used for GPDMA operations.
Returns
Status of the operation.
SL_STATUS_OK: If the descriptor was successfully built.
SL_STATUS_INVALID_PARAMETER: If any of the input parameters are invalid.
SL_STATUS_GPDMA_DESCRIPTOR_MEMORY_BUFFER_NOT_SUFFICIENT: descriptor memory buffer size is not sufficient.
SL_STATUS_GPDMA_DESCRIPTOR_MEMORY_BUFFER_ALREADY_ALLOCATED : descriptor memory buffer already allocated to given channel.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED: Given channel is not allocated.
SL_STATUS_BUSY - Channel is busy. For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_gpdma_allocate_fifo#
sl_status_t sl_si91x_gpdma_allocate_fifo (uint32_t channel_no, uint32_t fifo_size)
Allocates a FIFO buffer of the specified size to a GPDMA channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | The GPDMA channel number to allocate the FIFO for. |
uint32_t | [in] | fifo_size | The size of the FIFO buffer to allocate (in bytes). |
This function allocates a FIFO (First In, First Out) buffer of the specified size to the selected GPDMA channel.
Returns
Status of the operation.
SL_STATUS_OK: If the FIFO was successfully allocated.
SL_STATUS_INVALID_PARAMETER: If the channel number is invalid or the FIFO size is not supported.
SL_STATUS_GPDMA_FIFO_MEMORY_NOT_AVAILABLE: If the FIFO memory is not available.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED: Given channel is not allocated.
SL_STATUS_BUSY - Channel is busy.
Note
The availability of channels and maximum FIFO size may vary based on hardware configuration. For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_get_channel_fifo_size#
sl_status_t sl_si91x_get_channel_fifo_size (uint32_t channel_no, uint32_t * fifo_size)
Gets the FIFO size of a specified GPDMA channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_no | The GPDMA channel number to query |
uint32_t * | [out] | fifo_size | Pointer to store the retrieved FIFO size value |
This function retrieves the FIFO buffer size configured for the specified GPDMA channel.
Returns
sl_status_t SL_STATUS_OK if successful, SL_STATUS_INVALID_PARAMETER if channel number is invalid, SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED if given channel is not allocated.
Note
The channel number should be within the valid range of available GPDMA channels.
sl_si91x_gpdma_get_channel_status#
sl_status_t sl_si91x_gpdma_get_channel_status (uint32_t channel_number)
Gets the current status of a specified GPDMA channel.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | channel_number | The GPDMA channel number for which to get the status |
This function retrieves the status of the specified GPDMA channel.
Returns
status of the operation.
SL_STATUS_OK: If the channel is free.
SL_STATUS_BUSY: If the transfer is in progress for given channel.
SL_STATUS_GPDMA_CHANNEL_NOT_ALLOCATED: If the channel is not allocated.
SL_STATUS_GPDMA_CHANNEL_ALREADY_ALLOCATED: If the channel is already allocated.