microHAL
An abstraction layer for your future F4xx projects
|
Function prototypes for the DMA driver. More...
Go to the source code of this file.
Data Structures | |
struct | DMAStreamRegs |
Contains DMA stream registers. More... | |
struct | DMARegs |
Contains DMA registers. More... | |
struct | DMAStreamConfig |
Contains DMA stream options. More... | |
struct | DMAStreamISR |
Contains DMA stream interrupt configuration. More... | |
Macros | |
#define | DMA(x) |
Typedefs | |
typedef enum dma_peripheral | dma_peripheral_t |
Available DMA peripherals. | |
typedef enum dma_dir | dma_dir_t |
Available DMA directions. | |
typedef enum dma_datasize | dma_datasize_t |
Available DMA data sizes. | |
typedef enum dma_priority | dma_priority_t |
Available DMA priorities. | |
Enumerations | |
enum | dma_peripheral { DMA_PERIPH_1 = 0x00 , DMA_PERIPH_2 = 0x01 } |
Available DMA peripherals. | |
enum | dma_dir { DMA_DIR_PER2MEM = 0x00 , DMA_DIR_MEM2PER = 0x01 , DMA_DIR_MEM2MEM = 0x02 } |
Available DMA directions. | |
enum | dma_datasize { DMA_DATASIZE_BYTE = 0x00 , DMA_DATASIZE_HWRD = 0x01 , DMA_DATASIZE_WORD = 0x02 } |
Available DMA data sizes. | |
enum | dma_priority { DMA_PRIORITY_LOW = 0x00 , DMA_PRIORITY_MED = 0x01 , DMA_PRIORITY_HIG = 0x02 , DMA_PRIORITY_VHI = 0x03 } |
Available DMA priorities. | |
Functions | |
void | dma_set_addresses (const dma_peripheral_t dma, const uint8_t stream, const uint32_t PA, const uint32_t M0A, const uint32_t M1A) |
Set the DMA source and destination addresses. | |
void | dma_configure_data (const dma_peripheral_t dma, const uint8_t stream, const uint16_t count, const dma_datasize_t msize, const dma_datasize_t psize) |
Set DMA transfers to specified configuration. | |
void | dma_set_direction (const dma_peripheral_t dma, const uint8_t stream, const dma_dir_t direction) |
Set DMA transfers to the desired direction. | |
void | dma_configure_stream (const dma_peripheral_t dma, const uint8_t stream, const struct DMAStreamConfig config) |
Set DMA stream to the specified configuration. | |
void | dma_set_channel (const dma_peripheral_t dma, const uint8_t stream, const uint8_t channel, const dma_priority_t priority) |
Set the DMA stream channel and priority. | |
void | dma_set_interrupts (const dma_peripheral_t dma, const uint8_t stream, const struct DMAStreamISR config) |
Enabled the specified DMA stream interrupts. | |
void | dma_enable (const dma_peripheral_t dma, const uint8_t stream) |
Enables DMA stream transfers. | |
void | dma_disable (const dma_peripheral_t dma, const uint8_t stream) |
Disables DMA stream transfers. | |
Function prototypes for the DMA driver.
This file contains all of the enums, macros, and function prototypes required for a functional DMA driver.
DISCLAIMER: No burst or FIFO for the time being!
#define DMA | ( | x | ) |
void dma_configure_data | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const uint16_t | count, | ||
const dma_datasize_t | msize, | ||
const dma_datasize_t | psize ) |
Set DMA transfers to specified configuration.
The DMA datasizes are specified in the dma_datasize_t enum. Any other value will be ignored.
dma | The selected DMA |
stream | The selected stream (0..7) |
count | The total number of data items |
msize | The size of data stored in memory |
psize | The size of data stored in the peripheral |
void dma_configure_stream | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const struct DMAStreamConfig | config ) |
Set DMA stream to the specified configuration.
The DMA stream options are specified in the DMAStreamConfig struct.
dma | The selected DMA |
stream | The selected stream (0..7) |
config | The stream configuration |
void dma_disable | ( | const dma_peripheral_t | dma, |
const uint8_t | stream ) |
Disables DMA stream transfers.
dma | The selected DMA |
stream | The selected stream (0..7) |
void dma_enable | ( | const dma_peripheral_t | dma, |
const uint8_t | stream ) |
Enables DMA stream transfers.
dma | The selected DMA |
stream | The selected stream (0..7) |
void dma_set_addresses | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const uint32_t | PA, | ||
const uint32_t | M0A, | ||
const uint32_t | M1A ) |
Set the DMA source and destination addresses.
Usually only the peripheral and M0 addresses are needed. In that case you shall set M1A to zero.
dma | The selected DMA |
stream | The selected stream (0..7) |
PA | The peripheral address |
M0A | The memory 0 address |
M1A | The memory 1 address |
void dma_set_channel | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const uint8_t | channel, | ||
const dma_priority_t | priority ) |
Set the DMA stream channel and priority.
The DMA priority levels are specified in the dma_priority_t enum. Any other value will be ignored. Refer to the chip's manual for the channel function matrix.
dma | The selected DMA |
stream | The selected stream (0..7) |
channel | The selected channel (0..7) |
priority | The stream priority level |
void dma_set_direction | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const dma_dir_t | direction ) |
Set DMA transfers to the desired direction.
The DMA directions are specified in the dma_dir_t enum. Any other value will be ignored. After that set the addresses according to the chip's manual.
dma | The selected DMA |
stream | The selected stream (0..7) |
direction | The transfer direction |
void dma_set_interrupts | ( | const dma_peripheral_t | dma, |
const uint8_t | stream, | ||
const struct DMAStreamISR | config ) |
Enabled the specified DMA stream interrupts.
The available DMA interrupts are located in the DMAStreamISR struct.
dma | The selected DMA |
stream | The selected stream (0..7) |
config | The interrupt configuration |