bf0_hal_dma.h

Header file of DMA HAL module.

Author

Sifli software development team

Attention

Defines

DMA_SUPPORT_DYN_CHANNEL_ALLOC
HAL_DMA_ERROR_NONE

No error

HAL_DMA_ERROR_TE

Transfer error

HAL_DMA_ERROR_NO_XFER

Abort requested with no Xfer ongoing

HAL_DMA_ERROR_TIMEOUT

Timeout error

HAL_DMA_ERROR_NOT_SUPPORTED

Not supported mode

HAL_DMA_ERROR_SYNC

DMAMUX sync overrun error

HAL_DMA_ERROR_REQGEN

DMAMUX request generator overrun error

DMA_REQUEST_0
DMA_REQUEST_1
DMA_REQUEST_2
DMA_REQUEST_3
DMA_REQUEST_4
DMA_REQUEST_5
DMA_REQUEST_6
DMA_REQUEST_7
DMA_REQUEST_8
DMA_REQUEST_9
DMA_REQUEST_10
DMA_REQUEST_11
DMA_REQUEST_12
DMA_REQUEST_13
DMA_REQUEST_14
DMA_REQUEST_15
DMA_REQUEST_16
DMA_REQUEST_17
DMA_REQUEST_18
DMA_REQUEST_19
DMA_REQUEST_20
DMA_REQUEST_21
DMA_REQUEST_22
DMA_REQUEST_23
DMA_REQUEST_24
DMA_REQUEST_25
DMA_REQUEST_26
DMA_REQUEST_27
DMA_REQUEST_28
DMA_REQUEST_29
DMA_REQUEST_30
DMA_REQUEST_31
DMA_REQUEST_32
DMA_REQUEST_33
DMA_REQUEST_34
DMA_REQUEST_35
DMA_REQUEST_36
DMA_REQUEST_37
DMA_REQUEST_38
DMA_REQUEST_39
DMA_REQUEST_40
DMA_REQUEST_41
DMA_REQUEST_42
DMA_REQUEST_43
DMA_REQUEST_44
DMA_REQUEST_45
DMA_REQUEST_46
DMA_REQUEST_47
DMA_REQUEST_48
DMA_REQUEST_49
DMA_REQUEST_50
DMA_REQUEST_51
DMA_REQUEST_52
DMA_REQUEST_53
DMA_REQUEST_54
DMA_REQUEST_55
DMA_REQUEST_56
DMA_REQUEST_57
DMA_REQUEST_58
DMA_REQUEST_59
DMA_REQUEST_60
DMA_REQUEST_61
DMA_REQUEST_62
DMA_REQUEST_63
MAX_DMA_CHANNEL
DMA_PERIPH_TO_MEMORY

Peripheral to memory direction

DMA_MEMORY_TO_PERIPH

Memory to peripheral direction

DMA_MEMORY_TO_MEMORY

Memory to memory direction

DMA_PINC_ENABLE

Peripheral increment mode Enable

DMA_PINC_DISABLE

Peripheral increment mode Disable

DMA_MINC_ENABLE

Memory increment mode Enable

DMA_MINC_DISABLE

Memory increment mode Disable

DMA_PDATAALIGN_BYTE

Peripheral data alignment : Byte

DMA_PDATAALIGN_HALFWORD

Peripheral data alignment : HalfWord

DMA_PDATAALIGN_WORD

Peripheral data alignment : Word

DMA_MDATAALIGN_BYTE

Memory data alignment : Byte

DMA_MDATAALIGN_HALFWORD

Memory data alignment : HalfWord

DMA_MDATAALIGN_WORD

Memory data alignment : Word

DMA_NORMAL

Normal mode

DMA_CIRCULAR

Circular mode

DMA_PRIORITY_LOW

Priority level : Low

DMA_PRIORITY_MEDIUM

Priority level : Medium

DMA_PRIORITY_HIGH

Priority level : High

DMA_PRIORITY_VERY_HIGH

Priority level : Very_High

