9.2 DMA Firmware driver API description
The following section lists the various functions of the DMA library.
9.2.1 How to use this driver
1. Enable The DMA controller clock using
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE) function for DMA1 or
using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE) function for
DMA2.
2. Enable and configure the peripheral to be connected to the DMA channel (except for
internal SRAM / FLASH memories: no initialization is necessary).
3. For a given Channel, program the Source and Destination addresses, the transfer
Direction, the Buffer Size, the Peripheral and Memory Incrementation mode and Data
Size, the Circular or Normal mode, the channel transfer Priority and the Memory-to-
Memory transfer mode (if needed) using the DMA_Init() function.
4. Enable the NVIC and the corresponding interrupt(s) using the function
DMA_ITConfig() if you need to use DMA interrupts.
5. Enable the DMA channel using the DMA_Cmd() function.
6. Activate the needed channel Request using PPP_DMACmd() function for any PPP
peripheral except internal SRAM and FLASH (ie. SPI, USART ...) The function
allowing this operation is provided in each PPP peripheral driver (ie. SPI_DMACmd for
SPI peripheral).
7. Optionally, you can configure the number of data to be transferred when the channel
is disabled (ie. after each Transfer Complete event or when a Transfer Error occurs)
using the function DMA_SetCurrDataCounter(). And you can get the number of
remaining data to be transferred using the function DMA_GetCurrDataCounter() at run
time (when the DMA channel is enabled and running).
8. To control DMA events you can use one of the following two methods:
a. Check on DMA channel flags using the function DMA_GetFlagStatus().
b. Use DMA interrupts through the function DMA_ITConfig() at initialization phase
and DMA_GetITStatus() function into interrupt routines in communication phase.
After checking on a flag you should clear it using DMA_ClearFlag() function. And
after checking on an interrupt event you should clear it using
DMA_ClearITPendingBit() function.
9.2.2 Initialization and Configuration functions
This subsection provides functions allowing to initialize the DMA channel source and
destination addresses, incrementation and data sizes, transfer direction, buffer size,
circular/normal mode selection, memory-to-memory mode selection and channel priority
value.
The DMA_Init() function follows the DMA configuration procedures as described in
reference manual (RM00316).
ï‚· DMA_DeInit()
ï‚· DMA_Init()
ï‚· DMA_StructInit()
ï‚· DMA_Cmd()