Generic interface of the DMA on STM32 platforms.
More...
#include </home/travis/build/forGGe/theCore/platform/stm32/family/export/stm32_dma_wrap_interface.hpp>
|
static constexpr auto | get_irqn () |
| Gets IRQ number of given DMA entity. More...
|
|
static void | init () |
| Initializes DMA. More...
|
|
template<dma_data_sz Size = dma_data_sz::byte, dma_mode Mode = dma_mode::normal> |
static void | mem_to_periph (const uint8_t *src, size_t size, volatile uint16_t *periph) |
| Prepares DMA transaction from the memory buffer to the given peripheral. More...
|
|
template<dma_data_sz Size = dma_data_sz::byte, dma_mode Mode = dma_mode::normal> |
static void | mem_to_periph (uint16_t filler, size_t cnt, volatile uint16_t *periph) |
| Prepares DMA transaction that sends given data unit to the given peripheral. More...
|
|
template<dma_data_sz Size = dma_data_sz::byte, dma_mode Mode = dma_mode::normal> |
static void | periph_to_mem (volatile uint16_t *periph, uint8_t *dst, size_t size) |
| Prepares DMA transaction from the peripheral to the given memory buffer. More...
|
|
template<dma_data_sz Size = dma_data_sz::byte, dma_mode Mode = dma_mode::normal> |
static void | periph_to_mem (volatile uint16_t *periph, size_t size) |
| Prepares DMA transaction that reads data from peripheral without storing it. More...
|
|
template<bool EnableTC = true, bool EnableHT = true, bool EnableErr = true> |
static void | enable_events_irq () |
| Enables IRQ for the events from DMA entity. More...
|
|
template<bool DisableTC = true, bool DisableHT = true, bool DisableErr = true> |
static void | disable_events_irq () |
| Disables IRQ for the events from DMA entity. More...
|
|
static void | enable () |
| Enables DMA transaction. More...
|
|
static void | disable () |
| Disables DMA transaction. More...
|
|
static bool | tc () |
| Checks if TC event occurred. More...
|
|
static bool | ht () |
| Checks if HT event occurred. More...
|
|
static bool | err () |
| Checks if TC event occurred. More...
|
|
static void | clear_tc () |
| Clears TC event. More...
|
|
static void | clear_ht () |
| Clears HT event. More...
|
|
static void | clear_err () |
| Clears ERR event. More...
|
|
static auto | bytes_left () |
| Checks how many bytes left to transmit via DMA entity. More...
|
|
template<class Impl>
class ecl::dma_wrap_base< Impl >
Generic interface of the DMA on STM32 platforms.
The STM32 MCU family module must implement each method in its own headers. Depends on the family the entity behind the class may differ. E.g. in STM32F4 each DMA instance is unambiguously described by the pair of "stream" and "channel" in contrast to just "channel" in STM32L1. Template parameter allows to incapsulate additional methods into separate class required by the MCU family while keeping in it the scope of a base class and not exposing it in its body.
- Template Parameters
-
Impl | Desired additional implementation, defined by the platform. |
◆ dma_wrap_base() [1/2]
◆ dma_wrap_base() [2/2]
◆ get_irqn()
Gets IRQ number of given DMA entity.
◆ init()
Initializes DMA.
- Precondition
- DMA is not initialized.
- Postcondition
- DMA is initialized and ready to work.
◆ mem_to_periph() [1/2]
template<class Derived >
template<dma_data_sz Size, dma_mode Mode>
void ecl::dma_wrap_base< Derived >::mem_to_periph |
( |
const uint8_t * |
src, |
|
|
size_t |
size, |
|
|
volatile uint16_t * |
periph |
|
) |
| |
|
static |
Prepares DMA transaction from the memory buffer to the given peripheral.
- Precondition
- DMA was initialized by calling init() method.
-
src != nullptr, periph != nullptr, size > 0
- Postcondition
- DMA is configured with given parameters and ready to go.
Transaction can be triggered by enable() call. DMA events can be enabled using enable_events_irq() routine. If circular mode is chosen then new DMA transaction will start automatically, without need of the explicit enable() call.
- Template Parameters
-
Size | Required size of a single data unit. |
Mode | Mode of operation. |
- Parameters
-
[in] | src | The source memory buffer from which data will be read. |
[in] | size | Size of the memory buffer buffer in bytes. |
[in] | periph | The valid peripheral address. |
◆ mem_to_periph() [2/2]
template<class Derived >
template<dma_data_sz Size, dma_mode Mode>
void ecl::dma_wrap_base< Derived >::mem_to_periph |
( |
uint16_t |
filler, |
|
|
size_t |
cnt, |
|
|
volatile uint16_t * |
periph |
|
) |
| |
|
static |
Prepares DMA transaction that sends given data unit to the given peripheral.
- Precondition
- DMA was initialized by calling init() method.
-
cnt > 0, periph != nullptr
- Postcondition
- DMA is configured with given parameters and ready to go.
Transaction can be triggered by enable() call. DMA events can be enabled using enable_events_irq() routine. If circular mode is chosen then new DMA transaction will start automatically, without need of the explicit enable() call.
- Template Parameters
-
Size | Required size of a single data unit. |
Mode | Mode of operation. |
- Parameters
-
[in] | filler | Data unit to be transfered. |
[in] | cnt | Amount of data units to be transfered. |
[in] | periph | The valid peripheral address. |
◆ periph_to_mem() [1/2]
template<class Derived >
template<dma_data_sz Size, dma_mode Mode>
void ecl::dma_wrap_base< Derived >::periph_to_mem |
( |
volatile uint16_t * |
periph, |
|
|
uint8_t * |
dst, |
|
|
size_t |
size |
|
) |
| |
|
static |
Prepares DMA transaction from the peripheral to the given memory buffer.
- Precondition
- DMA was initialized by calling init() method.
-
size > 0, periph != nullptr, dst != nullptr
- Postcondition
- DMA is configured with given parameters and ready to go.
Transaction can be triggered by enable() call. DMA events can be enabled using enable_events_irq() routine. If circular mode is chosen then new DMA transaction will start automatically, without need of the explicit enable() call.
- Template Parameters
-
Size | Size of a single data unit. |
Mode | Mode of operation. |
- Parameters
-
[in] | periph | The valid peripheral address. |
[in] | size | Size of the memory buffer buffer in bytes. |
[in] | dst | The destination buffer. |
◆ periph_to_mem() [2/2]
template<class Derived >
template<dma_data_sz Size, dma_mode Mode>
void ecl::dma_wrap_base< Derived >::periph_to_mem |
( |
volatile uint16_t * |
periph, |
|
|
size_t |
size |
|
) |
| |
|
static |
Prepares DMA transaction that reads data from peripheral without storing it.
- Precondition
- DMA was initialized by calling init() method.
-
size > 0, periph != nullptr
- Postcondition
- DMA is configured with given parameters and ready to go.
Transaction can be triggered by enable() call. DMA events can be enabled using enable_events_irq() routine. If circular mode is chosen then new DMA transaction will start automatically, without need of the explicit enable() call.
- Template Parameters
-
Size | Size of a single data unit. |
Mode | Mode of operation. |
- Parameters
-
[in] | periph | The valid peripheral address. |
[in] | size | Size of the memory buffer buffer in bytes. |
◆ enable_events_irq()
template<class Derived >
template<bool EnableTC, bool EnableHT, bool EnableErr>
Enables IRQ for the events from DMA entity.
- Precondition
- DMA was initialized by calling init() method.
- Postcondition
- DMA configured to trigger IRQ every time corresponding event occur.
Events will be generated by the DMA according to type of events requested. If enabled, events will be delivered via IRQ. To subscribe for it use IRQ descriptor returned by the get_irqn() routine. Use tc(), ht() and err() to check if event occurred or not.
- Template Parameters
-
EnableTC | Set if transfer complete event must be enabled. |
EnableHT | Set if half transfer event must be enabled. |
EnableErr | Set if error event must be enabled. |
- Note
- Event IRQ allowance is not changed if relevant argument is not set. See example below
dma_tx::template enable_events_irq<true, false, false>();
dma_tx::template enable_events_irq<false, false, true>();
◆ disable_events_irq()
template<class Derived >
template<bool DisableTC, bool DisableHT, bool DisableErr>
Disables IRQ for the events from DMA entity.
- Precondition
- DMA was initialized by calling init() method.
- Postcondition
- DMA configure to do not trigger IRQ for selected events.
IRQ previously enabled by enable_events_irq() can be disabled using this method..
- Template Parameters
-
EnableTC | Set if transfer complete event must be enabled. |
EnableHT | Set if half transfer event must be enabled. |
EnableErr | Set if error event must be enabled. |
- Note
- Event IRQ allowance is not changed if relevant argument is not set. See example below
dma_tx::template disable_events_irq<true, false, false>();
dma_tx::template disable_events_irq<false, false, true>();
◆ enable()
Enables DMA transaction.
- Precondition
- DMA was configured by one of the periph_to_mem() or mem_to_periph() methods.
-
DMA was not yet started or already stopped previously by disable() call.
- Postcondition
- DMA transaction enabled and started.
By invoking this method one can lauch previously configured transaction. Use tc(), ht() and err() to check particular event state. Corresponding IRQ will be triggered if configured by enable_events_irq().
◆ disable()
Disables DMA transaction.
- Precondition
- DMA was enabled by enable() and not yet disabled.
- Postcondition
- DMA transaction stopped and disabled.
If to call disable() before TC event occur then DMA will stop only after last data unit will be transfered.
◆ tc()
Checks if TC event occurred.
- Precondition
- DMA was initialized by calling init() method.
- Returns
- true if tranfer completed, false otherwise.
◆ ht()
Checks if HT event occurred.
- Precondition
- DMA was initialized by calling init() method.
- Returns
- true if tranfer is half-completed, false otherwise.
◆ err()
Checks if TC event occurred.
- Precondition
- DMA was initialized by calling init() method.
- Returns
- true if error occurred during transaction, false otherwise.
◆ clear_tc()
Clears TC event.
- Precondition
- DMA was initialized by calling init() method.
- Postcondition
- tc() == false.
◆ clear_ht()
Clears HT event.
- Precondition
- DMA was initialized by calling init() method.
- Postcondition
- ht() == false.
◆ clear_err()
Clears ERR event.
- Precondition
- DMA was initialized by calling init() method.
- Postcondition
- err() == false.
◆ bytes_left()
Checks how many bytes left to transmit via DMA entity.
- Precondition
- DMA was initialized by calling init() method.
The documentation for this class was generated from the following files: