PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
Direct Memory Access (DMA)

Data Structures

union  un_dmac_dmaca_t
union  un_dmac_dmacb_t
struct  stc_dma_int_sel
 DMA interrupt selection. More...
struct  stc_dma_int_cb
 DMA interrupt callback function. More...
struct  stc_dma_intern_data
 Datatype for holding internal data needed for DMA. More...
struct  stc_dma_config
 DMA configuration. More...

Defines

#define GET_DMA_ADDRESS(x)   (FM0P_DMAC_BASE + (0x10ul * (x)) + 0x10ul)
#define DMA_CH_COUNT   (4u)
#define DMA_MAX_CH_INDEX   (3u)
#define DMA_DMACA_OFFSET   0x00ul
#define DMA_DMACB_OFFSET   0x04ul
#define DMA_DMASA_OFFSET   0x08ul
#define DMA_DMADA_OFFSET   0x0Cul

Typedefs

typedef enum en_dma_transfermode en_dma_transfermode_t
 DMA transfer data width.
typedef enum en_dma_transferwidth en_dma_transferwidth_t
 DMA transfer data width.
typedef enum en_dma_idreq en_dma_idreq_t
 DMA IDREQ number.
typedef enum dma_stop_cause en_dma_stop_cause_t
 DMA stop cause.
typedef struct stc_dma_int_sel stc_dma_int_sel_t
 DMA interrupt selection.
typedef struct stc_dma_int_cb stc_dma_int_cb_t
 DMA interrupt callback function.
typedef struct stc_dma_intern_data stc_dma_intern_data_t
 Datatype for holding internal data needed for DMA.
