PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
Direct Memory Access (DMA)

Data Structures

union  un_dmac_dmaca_t
 
union  un_dmac_dmacb_t
 
struct  stc_dma_intern_data
 Datatype for holding internal data needed for DMA. More...
 
struct  stc_dma_instance_data
 DMA instance data type. More...
 
struct  stc_dma_config
 DMA configuration. More...
 

Macros

#define GET_DMA_ADDRESS(x)   (FM4_DMAC_BASE + (0x10ul * (x)) + 0x10ul)
 
#define DMA_DMACA_OFFSET   0x00ul
 
#define DMA_DMACB_OFFSET   0x04ul
 
#define DMA_DMASA_OFFSET   0x08ul
 
#define DMA_DMADA_OFFSET   0x0Cul
 
#define DMA_CHANNEL_ACTIVE   1u
 
#define DMA_CHANNEL_INACTIVE   0u
 

Typedefs

typedef enum en_dma_transfermode en_dma_transfermode_t
 DMA transfer data width. More...
 
typedef enum en_dma_transferwidth en_dma_transferwidth_t
 DMA transfer data width. More...
 
typedef enum en_dma_idreq en_dma_idreq_t
 DMA IDREQ number. More...
 
typedef struct stc_dma_intern_data stc_dma_intern_data_t
 Datatype for holding internal data needed for DMA. More...
 
typedef struct
stc_dma_instance_data 
stc_dma_instance_data_t
 DMA instance data type. More...
 
typedef struct stc_dma_config stc_dma_config_t
 DMA configuration. More...
 

Enumerations

enum  en_dma_transfermode {
  DmaBlockTransfer = 0,
  DmaBurstTransfer = 1,
  DmaDemandTransfer = 2
}
 DMA transfer data width. More...
 
enum  en_dma_transferwidth {
  Dma8Bit = 0,
  Dma16Bit = 1,
  Dma32Bit = 2
}
 DMA transfer data width. More...
 
enum  en_dma_idreq {
  Ep1DrqUsb0 = 0,
  Ep2DrqUsb0 = 1,
  Ep3DrqUsb0 = 2,
  Ep4DrqUsb0 = 3,
  Ep5DrqUsb0 = 4,
  Adc0 = 5,
  Adc1 = 6,
  Adc2 = 7,
  Bt0Irq0 = 8,
  Bt2Irq0 = 9,
  Bt4Irq0 = 10,
  Bt6Irq0 = 11,
  MfsRx0 = 12,
  MfsTx0 = 13,
  MfsRx1 = 14,
  MfsTx1 = 15,
  MfsRx2 = 16,
  MfsTx2 = 17,
  MfsRx3 = 18,
  MfsTx3 = 19,
  MfsRx4 = 20,
  MfsTx4 = 21,
  MfsRx5 = 22,
  MfsTx5 = 23,
  MfsRx6 = 24,
  MfsTx6 = 25,
  MfsRx7 = 26,
  MfsTx7 = 27,
  ExtIrq0 = 28,
  ExtIrq1 = 29,
  ExtIrq2 = 30,
  ExtIrq3 = 31,
  Software = 1234
}
 DMA IDREQ number. More...
 

Functions

static en_result_t Dma_Irq_Init (uint8_t u8DmaChannel)
 Init DMA interrupt. More...
 
static en_result_t Dma_Irq_DeInit (uint8_t u8DmaChannel)
 De-Init DMA interrupt. More...
 
void DmaIrqHandler (uint8_t u8DmaChannel)
 DMA interrupt handler. More...
 
en_result_t Dma_Init_Channel (volatile stc_dma_config_t *pstcConfig)
 Initializes a DMA channel. More...
 
en_result_t Dma_Set_Channel (volatile stc_dma_config_t *pstcConfig)
 Enable, disable, pause, or trigger a DMA channel via configuration. More...
 
en_result_t Dma_Enable (void)
 Enable DMA globally. More...
 
en_result_t Dma_Disable (void)
 Disable DMA globally. More...
 
en_result_t Dma_DeInit_Channel (volatile stc_dma_config_t *pstcConfig)
 De-Initializes a DMA channel. More...
 
en_result_t Dma_Set_ChannelParam (uint8_t u8DmaChannel, boolean_t bEnable, boolean_t bPause, boolean_t bSoftwareTrigger)
 Enable, disable, pause, or trigger a DMA channel via arguments. More...
 