DMA_IT_TC
DMA_IT_HT
DMA_IT_TE
DMA_FLAG_GL1
DMA_FLAG_TC1
DMA_FLAG_HT1
DMA_FLAG_TE1
DMA_FLAG_GL2
DMA_FLAG_TC2
DMA_FLAG_HT2
DMA_FLAG_TE2
DMA_FLAG_GL3
DMA_FLAG_TC3
DMA_FLAG_HT3
DMA_FLAG_TE3
DMA_FLAG_GL4
DMA_FLAG_TC4
DMA_FLAG_HT4
DMA_FLAG_TE4
DMA_FLAG_GL5
DMA_FLAG_TC5
DMA_FLAG_HT5
DMA_FLAG_TE5
DMA_FLAG_GL6
DMA_FLAG_TC6
DMA_FLAG_HT6
DMA_FLAG_TE6
DMA_FLAG_GL7
DMA_FLAG_TC7
DMA_FLAG_HT7
DMA_FLAG_TE7
__HAL_DMA_RESET_HANDLE_STATE(__HANDLE__)

Reset DMA handle state.

参数:
  • __HANDLE__ – DMA handle

返回值:

None

__HAL_DMA_ENABLE(__HANDLE__)

Enable the specified DMA Channel.

参数:
  • __HANDLE__ – DMA handle

返回值:

None

__HAL_DMA_DISABLE(__HANDLE__)

Disable the specified DMA Channel.

参数:
  • __HANDLE__ – DMA handle

返回值:

None

__HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__)

Return the current DMA Channel transfer complete flag.

参数:
  • __HANDLE__ – DMA handle

返回值:

The – specified transfer complete flag index.

__HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)

Return the current DMA Channel half transfer complete flag.

参数:
  • __HANDLE__ – DMA handle

返回值:

The – specified half transfer complete flag index.

__HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)

Return the current DMA Channel transfer error flag.

参数:
  • __HANDLE__ – DMA handle

返回值:

The – specified transfer error flag index.

__HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)

Return the current DMA Channel Global interrupt flag.

参数:
  • __HANDLE__ – DMA handle

返回值:

The – specified transfer error flag index.

__HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)

Get the DMA Channel pending flags.

参数:
  • __HANDLE__ – DMA handle

  • __FLAG__ – Get the specified flag. This parameter can be any combination of the following values:

    • DMA_FLAG_TCx: Transfer complete flag

    • DMA_FLAG_HTx: Half transfer complete flag

    • DMA_FLAG_TEx: Transfer error flag

    • DMA_FLAG_GLx: Global interrupt flag Where x can be from 1 to 7 to select the DMA Channel x flag.

返回值:

The – state of FLAG (SET or RESET).

__HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__)

Clear the DMA Channel pending flags.

参数:
  • __HANDLE__ – DMA handle

  • __FLAG__ – specifies the flag to clear. This parameter can be any combination of the following values:

    • DMA_FLAG_TCx: Transfer complete flag

    • DMA_FLAG_HTx: Half transfer complete flag

    • DMA_FLAG_TEx: Transfer error flag

    • DMA_FLAG_GLx: Global interrupt flag Where x can be from 1 to 7 to select the DMA Channel x flag.

返回值:

None

__HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__)

Enable the specified DMA Channel interrupts.

参数:
  • __HANDLE__ – DMA handle

  • __INTERRUPT__ – specifies the DMA interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:

    • DMA_IT_TC: Transfer complete interrupt mask

    • DMA_IT_HT: Half transfer complete interrupt mask

    • DMA_IT_TE: Transfer error interrupt mask

返回值:

None

__HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__)

Disable the specified DMA Channel interrupts.

参数:
  • __HANDLE__ – DMA handle

  • __INTERRUPT__ – specifies the DMA interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:

    • DMA_IT_TC: Transfer complete interrupt mask

    • DMA_IT_HT: Half transfer complete interrupt mask

    • DMA_IT_TE: Transfer error interrupt mask

返回值:

None

__HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)

Check whether the specified DMA Channel interrupt is enabled or not.

参数:
  • __HANDLE__ – DMA handle

  • __INTERRUPT__ – specifies the DMA interrupt source to check. This parameter can be one of the following values:

    • DMA_IT_TC: Transfer complete interrupt mask

    • DMA_IT_HT: Half transfer complete interrupt mask

    • DMA_IT_TE: Transfer error interrupt mask

返回值:

The – state of DMA_IT (SET or RESET).

__HAL_DMA_GET_COUNTER(__HANDLE__)

Return the number of remaining data units in the current DMA Channel transfer.

参数:
  • __HANDLE__ – DMA handle

返回值:

The – number of remaining data units in the current DMA Channel transfer.

__HAL_DMA_SET_COUNTER(__HANDLE__, __DATA_COUNTS__)

