edma_driver.h File Reference
#include "device_registers.h"
#include "status.h"
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  edma_user_config_t
 The user configuration structure for the eDMA driver. More...
 
struct  edma_chn_state_t
 Data structure for the eDMA channel state. Implements : edma_chn_state_t_Class. More...
 
struct  edma_channel_config_t
 The user configuration structure for the an eDMA driver channel. More...
 
struct  edma_scatter_gather_list_t
 Data structure for configuring a discrete memory transfer. Implements : edma_scatter_gather_list_t_Class. More...
 
struct  edma_state_t
 Runtime state structure for the eDMA driver. More...
 
struct  edma_loop_transfer_config_t
 eDMA loop transfer configuration. More...
 
struct  edma_transfer_config_t
 eDMA transfer size configuration. More...
 
struct  edma_software_tcd_t
 eDMA TCD Implements : edma_software_tcd_t_Class More...
 

Macros

#define STCD_SIZE(number)    (((number) * 32U) - 1U)
 Macro for the memory size needed for the software TCD. More...
 
#define STCD_ADDR(address)    (((uint32_t)address + 31UL) & ~0x1FUL)
 
#define EDMA_ERR_LSB_MASK   1U
 Macro for accessing the least significant bit of the ERR register. More...
 

Typedefs

typedef void(* edma_callback_t) (void *parameter, edma_chn_status_t status)
 Definition for the eDMA channel callback function. More...
 

Enumerations

enum  edma_channel_interrupt_t { EDMA_CHN_ERR_INT = 0U, EDMA_CHN_HALF_MAJOR_LOOP_INT, EDMA_CHN_MAJOR_LOOP_INT }
 eDMA channel interrupts. Implements : edma_channel_interrupt_t_Class More...
 
enum  edma_arbitration_algorithm_t { EDMA_ARBITRATION_FIXED_PRIORITY = 0U, EDMA_ARBITRATION_ROUND_ROBIN }
 eDMA channel arbitration algorithm used for selection among channels. Implements : edma_arbitration_algorithm_t_Class More...
 
enum  edma_channel_priority_t {
  EDMA_CHN_PRIORITY_0 = 0U, EDMA_CHN_PRIORITY_1 = 1U, EDMA_CHN_PRIORITY_2 = 2U, EDMA_CHN_PRIORITY_3 = 3U,
  EDMA_CHN_DEFAULT_PRIORITY = 255U
}
 eDMA channel priority setting Implements : edma_channel_priority_t_Class More...
 
enum  edma_modulo_t {
  EDMA_MODULO_OFF = 0U, EDMA_MODULO_2B, EDMA_MODULO_4B, EDMA_MODULO_8B,
  EDMA_MODULO_16B, EDMA_MODULO_32B, EDMA_MODULO_64B, EDMA_MODULO_128B,
  EDMA_MODULO_256B, EDMA_MODULO_512B, EDMA_MODULO_1KB, EDMA_MODULO_2KB,
  EDMA_MODULO_4KB, EDMA_MODULO_8KB, EDMA_MODULO_16KB, EDMA_MODULO_32KB,
  EDMA_MODULO_64KB, EDMA_MODULO_128KB, EDMA_MODULO_256KB, EDMA_MODULO_512KB,
  EDMA_MODULO_1MB, EDMA_MODULO_2MB, EDMA_MODULO_4MB, EDMA_MODULO_8MB,
  EDMA_MODULO_16MB, EDMA_MODULO_32MB, EDMA_MODULO_64MB, EDMA_MODULO_128MB,
  EDMA_MODULO_256MB, EDMA_MODULO_512MB, EDMA_MODULO_1GB, EDMA_MODULO_2GB
}
 eDMA modulo configuration Implements : edma_modulo_t_Class More...
 
enum  edma_transfer_size_t { EDMA_TRANSFER_SIZE_1B = 0x0U, EDMA_TRANSFER_SIZE_2B = 0x1U, EDMA_TRANSFER_SIZE_4B = 0x2U }
 eDMA transfer configuration Implements : edma_transfer_size_t_Class More...
 
enum  edma_chn_status_t { EDMA_CHN_NORMAL = 0U, EDMA_CHN_ERROR }
 Channel status for eDMA channel. More...
 
enum  edma_transfer_type_t { EDMA_TRANSFER_PERIPH2MEM = 0U, EDMA_TRANSFER_MEM2PERIPH, EDMA_TRANSFER_MEM2MEM, EDMA_TRANSFER_PERIPH2PERIPH }
 A type for the DMA transfer. Implements : edma_transfer_type_t_Class. More...
 

Functions

eDMA peripheral driver module level functions
status_t EDMA_DRV_Init (edma_state_t *edmaState, const edma_user_config_t *userConfig, edma_chn_state_t *const chnStateArray[], const edma_channel_config_t *const chnConfigArray[], uint32_t chnCount)
 Initializes the eDMA module. More...
 
status_t EDMA_DRV_Deinit (void)
 De-initializes the eDMA module. More...
 
eDMA peripheral driver channel management functions
status_t EDMA_DRV_ChannelInit (edma_chn_state_t *edmaChannelState, const edma_channel_config_t *edmaChannelConfig)
 Initializes an eDMA channel. More...
 
status_t EDMA_DRV_ReleaseChannel (uint8_t virtualChannel)
 Releases an eDMA channel. More...
 