en_result_t Dma_DeInit_ChannelParam (uint8_t u8DmaChannel)
 De-Initializes a DMA channel via channel parameter. More...
 

Variables

stc_dma_intern_data_t stcDmaInternData
 
stc_dma_intern_data_t stcDmaInternData
 

Detailed Description

Provided functions of DMA module:

The DMA is configured by Dma_Init_Channel() but not started then. With the function Dma_Set_Channel() the enable, pause and/or trigger bits can be set. Dma_Enable() enables globally the DMA and Dma_Disable() disables DMA globally. Dma_DeInit_Channel() clears a channel for a possible new configuration.

Once a DMA channel was setup by Dma_Init_Channel() it cannot be re-initialized by this function (with a new configuration) anymore. result_t::OperationInProgress is returned in this case. Dma_DeInit_Channel() has to be called before to unlock the channel for a new configuration.

Dma_Set_ChannelParam() and Dma_DeInit_ChannelParam() perform the same functionality as Dma_Set_Channel() and Dma_DeInit_Channel() instead of configuration usage. Here direct arguments are used.

Note
Set stc_dma_config_t::u16TransferCount to "Number of Transfers - 1"!

Macro Definition Documentation

#define DMA_CHANNEL_ACTIVE   1u

Definition at line 114 of file dma.h.

Referenced by Dma_Init_Channel().

#define DMA_CHANNEL_INACTIVE   0u

Definition at line 115 of file dma.h.

Referenced by Dma_DeInit_Channel(), and Dma_DeInit_ChannelParam().

#define DMA_DMACA_OFFSET   0x00ul
#define DMA_DMACB_OFFSET   0x04ul
#define DMA_DMADA_OFFSET   0x0Cul

Definition at line 110 of file dma.h.

Referenced by Dma_DeInit_Channel(), Dma_DeInit_ChannelParam(), and Dma_Init_Channel().

#define DMA_DMASA_OFFSET   0x08ul

Definition at line 109 of file dma.h.

Referenced by Dma_DeInit_Channel(), Dma_DeInit_ChannelParam(), and Dma_Init_Channel().

#define GET_DMA_ADDRESS (   x)    (FM4_DMAC_BASE + (0x10ul * (x)) + 0x10ul)

Typedef Documentation

DMA IDREQ number.

DMA transfer data width.

DMA transfer data width.

DMA configuration.

DMA instance data type.

Datatype for holding internal data needed for DMA.

Enumeration Type Documentation

DMA IDREQ number.

Enumerator
Ep1DrqUsb0 

Interrupt signal from EP1 DRQ of USB ch.0.

Ep2DrqUsb0 

Interrupt signal from EP2 DRQ of USB ch.0.

Ep3DrqUsb0 

Interrupt signal from EP3 DRQ of USB ch.0.

Ep4DrqUsb0 

Interrupt signal from EP4 DRQ of USB ch.0.

Ep5DrqUsb0 

Interrupt signal from EP5 DRQ of USB ch.0.

Adc0 

Scan conversion interrupt signal from A/D converter unit0.

Adc1 

Scan conversion interrupt signal from A/D converter unit1.

Adc2 

Scan conversion interrupt signal from A/D converter unit2.

Bt0Irq0 

Interrupt signal from IRQ0 of base timer ch.0.

Bt2Irq0 

Interrupt signal from IRQ0 of base timer ch.2.

Bt4Irq0 

Interrupt signal from IRQ0 of base timer ch.4.

Bt6Irq0 

Interrupt signal from IRQ0 of base timer ch.6.

MfsRx0 

Receiving interrupt signal from MFS ch.0.

MfsTx0 

Sending interrupt signal from MFS ch.0.

MfsRx1 

Receiving interrupt signal from MFS ch.1.

MfsTx1 

Sending interrupt signal from MFS ch.1.

MfsRx2 

Receiving interrupt signal from MFS ch.2.

MfsTx2 

Sending interrupt signal from MFS ch.2.

MfsRx3 

Receiving interrupt signal from MFS ch.3.

MfsTx3 

Sending interrupt signal from MFS ch.3.

MfsRx4 

Receiving interrupt signal from MFS ch.4.

MfsTx4 

Sending interrupt signal from MFS ch.4.

MfsRx5 

Receiving interrupt signal from MFS ch.5.

MfsTx5 

