This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.
|
enum | { kStatus_DMA_ChannelBusy = MAKE_STATUS(kStatusGroup_DMA, 0)
} |
| _dma_channeltransfer_status DMA transfer status More...
|
|
enum | dma_channel_transfer_type_t {
kDMA_ChannelTransferMemoryToMemory = 0x0U,
kDMA_ChannelTransferPeripheralToMemory,
kDMA_ChannelTransferMemoryToPeripheral
} |
| DMA channel transfer type. More...
|
|
enum | _dma_channel_interrupt_enable { kDMA_ChannelInterruptEnable
} |
| DMA interrupt source. More...
|
|
enum | _dma_channel_status_flags {
kDMA_ChannelTransactionsBCRFlag = DMA_DSR_BCR_BCR_MASK,
kDMA_ChannelTransactionsDoneFlag = DMA_DSR_BCR_DONE_MASK,
kDMA_ChannelTransactionsBusyFlag = DMA_DSR_BCR_BSY_MASK,
kDMA_ChannelTransactionsRequestFlag = DMA_DSR_BCR_REQ_MASK
} |
| _dma_channel_status_flags DMA channel status flags. More...
|
|
enum | _dma_error_status_flags {
kDMA_ChannelConfigurationErrorFlag,
kDMA_ChannelBusErrorOnSourceFlag,
kDMA_ChannelBusErrorOnDestinatiFlag
} |
| _dma_error_status_flags DMA channel detail error status flags. More...
|
|
enum | dma_channel_t {
kDMA_Channel0 = 0U,
kDMA_Channel1 = 1U,
kDMA_Channel2 = 2U,
kDMA_Channel3 = 3U
} |
| DMA channel index. More...
|
|
enum | dma_channel_transfer_width_t {
kDMA_ChannelTransferWidth32Bits = 0x0U,
kDMA_ChannelTransferWidth8Bits,
kDMA_ChannelTransferWidth16Bits
} |
| DMA transfer width configuration. More...
|
|
enum | dma_channel_modulo_t {
kDMA_ChannelModuloDisable = 0x0U,
kDMA_ChannelModulo16bytes,
kDMA_ChannelModulo32bytes,
kDMA_ChannelModulo64bytes,
kDMA_ChannelModulo128bytes,
kDMA_ChannelModulo256bytes,
kDMA_ChannelModulo512bytes,
kDMA_ChannelModulo1Kbytes,
kDMA_ChannelModulo2Kbytes,
kDMA_ChannelModulo4Kbytes,
kDMA_ChannelModulo8Kbytes,
kDMA_ChannelModulo16Kbytes,
kDMA_ChannelModulo32Kbytes,
kDMA_ChannelModulo64Kbytes,
kDMA_ChannelModulo128Kbytes,
kDMA_ChannelModulo256Kbytes
} |
| DMA channel modulo configuration. More...
|
|
enum | dma_channel_link_type_t {
kDMA_ChannelLinkDisable = 0x0U,
kDMA_ChannelLinkChannel1AndChannel2,
kDMA_ChannelLinkChannel1,
kDMA_ChannelLinkChannel1AfterBCR0
} |
| DMA channel link type. More...
|
|
enum | dma_channel_address_increment_type_t {
kDMA_ChannelAddressFix = 0x0U,
kDMA_ChannelAddressIncrement = 0x1U
} |
| DMA transfer address increment definition. More...
|
|
|
void | DMA_ResetChannel (DMA_Type *base, dma_channel_t eChannel) |
| Resets the DMA channel. More...
|
|
void | DMA_GetChannelDefaultTransferConfig (dma_channel_transfer_config_t *psTransfer, uint32_t u32SrcAddr, uint32_t u32DstAddr, uint32_t u32TotalBytes, dma_channel_transfer_width_t eTransferWidth, dma_channel_transfer_type_t eTransferType) |
| Get channel default transfer configuration. More...
|
|
void | DMA_SetChannelTransferConfig (DMA_Type *base, dma_channel_t eChannel, dma_channel_transfer_config_t *psTransfer) |
| DMA set channel transfer configurations. More...
|
|
void | DMA_SetChannelLinkConfig (DMA_Type *base, dma_channel_t eChannel, dma_channel_link_config_t *pLinkConfig) |
| Configures the DMA channel link feature. More...
|
|
static void | DMA_SetChannelSourceAddress (DMA_Type *base, dma_channel_t eChannel, uint32_t u32SrcAddr) |
| Sets the DMA source address for the DMA transfer. More...
|
|
static void | DMA_SetChannelDestinationAddress (DMA_Type *base, dma_channel_t eChannel, uint32_t u32DestAddr) |
| Sets the DMA destination address for the DMA transfer. More...
|
|
static void | DMA_SetChannelTransferSize (DMA_Type *base, dma_channel_t eChannel, uint32_t u32TransferSize) |
| Sets the DMA transfer size for the DMA transfer. More...
|
|
void | DMA_SetChannelPeripheralRequest (DMA_Type *base, dma_channel_t eChannel, dma_channel_request_source_t eChannelRequestSource) |
| Sets the DMA transfer peripheral number for the DMA transfer. More...
|
|
void | DMA_SetChannelModulo (DMA_Type *base, dma_channel_t eChannel, dma_channel_modulo_t eSrcModulo, dma_channel_modulo_t eDestModulo) |
| Sets the source address range and the destination address range for the DMA transfer. More...
|
|
static void | DMA_EnableChannelCycleSteal (DMA_Type *base, dma_channel_t eChannel, bool bEnable) |
| Enables the DMA cycle steal for the DMA transfer. More...
|
|
static void | DMA_EnableChannelAutoAlign (DMA_Type *base, dma_channel_t eChannel, bool bEnable) |
| Enables the DMA auto align for the DMA transfer. More...
|
|
struct dma_channel_link_config_t |
struct dma_channel_transfer_config_t |
The transfer configuration structure support full feature configuration of the transfer control descriptor.
bool dma_channel_transfer_config_t::bEnablAutoStopPeripheralRequest |
This structure target for whole dma module configurations.
void* dma_handle_t::pUserData |
DMA_Type* dma_handle_t::psBase |
typedef void(* dma_transfer_callback_t)(dma_handle_t *psHandle, void *pUserData) |
This callback function is called in the DMA interrupt handler function. In normal mode, running into callback function means the transfer users need is done.
- Parameters
-
psHandle | DMA handle pointer, users shall not touch the values inside. |
pUserData | The callback user parameter pointer. Users can use this parameter to involve things users need to change in DMA callback function. |
The enumerator used for transactional interface only.
Enumerator |
---|
kStatus_DMA_ChannelBusy |
Channel is busy and can't handle the transfer request.
|
Enumerator |
---|
kDMA_ChannelTransferMemoryToMemory |
Transfer type from memory to memory assume that the both source and destination address are incremental.
|
kDMA_ChannelTransferPeripheralToMemory |
Transfer type peripher to memory assume that the source address is fixed.
|
kDMA_ChannelTransferMemoryToPeripheral |
Transfer type from memory to peripheral assume that the destination address is fixed.
|
Enumerator |
---|
kDMA_ChannelInterruptEnable |
Enable interrupt while transfer complete.
|
Enumerator |
---|
kDMA_ChannelTransactionsBCRFlag |
Contains the number of bytes yet to be transferred for a given block.
|
kDMA_ChannelTransactionsDoneFlag |
Transactions Done.
|
kDMA_ChannelTransactionsBusyFlag |
Transactions Busy.
|
kDMA_ChannelTransactionsRequestFlag |
Transactions Request.
|
Enumerator |
---|
kDMA_ChannelConfigurationErrorFlag |
Any of the following conditions causes a configuration error: BCR, SAR, or DAR does not match the requested transfer size.
SSIZE or DSIZE is set to an unsupported value. BCR equals 0 when the DMA receives a start condition. CE is cleared at hardware reset or by writing a 1 to DONE.
|
kDMA_ChannelBusErrorOnSourceFlag |
BES is cleared at hardware reset or by writing a 1 to DONE.
|
kDMA_ChannelBusErrorOnDestinatiFlag |
BED is cleared at hardware reset or by writing a 1 to DONE.
|
Enumerator |
---|
kDMA_Channel0 |
DMA channel 0.
|
kDMA_Channel1 |
DMA channel 1.
|
kDMA_Channel2 |
DMA channel 2.
|
kDMA_Channel3 |
DMA channel 3.
|
Enumerator |
---|
kDMA_ChannelTransferWidth32Bits |
Source/Destination data transfer width is 4 byte every time.
|
kDMA_ChannelTransferWidth8Bits |
Source/Destination data transfer width is 1 bytes every time.
|
kDMA_ChannelTransferWidth16Bits |
Source/Destination data transfer width is 2 bytes every time.
|
The DMA modulo feature can be used to specify the address range of the source/destination address, it is useful to implement a circular data queue.
Enumerator |
---|
kDMA_ChannelModuloDisable |
Disable modulo.
|
kDMA_ChannelModulo16bytes |
Circular buffer size is 16 bytes.
|
kDMA_ChannelModulo32bytes |
Circular buffer size is 32 bytes.
|
kDMA_ChannelModulo64bytes |
Circular buffer size is 64 bytes.
|
kDMA_ChannelModulo128bytes |
Circular buffer size is 128 bytes.
|
kDMA_ChannelModulo256bytes |
Circular buffer size is 256 bytes.
|
kDMA_ChannelModulo512bytes |
Circular buffer size is 512 bytes.
|
kDMA_ChannelModulo1Kbytes |
Circular buffer size is 1 K bytes.
|
kDMA_ChannelModulo2Kbytes |
Circular buffer size is 2 K bytes.
|
kDMA_ChannelModulo4Kbytes |
Circular buffer size is 4 K bytes.
|
kDMA_ChannelModulo8Kbytes |
Circular buffer size is 8 K bytes.
|
kDMA_ChannelModulo16Kbytes |
Circular buffer size is 16 K bytes.
|
kDMA_ChannelModulo32Kbytes |
Circular buffer size is 32 K bytes.
|
kDMA_ChannelModulo64Kbytes |
Circular buffer size is 64 K bytes.
|
kDMA_ChannelModulo128Kbytes |
Circular buffer size is 128 K bytes.
|
kDMA_ChannelModulo256Kbytes |
Circular buffer size is 256 K bytes.
|
Enumerator |
---|
kDMA_ChannelLinkDisable |
No channel link.
|
kDMA_ChannelLinkChannel1AndChannel2 |
Perform a link to channel LCH1 after each cycle-steal transfer.
followed by a link to LCH2 after the BCR decrements to 0.
|
kDMA_ChannelLinkChannel1 |
Perform a link to LCH1 after each cycle-steal transfer.
|
kDMA_ChannelLinkChannel1AfterBCR0 |
Perform a link to LCH1 after the BCR decrements.
|
Enumerator |
---|
kDMA_ChannelAddressFix |
Address Fix.
|
kDMA_ChannelAddressIncrement |
Address increment.
|
- Parameters
-
base | DMA peripheral base address. |
psConfig | pointer to user's DMA configure structure, see dma_config_t for detail. |
void DMA_Deinit |
( |
DMA_Type * |
base | ) |
|
- Parameters
-
base | DMA peripheral base address. |
void DMA_ResetChannel |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel |
|
) |
| |
Sets all register values to reset values and enables the cycle steal and auto stop channel request features.
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
- Note
- 1. This function will reset all of the configuration structure members to zero firstly, then apply default configurations to the structure.
- No interrupt enabled by this function by default, if application would like to use DMA interrupt please enable it manually by psTransfer->u16EnabledInterruptMask = _dma_channel_interrupt
- Parameters
-
psTransfer | pointer to user's DMA channel configure structure, see dma_channel_transfer_config_t for detail. |
u32SrcAddr | source address, must be byte address. |
u32DstAddr | destination address, must be byte address. |
u32TotalBytes | total bytes to be transferred. |
eTransferWidth | it represents how many bits are transferred in each read/write. |
eTransferType | DMA channel transfer type. |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
psTransfer | pointer to user's DMA channel configure structure, see dma_channel_transfer_config_t for detail. |
This function allows DMA channels to have their transfers linked. The current DMA channel triggers a DMA request to the linked channels (LCH1 or LCH2) depending on the channel link type. Perform a link to channel LCH1 after each cycle-steal transfer followed by a link to LCH2 after the BCR decrements to 0 if the type is kDMA_ChannelLinkChannel1AndChannel2. Perform a link to LCH1 after each cycle-steal transfer if the type is kDMA_ChannelLinkChannel1. Perform a link to LCH1 after the BCR decrements to 0 if the type is kDMA_ChannelLinkChannel1AfterBCR0.
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
pLinkConfig | Pointer to the channel link configuration structure. |
static void DMA_SetChannelSourceAddress |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
uint32_t |
u32SrcAddr |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
u32SrcAddr | DMA source address. |
static void DMA_SetChannelDestinationAddress |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
uint32_t |
u32DestAddr |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
u32DestAddr | DMA destination address. |
static void DMA_SetChannelTransferSize |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
uint32_t |
u32TransferSize |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
u32TransferSize | The number of bytes to be transferred. |
void DMA_SetChannelPeripheralRequest |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
dma_channel_request_source_t |
eChannelRequestSource |
|
) |
| |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
eChannelRequestSource | The number of request source. |
This function defines a specific address range of source/destination address, after the source/destination address hits the range boundary, source/destination address will wrap to origin value.
Setting this field provides the ability to implement a circular data queue easily. For data queues require loop power-of-2 size bytes, the queue should start at a 0-modulo-size address and the SMOD field should be set to the appropriate value for the queue, freezing the desired number of upper address bits. The value programmed into this field specifies the number of lower address bits allowed to change
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
eSrcModulo | A source modulo value. |
eDestModulo | A destination modulo value. |
static void DMA_EnableChannelCycleSteal |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
If the cycle steal feature is enabled (true), the DMA controller forces a single read/write transfer per request, or it continuously makes read/write transfers until the BCR decrements to 0.
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
bEnable | The command for enable (true) or disable (false). |
static void DMA_EnableChannelAutoAlign |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
If the auto align feature is enabled (true), the appropriate address register increments regardless of DINC or SINC.
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
bEnable | The command for enable (true) or disable (false). |
static void DMA_EnableChannelInterrupt |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
bEnable | The command for enable (true) or disable (false). |
static void DMA_EnableChannelPeripheralRequest |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | The DMA channel number. |
bEnable | The command for enable (true) or disable (false). |
static void DMA_TriggerChannelStart |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel |
|
) |
| |
|
inlinestatic |
This function starts only one read/write iteration.
- Parameters
-
base | DMA peripheral base address. |
eChannel | The DMA channel number. |
static void DMA_EnableChannelAutoStopRequest |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | The DMA channel number. |
bEnable | true is enable, false is disable. |
static uint32_t DMA_GetChannelRemainingBytes |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
- Returns
- The number of bytes which have not been transferred yet.
static uint32_t DMA_GetChannelStatusFlags |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
- Returns
- The mask of the channel status. Use the _dma_channel_status_flags type to decode the return 32 bit variables.
static void DMA_ClearChannelDoneStatus |
( |
DMA_Type * |
base, |
|
|
dma_channel_t |
eChannel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DMA peripheral base address. |
eChannel | DMA channel number. |
This function is called first if using the transactional API for the DMA. This function initializes the internal state of the DMA handle.
- Parameters
-
base | DMA peripheral base address. |
psHandle | DMA handle pointer. The DMA handle stores callback function and parameters. |
eChannel | DMA channel number. |
pfCallback | DMA callback function pointer. |
pUserData | A parameter for the callback function. |
This function submits the DMA transfer request according to the transfer configuration structure.
- Parameters
-
psHandle | DMA handle pointer. |
psTransfer | Pointer to DMA transfer configuration structure. |
- Return values
-
kStatus_DMA_Success | It indicates that the DMA submit transfer request succeeded. |
kStatus_DMA_ChannelBusy | It indicates that the DMA is busy. Submit transfer request is not allowed. |
- Note
- This function can't process multi transfer request.
void DMA_TransferChannelStart |
( |
dma_handle_t * |
psHandle, |
|
|
bool |
bIsPeripheral |
|
) |
| |
This function enables the channel request. Call this function after submitting a transfer request.
- Parameters
-
psHandle | DMA handle pointer. |
bIsPeripheral | For true: enable DMA hardware request peripheral. For false: disable DMA hardware request peripheral. |
void DMA_TransferChannelStop |
( |
dma_handle_t * |
psHandle | ) |
|
This function disables the channel request to stop a DMA transfer. The transfer can be resumed by calling the DMA_StartTransfer.
- Parameters
-
psHandle | DMA handle pointer. |
void DMA_TransferChannelAbort |
( |
dma_handle_t * |
psHandle | ) |
|
This function disables the channel request and clear transfer status bits. Users can submit another transfer after calling this API.
- Parameters
-
psHandle | DMA handle pointer. |
void DMA_TransferChannelHandleIRQ |
( |
dma_handle_t * |
psHandle | ) |
|
This function clears the channel interrupt flag and calls the callback function if it is not NULL.
- Parameters
-
psHandle | DMA handle pointer. |