eDMA peripheral driver transfer setup functions
void EDMA_DRV_PushConfigToReg (uint8_t virtualChannel, const edma_transfer_config_t *tcd)
 Copies the channel configuration to the TCD registers. More...
 
void EDMA_DRV_PushConfigToSTCD (const edma_transfer_config_t *config, edma_software_tcd_t *stcd)
 Copies the channel configuration to the software TCD structure. More...
 
status_t EDMA_DRV_ConfigSingleBlockTransfer (uint8_t virtualChannel, edma_transfer_type_t type, uint32_t srcAddr, uint32_t destAddr, edma_transfer_size_t transferSize, uint32_t dataBufferSize)
 Configures a simple single block data transfer with DMA. More...
 
status_t EDMA_DRV_ConfigMultiBlockTransfer (uint8_t virtualChannel, edma_transfer_type_t type, uint32_t srcAddr, uint32_t destAddr, edma_transfer_size_t transferSize, uint32_t blockSize, uint32_t blockCount, bool disableReqOnCompletion)
 Configures a multiple block data transfer with DMA. More...
 
status_t EDMA_DRV_ConfigLoopTransfer (uint8_t virtualChannel, const edma_transfer_config_t *transferConfig)
 Configures the DMA transfer in loop mode. More...
 
status_t EDMA_DRV_ConfigScatterGatherTransfer (uint8_t virtualChannel, edma_software_tcd_t *stcd, edma_transfer_size_t transferSize, uint32_t bytesOnEachRequest, const edma_scatter_gather_list_t *srcList, const edma_scatter_gather_list_t *destList, uint8_t tcdCount)
 Configures the DMA transfer in a scatter-gather mode. More...
 
void EDMA_DRV_CancelTransfer (bool error)
 Cancel the running transfer. More...
 
eDMA Peripheral driver channel operation functions
status_t EDMA_DRV_StartChannel (uint8_t virtualChannel)
 Starts an eDMA channel. More...
 
status_t EDMA_DRV_StopChannel (uint8_t virtualChannel)
 Stops the eDMA channel. More...
 
status_t EDMA_DRV_SetChannelRequest (uint8_t virtualChannel, uint8_t req)
 Configures the DMA request for the eDMA channel. More...
 
void EDMA_DRV_ClearTCD (uint8_t virtualChannel)
 Clears all registers to 0 for the channel's TCD. More...
 
void EDMA_DRV_SetSrcAddr (uint8_t virtualChannel, uint32_t address)
 Configures the source address for the eDMA channel. More...
 
void EDMA_DRV_SetSrcOffset (uint8_t virtualChannel, int16_t offset)
 Configures the source address signed offset for the eDMA channel. More...
 
void EDMA_DRV_SetSrcReadChunkSize (uint8_t virtualChannel, edma_transfer_size_t size)
 Configures the source data chunk size (transferred in a read sequence). More...
 
void EDMA_DRV_SetSrcLastAddrAdjustment (uint8_t virtualChannel, int32_t adjust)
 Configures the source address last adjustment. More...
 
void EDMA_DRV_SetDestAddr (uint8_t virtualChannel, uint32_t address)
 Configures the destination address for the eDMA channel. More...
 
void EDMA_DRV_SetDestOffset (uint8_t virtualChannel, int16_t offset)
 Configures the destination address signed offset for the eDMA channel. More...
 
void EDMA_DRV_SetDestWriteChunkSize (uint8_t virtualChannel, edma_transfer_size_t size)
 Configures the destination data chunk size (transferred in a write sequence). More...
 
void EDMA_DRV_SetDestLastAddrAdjustment (uint8_t virtualChannel, int32_t adjust)
 Configures the destination address last adjustment. More...
 
void EDMA_DRV_SetMinorLoopBlockSize (uint8_t virtualChannel, uint32_t nbytes)
 Configures the number of bytes to be transferred in each service request of the channel. More...
 
void EDMA_DRV_SetMajorLoopIterationCount (uint8_t virtualChannel, uint32_t majorLoopCount)
 Configures the number of major loop iterations. More...
 
uint32_t EDMA_DRV_GetRemainingMajorIterationsCount (uint8_t virtualChannel)
 Returns the remaining major loop iteration count. More...
 
void EDMA_DRV_SetScatterGatherLink (uint8_t virtualChannel, uint32_t nextTCDAddr)
 Configures the memory address of the next TCD, in scatter/gather mode. More...
 
void EDMA_DRV_DisableRequestsOnTransferComplete (uint8_t virtualChannel, bool disable)
 Disables/Enables the DMA request after the major loop completes for the TCD. More...
 
void EDMA_DRV_ConfigureInterrupt (uint8_t virtualChannel, edma_channel_interrupt_t intSrc, bool enable)
 Disables/Enables the channel interrupt requests. More...
 
void EDMA_DRV_TriggerSwRequest (uint8_t virtualChannel)
 Triggers a sw request for the current channel. More...
 
eDMA Peripheral callback and interrupt functions
status_t EDMA_DRV_InstallCallback (uint8_t virtualChannel, edma_callback_t callback, void *parameter)
 Registers the callback function and the parameter for eDMA channel. More...
 
eDMA Peripheral driver miscellaneous functions
edma_chn_status_t EDMA_DRV_GetChannelStatus (uint8_t virtualChannel)
 Gets the eDMA channel status. More...