Sending interrupt signal from MFS ch.5.

MfsRx6 

Receiving interrupt signal from MFS ch.6.

MfsTx6 

Sending interrupt signal from MFS ch.6.

MfsRx7 

Receiving interrupt signal from MFS ch.7.

MfsTx7 

Sending interrupt signal from MFS ch.7.

ExtIrq0 

Interrupt signal from external interrupt unit ch.0.

ExtIrq1 

Interrupt signal from external interrupt unit ch.1.

ExtIrq2 

Interrupt signal from external interrupt unit ch.2.

ExtIrq3 

Interrupt signal from external interrupt unit ch.3.

Software 

Software Demand (just a high number)

Definition at line 147 of file dma.h.

DMA transfer data width.

Enumerator
DmaBlockTransfer 
DmaBurstTransfer 
DmaDemandTransfer 

Definition at line 125 of file dma.h.

DMA transfer data width.

Enumerator
Dma8Bit 

8 bit transfer via DMA

Dma16Bit 

16 bit transfer via DMA

Dma32Bit 

32 bit transfer via DMA

Definition at line 136 of file dma.h.

Function Documentation

en_result_t Dma_DeInit_Channel ( volatile stc_dma_config_t *  pstcConfig)

De-Initializes a DMA channel.

Clears an DMA channel.

Parameters
[in]pstcConfigDMA module configuration
Return values
Okinit successful
ErrorInvalidParameterpstcAdc == NULL or other invalid configuration

Definition at line 508 of file dma.c.

References stc_dma_intern_data::au8DmaChannelActive, DMA_CHANNEL_INACTIVE, DMA_DMACA_OFFSET, DMA_DMACB_OFFSET, DMA_DMADA_OFFSET, DMA_DMASA_OFFSET, Dma_Irq_DeInit(), ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, and stc_dma_config::u8DmaChannel.

Here is the call graph for this function:

en_result_t Dma_DeInit_ChannelParam ( uint8_t  u8DmaChannel)

De-Initializes a DMA channel via channel parameter.

Clears an DMA channel.

Parameters
[in]u8DmaChannelDMA channel to be de-initialized
Return values
Okinit successful

Definition at line 590 of file dma.c.

References stc_dma_intern_data::au8DmaChannelActive, DMA_CHANNEL_INACTIVE, DMA_DMACA_OFFSET, DMA_DMACB_OFFSET, DMA_DMADA_OFFSET, DMA_DMASA_OFFSET, Dma_Irq_DeInit(), GET_DMA_ADDRESS, and Ok.

Here is the call graph for this function:

en_result_t Dma_Disable ( void  )

Disable DMA globally.

Return values
OkDisable finished

Clear everything

Definition at line 489 of file dma.c.

References Ok.

en_result_t Dma_Enable ( void  )

Enable DMA globally.

Return values
OkEnable finished

Set DE Bit (DMA enable all channels)

Definition at line 475 of file dma.c.

References Ok.

en_result_t Dma_Init_Channel ( volatile stc_dma_config_t *  pstcConfig)

Initializes a DMA channel.

Sets up an DMA channel without starting immediate DMA transfer. Enable_Dma_Channel() is used for starting DMA transfer.

Parameters
[in]pstcConfigDMA module configuration
Return values
Okinit successful
ErrorInvalidParameterpstcAdc == NULL or other invalid configuration
OperationInProgressDMA channel already in use

Definition at line 283 of file dma.c.

References stc_dma_intern_data::apfnDmaCallback, stc_dma_intern_data::apfnDmaErrorCallback, stc_dma_intern_data::au8DmaChannelActive, stc_dma_config::bCompletionInterruptEnable, stc_dma_config::bEnableBitMask, stc_dma_config::bErrorInterruptEnable, stc_dma_config::bFixedDestination, stc_dma_config::bFixedSource, stc_dma_config::bReloadCount, stc_dma_config::bReloadDestination, stc_dma_config::bReloadSource, Dma16Bit, Dma32Bit, Dma8Bit, DMA_CHANNEL_ACTIVE, DMA_DMACA_OFFSET, DMA_DMACB_OFFSET, DMA_DMADA_OFFSET, DMA_DMASA_OFFSET, Dma_Irq_Init(), DmaBlockTransfer, DmaBurstTransfer, DmaDemandTransfer, stc_dma_config::enDmaIdrq, stc_dma_config::enTransferMode, stc_dma_config::enTransferWdith, ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, OperationInProgress, stc_dma_config::pfnCallback, stc_dma_config::pfnErrorCallback, Software, un_dmac_dmaca_t::stcDMACA, un_dmac_dmacb_t::stcDMACB, TRUE, stc_dma_config::u16TransferCount, stc_dma_config::u32DestinationAddress, un_dmac_dmaca_t::u32DMACA, un_dmac_dmacb_t::u32DMACB, stc_dma_config::u32SourceAddress, stc_dma_config::u8BlockCount, and stc_dma_config::u8DmaChannel.