typedef struct stc_dma_config stc_dma_config_t
 DMA configuration.

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 {
  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...
enum  dma_stop_cause {
  DmaStopByAddrOverflow = 0, DmaStopByTransferStopRqst = 1, DmaStopBySrcAccessError = 2, DmaStopByDstAccessError = 3,
  DmaStopByTransferComplete = 4, DmaStopByTransferPause = 5
}
 DMA stop cause. More...

Functions

static en_result_t Dma_Irq_Init (uint8_t u8DmaChannel)
 Init DMA interrupt IRQ.
static en_result_t Dma_Irq_DeInit (uint8_t u8DmaChannel)
 De-Init DMA interrupt.
void DmaIrqHandler (uint8_t u8DmaChannel)
 DMA interrupt handler.
en_result_t Dma_EnableInt (uint8_t u8DmaChannel, stc_dma_int_sel_t *pstcIntSel, stc_dma_int_cb_t *pstcIntCb)
 Enable interrupt of a DMA channel.
en_result_t Dma_DisableInt (uint8_t u8DmaChannel, stc_dma_int_sel_t *pstcIntSel)
 Disable interrupt of a DMA channel.
en_result_t Dma_Init_Channel (uint8_t u8DmaChannel, volatile stc_dma_config_t *pstcConfig)
 Initializes a DMA channel.
en_result_t Dma_DeInit_Channel (uint8_t u8DmaChannel)
 De-Initializes a DMA channel.
en_result_t Dma_SetChannel (uint8_t u8DmaChannel, boolean_t bEnable, boolean_t bPause, boolean_t bSoftwareTrigger)
 Enable, disable, pause, or trigger a DMA channel via configuration.
en_dma_stop_cause_t Dma_GetStopCause (uint8_t u8DmaChannel)
 Read stop cause of a DMA channel.
en_result_t Dma_Enable (void)
 Enable DMA globally.
en_result_t Dma_Disable (void)
 Disable DMA globally.

Variables

static stc_dma_intern_data_t stcDmaInternData
 Store DMA internal data.
stc_dma_intern_data_t stcDmaInternData

Detailed Description

Provided functions of DMA module:

Dma_Init_Channel() initializes a DMA channel with the structure type stc_dma_config_t.

Dma_Init_Channel() resets a DMA channel to its initial status.

Dma_SetChannel() can enable/disable and triggers a channel by software.

Dma_GetStopCause() gets the DMA completion cause.

Dma_Enable() enables the entire DMA module and Dma_Disable() disables entire DMA module.


Define Documentation

#define DMA_CH_COUNT   (4u)

Definition at line 102 of file dma.h.

#define DMA_DMACA_OFFSET   0x00ul

Definition at line 106 of file dma.h.

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

#define DMA_DMADA_OFFSET   0x0Cul

Definition at line 109 of file dma.h.

Referenced by Dma_DeInit_Channel(), and Dma_Init_Channel().

#define DMA_DMASA_OFFSET   0x08ul

Definition at line 108 of file dma.h.

Referenced by Dma_DeInit_Channel(), and Dma_Init_Channel().

#define DMA_MAX_CH_INDEX   (3u)

Definition at line 103 of file dma.h.

Referenced by Dma_DisableInt(), and Dma_EnableInt().

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

Typedef Documentation

DMA IDREQ number.

DMA stop cause.

DMA transfer data width.

DMA transfer data width.

DMA configuration.

DMA interrupt callback function.

DMA interrupt selection.

Datatype for holding internal data needed for DMA.


Enumeration Type Documentation

DMA stop cause.

Enumerator:
DmaStopByAddrOverflow 

DMA stops by address overflow.

DmaStopByTransferStopRqst 

DMA stops by transfer stop request.

DmaStopBySrcAccessError 

DMA stops by source access error.

DmaStopByDstAccessError 

DMA stops by destination access error.

DmaStopByTransferComplete 

DMA stops by transfer completion.

DmaStopByTransferPause 

DMA stops by transfer pause.

Definition at line 177 of file dma.h.

DMA IDREQ number.

Enumerator:
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 141 of file dma.h.

DMA transfer data width.

Enumerator:
DmaBlockTransfer 

Block Transfer.

DmaBurstTransfer 

Burst transfer.

DmaDemandTransfer 

Demand transfer.

Definition at line 119 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 130 of file dma.h.


Function Documentation

en_result_t Dma_DeInit_Channel ( uint8_t  u8DmaChannel)

De-Initializes a DMA channel.

Clears an DMA channel.

Parameters:
[in]u8DmaChannelDMA channel number
Return values:
Okinit successful
ErrorInvalidParameterpstcAdc == NULL or other invalid configuration

Definition at line 487 of file dma.c.

References 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:

Disable DMA globally.

Return values:
OkDisable finished

Clear everything

Definition at line 592 of file dma.c.

References Ok.

en_result_t Dma_DisableInt ( uint8_t  u8DmaChannel,
stc_dma_int_sel_t pstcIntSel 
)

Disable interrupt of a DMA channel.

Parameters:
[in]u8DmaChannelDMA channel index
[in]pstcIntSelDMA interrupt selection structure
Return values:
OkInterrupt disabled normally
ErrorInvalidParameterIf one of following cases matchs:
  • u8DmaChannel > DMA_MAX_CH_INDEX
  • Other invalid configuration

Definition at line 308 of file dma.c.

References stc_dma_intern_data::apfnDmaCallback, stc_dma_intern_data::apfnDmaErrorCallback, stc_dma_int_sel::bCompleteInt, stc_dma_int_sel::bErrorInt, DMA_DMACB_OFFSET, Dma_Irq_DeInit(), DMA_MAX_CH_INDEX, ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, un_dmac_dmacb_t::stcDMACB, TRUE, and un_dmac_dmacb_t::u32DMACB.

Here is the call graph for this function:

en_result_t Dma_Enable ( void  )

Enable DMA globally.

Return values:
OkEnable finished

Set DE Bit (DMA enable all channels)

Definition at line 578 of file dma.c.

References Ok.

en_result_t Dma_EnableInt ( uint8_t  u8DmaChannel,
stc_dma_int_sel_t pstcIntSel,
stc_dma_int_cb_t pstcIntCb 
)

Enable interrupt of a DMA channel.

Enable interrupt and set interrupt callback function of a DMA channel

Parameters:
[in]u8DmaChannelDMA channel index
[in]pstcIntSelDMA interrupt selection structure
[in]pstcIntCbDMA interrupt callback function
Return values:
OkInterrupt enabled normally
ErrorInvalidParameterIf one of followng cases matchs:
  • u8DmaChannel > DMA_MAX_CH_INDEX
  • Other invalid configuration

Definition at line 257 of file dma.c.

References stc_dma_intern_data::apfnDmaCallback, stc_dma_intern_data::apfnDmaErrorCallback, stc_dma_int_sel::bCompleteInt, stc_dma_int_sel::bErrorInt, DMA_DMACB_OFFSET, Dma_Irq_Init(), DMA_MAX_CH_INDEX, ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, stc_dma_int_cb::pfnCompleteCallback, stc_dma_int_cb::pfnErrorCallback, un_dmac_dmacb_t::stcDMACB, TRUE, and un_dmac_dmacb_t::u32DMACB.

Here is the call graph for this function:

en_dma_stop_cause_t Dma_GetStopCause ( uint8_t  u8DmaChannel)

Read stop cause of a DMA channel.

Parameters:
[in]u8DmaChannelDMA channel
Return values:
DmaStopByAddrOverflowDMA stops by address overflow
DmaStopByTransferStopRqstDMA stops by transfer stop request
DmaStopBySrcAccessErrorDMA stops by source access error
DmaStopByDstAccessErrorDMA stops by destination access error
DmaStopByTransferCompleteDMA stops by transfer completion
DmaStopByTransferPauseDMA stops by transfer pause

Definition at line 558 of file dma.c.

References DMA_DMACB_OFFSET, GET_DMA_ADDRESS, un_dmac_dmacb_t::stcDMACB, and un_dmac_dmacb_t::u32DMACB.

en_result_t Dma_Init_Channel ( uint8_t  u8DmaChannel,
volatile stc_dma_config_t pstcConfig 
)

Initializes a DMA channel.

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

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

Definition at line 362 of file dma.c.

References stc_dma_config::bEnableBitMask, stc_dma_config::bFixedDestination, stc_dma_config::bFixedSource, stc_dma_config::bReloadCount, stc_dma_config::bReloadDestination, stc_dma_config::bReloadSource, Dma16Bit, Dma32Bit, Dma8Bit, DMA_DMACA_OFFSET, DMA_DMACB_OFFSET, DMA_DMADA_OFFSET, DMA_DMASA_OFFSET, DmaBlockTransfer, DmaBurstTransfer, DmaDemandTransfer, stc_dma_config::enDmaIdrq, stc_dma_config::enTransferMode, stc_dma_config::enTransferWdith, ErrorInvalidParameter, GET_DMA_ADDRESS, Ok, 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, and stc_dma_config::u8BlockCount.

static en_result_t Dma_Irq_DeInit ( uint8_t  u8DmaChannel) [static]

De-Init DMA interrupt.

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

Definition at line 203 of file dma.c.

References Ok, and PDL_DEFAULT_INTERRUPT_LEVEL.

Referenced by Dma_DeInit_Channel(), and Dma_DisableInt().

Here is the caller graph for this function:

static en_result_t Dma_Irq_Init ( uint8_t  u8DmaChannel) [static]

Init DMA interrupt IRQ.

Parameters:
[in]u8DmaChannelChannel number
Return values:
Okinit successful

Definition at line 164 of file dma.c.

References Ok, PDL_IRQ_LEVEL_MFS6_14_RX_DMA0, PDL_IRQ_LEVEL_MFS6_14_TX_DMA1, PDL_IRQ_LEVEL_MFS7_15_RX_DMA2, and PDL_IRQ_LEVEL_MFS7_15_TX_DMA3.

Referenced by Dma_EnableInt().

Here is the caller graph for this function:

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

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]u8DmaChannelDMA channel number
[in]bEnableEnable the channel or not
[in]bPausePause the channel or not
[in]bSoftwareTriggerTrigger DMA by software or not
Return values:
OkSetting finished

Definition at line 520 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 127 of file dma.c.

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

Referenced by MFS6_14_RX_DMA0_IRQHandler(), MFS6_14_TX_DMA1_IRQHandler(), MFS7_15_RX_DMA2_IRQHandler(), and MFS7_15_TX_DMA3_IRQHandler().

Here is the caller graph for this function:


Variable Documentation

Store DMA internal data.

Definition at line 78 of file dma.c.