restart the current DMA Channel transfer.

参数:
  • __HANDLE__ – DMA handle

  • __DATA_COUNTS__ – number of data to transfer (0 to 2^16 - 1)

返回值:

None.

__HAL_DMA_SET_CIRCLUAR_MODE(__HANDLE__, __CIRCLUAR_MODE__)

Set circular mode for the current DMA Channel transfer.

参数:
  • __HANDLE__ – DMA handle

  • __CIRCLUAR_MODE__ – Circluar mode, 0 disable, 1 enable

返回值:

None.

__HAL_DMA_CLEAR_CIRCLUAR_MODE(__HANDLE__, __CIRCLUAR_MODE__)

Clear circular mode for the current DMA Channel transfer.

参数:
  • __HANDLE__ – DMA handle

  • __CIRCLUAR_MODE__ – Circluar mode, 0 disable, 1 enable

返回值:

None.

IS_DMA_DIRECTION(DIRECTION)
IS_DMA_BUFFER_SIZE(SIZE)
IS_DMA_PERIPHERAL_INC_STATE(STATE)
IS_DMA_MEMORY_INC_STATE(STATE)
IS_DMA_ALL_REQUEST(REQUEST)
IS_DMA_PERIPHERAL_DATA_SIZE(SIZE)
IS_DMA_MEMORY_DATA_SIZE(SIZE)
IS_DMA_MODE(MODE)
IS_DMA_PRIORITY(PRIORITY)
IS_DMA_ALL_INSTANCE(__INSTANCE__)
DMA_1M_BOUNDARY_MASK
DMA_1M_LEN
IS_DMA_ACCROSS_1M_BOUNDARY(addr, size)

Typedefs

typedef struct __DMA_HandleTypeDef DMA_HandleTypeDef

DMA handle Structure definition.

Enums

enum HAL_DMA_StateTypeDef

HAL DMA State structures definition.

Values:

enumerator HAL_DMA_STATE_RESET

DMA not yet initialized or disabled

enumerator HAL_DMA_STATE_READY

DMA initialized and ready for use

enumerator HAL_DMA_STATE_BUSY

DMA process is ongoing

enumerator HAL_DMA_STATE_TIMEOUT

DMA timeout state

enum HAL_DMA_LevelCompleteTypeDef

HAL DMA Error Code structure definition.

Values:

enumerator HAL_DMA_FULL_TRANSFER

Full transfer

enumerator HAL_DMA_HALF_TRANSFER

Half Transfer

enum HAL_DMA_CallbackIDTypeDef

HAL DMA Callback ID structure definition.

Values:

enumerator HAL_DMA_XFER_CPLT_CB_ID

Full transfer

enumerator HAL_DMA_XFER_HALFCPLT_CB_ID

Half transfer

enumerator HAL_DMA_XFER_ERROR_CB_ID

Error

enumerator HAL_DMA_XFER_ABORT_CB_ID

Abort

enumerator HAL_DMA_XFER_ALL_CB_ID

All

Functions

HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)

Initialize the DMA according to the specified parameters in the DMA_InitTypeDef and initialize the associated handle.

参数:
  • hdma – Pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)

DeInitialize the DMA peripheral.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t Counts)

Start the DMA Transfer.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

  • SrcAddress – The source memory Buffer address

  • DstAddress – The destination memory Buffer address

  • Counts – The counts of data transfer action

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t Counts)

Start the DMA Transfer with interrupt enabled.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

  • SrcAddress – The source memory Buffer address

  • DstAddress – The destination memory Buffer address

  • Counts – The counts of data transfer action

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)

Abort the DMA Transfer.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)

Aborts the DMA Transfer in Interrupt mode.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout)

Polling for transfer complete.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

  • CompleteLevel – Specifies the DMA level complete.

  • Timeout – Timeout duration.

返回值:

HAL – status

void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)

Handle DMA interrupt request.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

None