Here is the call graph for this function:

static en_result_t Dma_Irq_DeInit ( uint8_t  u8DmaChannel)
static

De-Init DMA interrupt.

Sets up an DMA error/completion interrupt.

Parameters
[in]u8DmaChannelChannel number
Return values
Okde-init successful

Definition at line 219 of file dma.c.

References Ok, and PDL_DEFAULT_INTERRUPT_LEVEL.

Referenced by Dma_DeInit_Channel(), and Dma_DeInit_ChannelParam().

Here is the caller graph for this function:

static en_result_t Dma_Irq_Init ( uint8_t  u8DmaChannel)
static

Init DMA interrupt.

Sets up an DMA error/completion interrupt.

Parameters
[in]u8DmaChannelChannel number
Return values
Okinit successful

Definition at line 158 of file dma.c.

References Ok, PDL_DMA0_LEVEL, PDL_DMA1_LEVEL, PDL_DMA2_LEVEL, PDL_DMA3_LEVEL, PDL_DMA4_LEVEL, PDL_DMA5_LEVEL, PDL_DMA6_LEVEL, and PDL_DMA7_LEVEL.

Referenced by Dma_Init_Channel().

Here is the caller graph for this function:

en_result_t Dma_Set_Channel ( volatile stc_dma_config_t *  pstcConfig)

Enable, disable, pause, or trigger a DMA channel via configuration.

This function enables, disables, pauses or triggers a DMA transfer according to the settings in the configuration bits for EB (Enable), PB (Pause) and ST (Software Trigger)

Parameters
[in]pstcConfigDMA module configuration
Return values
OkSetting finished

Definition at line 441 of file dma.c.

References stc_dma_config::bEnable, stc_dma_config::bPause, stc_dma_config::bSoftwareTrigger, DMA_DMACA_OFFSET, ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, un_dmac_dmaca_t::stcDMACA, TRUE, un_dmac_dmaca_t::u32DMACA, and stc_dma_config::u8DmaChannel.

en_result_t Dma_Set_ChannelParam ( uint8_t  u8DmaChannel,
boolean_t  bEnable,
boolean_t  bPause,
boolean_t  bSoftwareTrigger 
)

Enable, disable, pause, or trigger a DMA channel via arguments.

This function enables, disables, pauses or triggers a DMA transfer according to the settings in the configuration bits for EB (Enable), PB (Pause) and ST (Software Trigger)

Parameters
[in]u8DmaChannelDMA channel to be set
[in]bEnableTRUE = Channel enabled, FALSE = Channel disabled
[in]bPauseTRUE = Channel paused, FALSE = Channel working
[in]bSoftwareTriggerTRUE = Channel trigger, FALSE = Channel no trigger
Return values
OkSetting finished

Definition at line 554 of file dma.c.

References DMA_DMACA_OFFSET, GET_DMA_ADDRESS, Ok, un_dmac_dmaca_t::stcDMACA, TRUE, and un_dmac_dmaca_t::u32DMACA.

void DmaIrqHandler ( uint8_t  u8DmaChannel)

DMA interrupt handler.

Parameters
[in]u8DmaChannelChannel number
Note
depending on the DMA stop status the DmaCallback function is called on successful transfer or DmaErrorCallback function on errornous transfer. The ErrorCallback has the error code as an (uint8_t) argument which reflects the 3 bits of the stop status.

Definition at line 119 of file dma.c.

References stc_dma_intern_data::apfnDmaCallback, stc_dma_intern_data::apfnDmaErrorCallback, DMA_DMACB_OFFSET, and GET_DMA_ADDRESS.

Variable Documentation

stc_dma_intern_data_t stcDmaInternData

Definition at line 75 of file dma.c.

stc_dma_intern_data_t stcDmaInternData

Definition at line 75 of file dma.c.