libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
DMA library for the multi channel controller found in F0/1/3 & L/G parts. More...
Functions | |
void | dma_channel_reset (uint32_t dma, uint8_t channel) |
DMA Channel Reset. More... | |
void | dma_clear_interrupt_flags (uint32_t dma, uint8_t channel, uint32_t interrupts) |
DMA Channel Clear Interrupt Flag. More... | |
bool | dma_get_interrupt_flag (uint32_t dma, uint8_t channel, uint32_t interrupt) |
DMA Channel Read Interrupt Flag. More... | |
void | dma_enable_mem2mem_mode (uint32_t dma, uint8_t channel) |
DMA Channel Enable Memory to Memory Transfers. More... | |
void | dma_set_priority (uint32_t dma, uint8_t channel, uint32_t prio) |
DMA Channel Set Priority. More... | |
void | dma_set_memory_size (uint32_t dma, uint8_t channel, uint32_t mem_size) |
DMA Channel Set Memory Word Width. More... | |
void | dma_set_peripheral_size (uint32_t dma, uint8_t channel, uint32_t peripheral_size) |
DMA Channel Set Peripheral Word Width. More... | |
void | dma_enable_memory_increment_mode (uint32_t dma, uint8_t channel) |
DMA Channel Enable Memory Increment after Transfer. More... | |
void | dma_disable_memory_increment_mode (uint32_t dma, uint8_t channel) |
DMA Channel Disable Memory Increment after Transfer. More... | |
void | dma_enable_peripheral_increment_mode (uint32_t dma, uint8_t channel) |
DMA Channel Enable Peripheral Increment after Transfer. More... | |
void | dma_disable_peripheral_increment_mode (uint32_t dma, uint8_t channel) |
DMA Channel Disable Peripheral Increment after Transfer. More... | |
void | dma_enable_circular_mode (uint32_t dma, uint8_t channel) |
DMA Channel Enable Memory Circular Mode. More... | |
void | dma_set_read_from_peripheral (uint32_t dma, uint8_t channel) |
DMA Channel Enable Transfers from a Peripheral. More... | |
void | dma_set_read_from_memory (uint32_t dma, uint8_t channel) |
DMA Channel Enable Transfers from Memory. More... | |
void | dma_enable_transfer_error_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Enable Interrupt on Transfer Error. More... | |
void | dma_disable_transfer_error_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Disable Interrupt on Transfer Error. More... | |
void | dma_enable_half_transfer_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Enable Interrupt on Transfer Half Complete. More... | |
void | dma_disable_half_transfer_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Disable Interrupt on Transfer Half Complete. More... | |
void | dma_enable_transfer_complete_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Enable Interrupt on Transfer Complete. More... | |
void | dma_disable_transfer_complete_interrupt (uint32_t dma, uint8_t channel) |
DMA Channel Disable Interrupt on Transfer Complete. More... | |
void | dma_enable_channel (uint32_t dma, uint8_t channel) |
DMA Channel Enable. More... | |
void | dma_disable_channel (uint32_t dma, uint8_t channel) |
DMA Channel Disable. More... | |
void | dma_set_peripheral_address (uint32_t dma, uint8_t channel, uint32_t address) |
DMA Channel Set the Peripheral Address. More... | |
void | dma_set_memory_address (uint32_t dma, uint8_t channel, uint32_t address) |
DMA Channel Set the Base Memory Address. More... | |
uint16_t | dma_get_number_of_data (uint32_t dma, uint8_t channel) |
DMA Channel Get the Transfer Block Size. More... | |
void | dma_set_number_of_data (uint32_t dma, uint8_t channel, uint16_t number) |
DMA Channel Set the Transfer Block Size. More... | |
DMA library for the multi channel controller found in F0/1/3 & L/G parts.
This library supports the DMA Control System in the STM32 series of ARM Cortex Microcontrollers by ST Microelectronics.
Up to two DMA controllers are supported. 12 DMA channels are allocated 7 to the first DMA controller and 5 to the second. Each channel is connected to between 3 and 6 hardware peripheral DMA signals in a logical OR arrangement.
DMA transfers can be configured to occur between peripheral and memory in any combination including memory to memory. Circular mode transfers are also supported in transfers involving a peripheral. An arbiter is provided to resolve priority DMA requests. Transfers can be made with 8, 16 or 32 bit words.
LGPL License Terms libopencm3 License
void dma_channel_reset | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Reset.
The channel is disabled and configuration registers are cleared.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 54 of file dma_common_l1f013.c.
References DMA_CCR, DMA_CMAR, DMA_CNDTR, DMA_CPAR, DMA_IFCR, and DMA_IFCR_CIF.
void dma_clear_interrupt_flags | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | interrupts | ||
) |
DMA Channel Clear Interrupt Flag.
The interrupt flag for the channel is cleared. More than one interrupt for the same channel may be cleared by using the logical OR of the interrupt flags.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: DMA Channel Number |
[in] | interrupts | unsigned int32. Logical OR of interrupt numbers: DMA Interrupt Flag Offsets within channel flag |
Definition at line 80 of file dma_common_l1f013.c.
References DMA_FLAG_OFFSET, and DMA_IFCR.
void dma_disable_channel | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 376 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_disable_half_transfer_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable Interrupt on Transfer Half Complete.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 325 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_disable_memory_increment_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable Memory Increment after Transfer.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 201 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_disable_peripheral_increment_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable Peripheral Increment after Transfer.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 229 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_disable_transfer_complete_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable Interrupt on Transfer Complete.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 349 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_disable_transfer_error_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Disable Interrupt on Transfer Error.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 301 of file dma_common_l1f013.c.
References DMA_CCR.
void dma_enable_channel | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 361 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_EN.
void dma_enable_circular_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Memory Circular Mode.
After the number of bytes/words to be transferred has been completed, the original transfer block size, memory and peripheral base addresses are reloaded and the process repeats.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 248 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_CIRC.
void dma_enable_half_transfer_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Interrupt on Transfer Half Complete.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 313 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_HTIE.
void dma_enable_mem2mem_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Memory to Memory Transfers.
Memory to memory transfers do not require a trigger to activate each transfer. Transfers begin immediately the channel has been enabled, and proceed without intervention.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 117 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_MEM2MEM.
void dma_enable_memory_increment_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Memory Increment after Transfer.
Following each transfer the current memory address is incremented by 1, 2 or 4 depending on the data size set in dma_set_memory_size. The value held by the base memory address register is unchanged.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 189 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_MINC.
void dma_enable_peripheral_increment_mode | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Peripheral Increment after Transfer.
Following each transfer the current peripheral address is incremented by 1, 2 or 4 depending on the data size set in dma_set_peripheral_size. The value held by the base peripheral address register is unchanged.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 217 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_PINC.
void dma_enable_transfer_complete_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Interrupt on Transfer Complete.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 337 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_TCIE.
void dma_enable_transfer_error_interrupt | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Interrupt on Transfer Error.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 289 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_TEIE.
bool dma_get_interrupt_flag | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | interrupt | ||
) |
DMA Channel Read Interrupt Flag.
The interrupt flag for the channel is returned.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: DMA Channel Number |
[in] | interrupt | unsigned int32. Interrupt number: DMA Interrupt Flag Offsets within channel flag |
Definition at line 99 of file dma_common_l1f013.c.
References DMA_FLAG_OFFSET, and DMA_ISR.
uint16_t dma_get_number_of_data | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Get the Transfer Block Size.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 429 of file dma_common_l1f013.c.
References DMA_CNDTR.
void dma_set_memory_address | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | address | ||
) |
DMA Channel Set the Base Memory Address.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | address | unsigned int32. Memory Initial Address. |
Definition at line 413 of file dma_common_l1f013.c.
References DMA_CCR, DMA_CCR_EN, and DMA_CMAR.
void dma_set_memory_size | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | mem_size | ||
) |
DMA Channel Set Memory Word Width.
Set the memory word width 8 bits, 16 bits, or 32 bits. Refer to datasheet for alignment information if the source and destination widths do not match.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | mem_size | unsigned int32. Memory word width DMA Channel Memory Word Width. |
Definition at line 151 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_MSIZE_MASK.
void dma_set_number_of_data | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint16_t | number | ||
) |
DMA Channel Set the Transfer Block Size.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | number | unsigned int16. Number of data words to transfer (65535 maximum). |
Definition at line 446 of file dma_common_l1f013.c.
References DMA_CNDTR.
void dma_set_peripheral_address | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | address | ||
) |
DMA Channel Set the Peripheral Address.
Set the address of the peripheral register to or from which data is to be transferred. Refer to the documentation for the specific peripheral.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | address | unsigned int32. Peripheral Address. |
Definition at line 395 of file dma_common_l1f013.c.
References DMA_CCR, DMA_CCR_EN, and DMA_CPAR.
void dma_set_peripheral_size | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | peripheral_size | ||
) |
DMA Channel Set Peripheral Word Width.
Set the peripheral word width 8 bits, 16 bits, or 32 bits. Refer to datasheet for alignment information if the source and destination widths do not match, or if the peripheral does not support byte or half-word writes.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | peripheral_size | unsigned int32. Peripheral word width DMA Channel Peripheral Word Width. |
Definition at line 171 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_PSIZE_MASK.
void dma_set_priority | ( | uint32_t | dma, |
uint8_t | channel, | ||
uint32_t | prio | ||
) |
DMA Channel Set Priority.
Channel Priority has four levels: low to very high. This has precedence over the hardware priority.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
[in] | prio | unsigned int32. Priority level DMA Channel Priority Levels. |
Definition at line 134 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_PL_MASK.
void dma_set_read_from_memory | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Transfers from Memory.
The data direction is set to read from memory.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 277 of file dma_common_l1f013.c.
References DMA_CCR, and DMA_CCR_DIR.
void dma_set_read_from_peripheral | ( | uint32_t | dma, |
uint8_t | channel | ||
) |
DMA Channel Enable Transfers from a Peripheral.
The data direction is set to read from a peripheral.
[in] | dma | unsigned int32. DMA controller base address: DMA1 or DMA2 |
[in] | channel | unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 |
Definition at line 263 of file dma_common_l1f013.c.
References DMA_CCR.