void HAL_DMAC1_CH1_IRQHandler(void)
void HAL_DMAC1_CH2_IRQHandler(void)
void HAL_DMAC1_CH3_IRQHandler(void)
void HAL_DMAC1_CH4_IRQHandler(void)
void HAL_DMAC1_CH5_IRQHandler(void)
void HAL_DMAC1_CH6_IRQHandler(void)
void HAL_DMAC1_CH7_IRQHandler(void)
void HAL_DMAC1_CH8_IRQHandler(void)
void HAL_DMAC2_CH1_IRQHandler(void)
void HAL_DMAC2_CH2_IRQHandler(void)
void HAL_DMAC2_CH3_IRQHandler(void)
void HAL_DMAC2_CH4_IRQHandler(void)
void HAL_DMAC2_CH5_IRQHandler(void)
void HAL_DMAC2_CH6_IRQHandler(void)
void HAL_DMAC2_CH7_IRQHandler(void)
void HAL_DMAC2_CH8_IRQHandler(void)
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (*pCallback)(DMA_HandleTypeDef *_hdma))

Register callbacks.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

  • CallbackID – User Callback identifer a HAL_DMA_CallbackIDTypeDef ENUM as parameter.

  • pCallback – pointer to private callbacsk function which has pointer to a DMA_HandleTypeDef structure as parameter.

返回值:

HAL – status

HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID)

UnRegister callbacks.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

  • CallbackID – User Callback identifer a HAL_DMA_CallbackIDTypeDef ENUM as parameter.

返回值:

HAL – status

void HAL_DMA_Select_Source(DMA_Channel_TypeDef *dma_chl, uint8_t request)
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)

Return the DMA hande state.

参数:
  • hdma – pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

HAL – state

uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)

Return the DMA error code.

参数:
  • hdma – : pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel.

返回值:

DMA – Error Code

struct dma_config

Public Members

DMA_Channel_TypeDef *Instance

DMA HW low layer handle

uint32_t dma_irq_prio

DMA interrupt priority

IRQn_Type dma_irq

DMA interrupt number

uint32_t request

DMA request number

struct DMA_InitTypeDef
#include <bf0_hal_dma.h>

DMA Configuration Structure definition.

Public Members

uint32_t Request

Specifies the request selected for the specified channel. This parameter can be a value of DMA request

uint32_t Direction

Specifies if the data will be transferred from memory to peripheral, from memory to memory or from peripheral to memory. This parameter can be a value of DMA Data transfer direction

uint32_t PeriphInc

Specifies whether the Peripheral address register should be incremented or not. This parameter can be a value of DMA Peripheral incremented mode

uint32_t MemInc

Specifies whether the memory address register should be incremented or not. This parameter can be a value of DMA Memory incremented mode

uint32_t PeriphDataAlignment

Specifies the Peripheral data width. This parameter can be a value of DMA Peripheral data size

uint32_t MemDataAlignment

Specifies the Memory data width. This parameter can be a value of DMA Memory data size

uint32_t Mode

Specifies the operation mode of the DMAy Channelx. This parameter can be a value of DMA mode

备注

The circular buffer mode cannot be used if the memory-to-memory data transfer is configured on the selected Channel

uint32_t Priority

Specifies the software priority for the DMAy Channelx. This parameter can be a value of DMA Priority level

uint32_t BurstSize

Specifies the burst size in non-m2m mode When BS>1, DMA will transfer for BS times for each request if left NDT is larger than BS, or else transfer for left NDT times. When BS=0 or 1, DMA will always do single transfer for each request. In memory-to-memory mode, BS is ignored.

uint32_t IrqPrio

Interrupt Priority

struct __DMA_HandleTypeDef
#include <bf0_hal_dma.h>

DMA handle Structure definition.

Public Members

DMA_Channel_TypeDef *Instance

Register base address

DMA_InitTypeDef Init

DMA communication parameters

HAL_LockTypeDef Lock

DMA locking object

HAL_DMA_StateTypeDef State

DMA transfer state

void *Parent

Parent object state

void (*XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)

DMA transfer complete callback

void (*XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma)

DMA Half transfer complete callback

void (*XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)

DMA transfer error callback

void (*XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)

DMA transfer abort callback

uint32_t ErrorCode

DMA Error code

DMAC_TypeDef *DmaBaseAddress

DMA Channel Base Address

uint32_t ChannelIndex

DMA Channel Index

uint32_t LeftCounts
uint32_t TotalCounts
uint32_t TransCounts
uint32_t SrcAddress
uint32_t DstAddress
uint8_t SrcInc
uint8_t DstInc
uint8_t SrcWidth

Src width, 0: 1 byte, 1: 2bytes, 2: 4bytes

uint8_t DstWidth

Dst width, 0: 1 byte, 1: 2bytes, 2: 4bytes