Overview of HAL drivers
Two operating modes are available:
Polling mode I/O operation
a.
b.
Interrupt mode I/O operation
a.
b.
c.
d.
e.
Additional functions and macros are available to ensure efficient DMA management:
Use HAL_DMA_GetState() function to return the DMA state and
HAL_DMA_GetError() in case of error detection.
Use HAL_DMA_Abort() function to abort the current transfer
The most used DMA HAL driver macros are the following:
__HAL_DMA_ENABLE: enablse the specified DMA Channels.
__HAL_DMA_DISABLE: disables the specified DMA Channels.
__HAL_DMA_GET_FS: returns the current DMA Stream FIFO filled level.
__HAL_DMA_GET_FLAG: gets the DMA Channels pending flags.
__HAL_DMA_CLEAR_FLAG: clears the DMA Channels pending flags.
__HAL_DMA_ENABLE_IT: enables the specified DMA Channels interrupts.
__HAL_DMA_DISABLE_IT: disables the specified DMA Channels interrupts.
__HAL_DMA_GET_IT_SOURCE: checks whether the specified DMA stream interrupt
has occurred or not.
50/1371
Use HAL_DMA_Start() to start DMA transfer when the source and destination
addresses and the Length of data to be transferred have been configured.
Use HAL_DMA_PollForTransfer() to poll for the end of current transfer. In this
case a fixed timeout can be configured depending on the user application.
Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
Use HAL_DMA_Start_IT() to start DMA transfer when the source and destination
addresses and the length of data to be transferred have been confgured. In this
case the DMA interrupt is configured.
Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt
subroutine
When data transfer is complete, HAL_DMA_IRQHandler() function is executed
and a user function can be called by customizing XferCpltCallback and
XferErrorCallback function pointer (i.e. a member of DMA handle structure).
When a peripheral is used in DMA mode, the DMA initialization should be done in
the HAL_PPP_MspInit() callback. In addition, the user application should
associate the DMA handle to the PPP handle (refer to section "HAL IO operation
functions").
DMA double-buffering feature is handled as an extension API.
DMA channel callbacks need to be initialized by the user application only in case
of memory-to-memory transfer. However when peripheral-to-memory transfers
are used, these callbacks are automatically initialized by calling a process API
function that uses the DMA.
DocID028236 Rev 2
UM1940
Need help?
Do you have a question about the STM32F2 and is the answer not in the manual?
Questions and answers