mikroSDK Reference Manual
|
DMA Hardware Abstraction Layer API Reference. More...
Functions list | |
void | hal_dma_configure_default (hal_dma_config_t *config) |
Configure DMA HAL configuration structure. | |
err_t | hal_dma_open (hal_dma_t *obj, hal_dma_config_t *config) |
Open the DMA HAL object. | |
void | hal_dma_get_channels (hal_dma_channel_t *channels) |
Get DMA modules/streams/channels. | |
err_t | hal_dma_set_mode (hal_dma_t *obj, hal_dma_mode_t mode) |
Set the DMA mode. | |
err_t | hal_dma_set_direction (hal_dma_t *obj, hal_dma_direction_t direction) |
Set the DMA direction. | |
err_t | hal_dma_set_priority (hal_dma_t *obj, hal_dma_priority_t priority) |
Set the DMA priority. | |
err_t | hal_dma_set_transfer_config (hal_dma_t *obj, uint32_t addr_src, uint32_t addr_dst, size_t transfer_size, hal_dma_source_memory_region_t src_mem_type) |
Configure the DMA transfer. | |
err_t | hal_dma_transfer_start (hal_dma_t *obj) |
Initializes the DMA transfer. | |
err_t | hal_dma_transfer_stop (hal_dma_t *obj) |
Stops the DMA transfer. | |
err_t | hal_dma_transfer_abort (hal_dma_t *obj) |
Aborts a DMA transfer. | |
err_t | hal_dma_close (hal_dma_t *obj) |
Close DMA HAL object. | |
Closes DMA HAL object, aborts any ongoing transfers, disables the stream, deinitializes the module, clears all buffers used by object and disables module clock for lower power consumption.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
Example
void hal_dma_configure_default | ( | hal_dma_config_t * | config | ) |
Configures hal_dma_config_t structure to default initialization values. Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.
[in,out] | config | configure DMA HAL configuration structure. See hal_dma_config_t structure definition for detailed explanation. |
Default values:
Function | Default value |
---|---|
Module | 0xFF |
Stream | 0xFF |
Channel | 0xFF |
Direction | HAL_DMA_DIRECTION_DEFAULT |
Mode | HAL_DMA_MODE_DEFAULT |
Priority | HAL_DMA_PRIORITY_DEFAULT |
Memory increment | false |
Memory data alignment | HAL_DMA_DATA_ALIGN_DEFAULT |
Memory burst size | HAL_DMA_BURST_SIZE_INCREMENT_DEFAULT |
Peripheral increment | false |
Peripheral data alignment | HAL_DMA_DATA_ALIGN_DEFAULT |
Peripheral burst size | HAL_DMA_BURST_SIZE_INCREMENT_DEFAULT |
Source address | 0 |
Destination address | 0 |
Transfer length | 0 |
Example
void hal_dma_get_channels | ( | hal_dma_channel_t * | channels | ) |
Checks current MCU for available number of modules, streams and channels.
[in,out] | channels | DMA channel context array. See hal_dma_channel_t definition for detailed explanation. |
channels
array has been adequately instantiated before calling this API. Example
err_t hal_dma_open | ( | hal_dma_t * | obj, |
hal_dma_config_t * | config ) |
Opens the DMA HAL object on selected module, stream and channel. Allocates memory for specified object. Additionally, initializes the DMA module.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
[in] | config | configure DMA HAL configuration settings. See hal_dma_config_t structure definition for detailed explanation. |
configuration
structure has been adequately populated beforehand. See hal_dma_configure_default definition for detailed explanation. Example
err_t hal_dma_set_direction | ( | hal_dma_t * | obj, |
hal_dma_direction_t | direction ) |
Sets DMA direction to be used by the DMA HAL.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
[in] | direction | DMA direction. See hal_dma_direction_t for valid values. |
Example
err_t hal_dma_set_mode | ( | hal_dma_t * | obj, |
hal_dma_mode_t | mode ) |
Sets DMA mode to be used by the DMA HAL.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
[in] | mode | DMA mode. See hal_dma_mode_t for valid values. |
Example
err_t hal_dma_set_priority | ( | hal_dma_t * | obj, |
hal_dma_priority_t | priority ) |
Sets DMA priority level to be used by the DMA HAL.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
[in] | priority | DMA priority level. See hal_dma_priority_t for valid values. |
Example
err_t hal_dma_set_transfer_config | ( | hal_dma_t * | obj, |
uint32_t | addr_src, | ||
uint32_t | addr_dst, | ||
size_t | transfer_size, | ||
hal_dma_source_memory_region_t | src_mem_type ) |
Configures initialized DMA stream for transfer.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
[in] | addr_src | Source address for transfer. |
[in] | addr_dst | Destination address for transfer. |
[in] | transfer_size | Number of bytes to transfer. |
[in] | src_mem_type | Source address memory region. |
Example
Aborts any ongoing DMA transfers and disables stream.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
Example
Starts previously configured DMA transfer by enabling stream.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
Example
Stops an active DMA transfer by disabling stream.
[in,out] | obj | DMA HAL object. See hal_dma_t structure definition for detailed explanation. |
Example