modm API documentation
modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE > Class Template Reference

#include <modm/platform/dma/dma_hal.hpp>

Inheritance diagram for modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >:
modm::platform::DmaBase

Public Typedefs

using IrqHandler = void (*)(void)
 

Public Types

enum  Channel {
  Stream0 = 0, Stream1, Stream2, Stream3,
  Stream4, Stream5, Stream6, Stream7,
  Channel0 = Stream0, Channel1 = Stream1, Channel2 = Stream2, Channel3 = Stream3,
  Channel4 = Stream4, Channel5 = Stream5, Channel6 = Stream6, Channel7 = Stream7
}
 
enum  CircularMode : uint32_t { Disabled = 0, CircularMode::Enabled = DMA_SxCR_CIRC }
 
enum  DataTransferDirection : uint32_t { DataTransferDirection::PeripheralToMemory = 0, DataTransferDirection::MemoryToPeripheral = DMA_SxCR_DIR_0, DataTransferDirection::MemoryToMemory = DMA_SxCR_DIR_1 }
 
enum  InterruptEnable : uint32_t { DirectModeError = DMA_SxCR_DMEIE, TransferError = DMA_SxCR_TEIE, HalfTransfer = DMA_SxCR_HTIE, TransferComplete = DMA_SxCR_TCIE }
 
enum  InterruptFlags : uint8_t {
  FifoError = 0b00'0001, DirectModeError = 0b00'0100, Error = 0b00'1000, HalfTransferComplete = 0b01'0000,
  TransferComplete = 0b10'0000, All = 0b11'1101, Global = All
}
 
enum  MemoryDataSize : uint32_t {
  Byte = 0, Bit8 = Byte, HalfWord = DMA_SxCR_MSIZE_0, Bit16 = HalfWord,
  Word = DMA_SxCR_MSIZE_1, Bit32 = Word
}
 
enum  MemoryIncrementMode : uint32_t { Fixed = 0, MemoryIncrementMode::Increment = DMA_SxCR_MINC }
 
enum  PeripheralDataSize : uint32_t {
  Byte = 0, Bit8 = Byte, HalfWord = DMA_SxCR_PSIZE_0, Bit16 = HalfWord,
  Word = DMA_SxCR_PSIZE_1, Bit32 = Word
}
 
enum  PeripheralIncrementMode : uint32_t { Fixed = 0, PeripheralIncrementMode::Increment = DMA_SxCR_PINC }
 
enum  Priority : uint32_t { Low = 0, Medium = DMA_SxCR_PL_0, High = DMA_SxCR_PL_1, VeryHigh = DMA_SxCR_PL_1 | DMA_SxCR_PL_0 }
 
enum  Request : uint32_t {
  Channel0 = (0 << DMA_SxCR_CHSEL_Pos), Channel1 = (1 << DMA_SxCR_CHSEL_Pos), Channel2 = (2 << DMA_SxCR_CHSEL_Pos), Channel3 = (3 << DMA_SxCR_CHSEL_Pos),
  Channel4 = (4 << DMA_SxCR_CHSEL_Pos), Channel5 = (5 << DMA_SxCR_CHSEL_Pos), Channel6 = (6 << DMA_SxCR_CHSEL_Pos), Channel7 = (7 << DMA_SxCR_CHSEL_Pos)
}
 
enum  Signal : uint8_t {
  NoSignal, Ch1, Ch2, Ch3,
  Ch4, Com, Dac1, Dac2,
  In, Out, Rx, Trig,
  Tx, Up
}
 

Public Member Functions

 MODM_FLAGS32 (InterruptEnable)
 
 MODM_FLAGS32 (InterruptFlags)
 

Static Public Member Functions

static void configure (DataTransferDirection direction, MemoryDataSize memoryDataSize, PeripheralDataSize peripheralDataSize, MemoryIncrementMode memoryIncrement, PeripheralIncrementMode peripheralIncrement, Priority priority=Priority::Medium, CircularMode circularMode=CircularMode::Disabled)
 
static void start ()
 
static void stop ()
 
static DataTransferDirection getDataTransferDirection ()
 
static void setMemoryAddress (uintptr_t address)
 
static void setPeripheralAddress (uintptr_t address)
 
static void setMemoryIncrementMode (bool increment)
 
static void setPeripheralIncrementMode (bool increment)
 
static void setDataLength (std::size_t length)
 
static void enableInterrupt (InterruptEnable_t irq)
 
static void disableInterrupt (InterruptEnable_t irq)
 

Static Protected Attributes

static constexpr uint32_t configmask
 
static constexpr uint32_t memoryMask
 
static constexpr uint32_t peripheralMask
 

Detailed Description

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
class modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >

Hardware abstraction layer of a DMA channel

Template Parameters
ChannelIDthe ID of the channel
CHANNEL_BASEbase address of the channel registers
Author
Mike Wolfram

Member Enumeration Documentation

enum modm::platform::DmaBase::CircularMode : uint32_t
inheritedstrong
Enum ValuesDocumentation
Enabled 

circular mode

enum modm::platform::DmaBase::DataTransferDirection : uint32_t
inheritedstrong
Enum ValuesDocumentation
PeripheralToMemory 

Source: DMA_SxPAR; Sink: DMA_SxM0AR.

MemoryToPeripheral 

Source: DMA_SxM0AR; Sink: DMA_SxPAR.

MemoryToMemory 

Source: DMA_SxPAR; Sink: DMA_SxM0AR.

enum modm::platform::DmaBase::MemoryDataSize : uint32_t
inheritedstrong

In direct mode (if the FIFO is not used) MSIZE is forced by hardware to the same value as PSIZE

enum modm::platform::DmaBase::MemoryIncrementMode : uint32_t
inheritedstrong
Enum ValuesDocumentation
Increment 

incremented according to MemoryDataSize

enum modm::platform::DmaBase::PeripheralIncrementMode : uint32_t
inheritedstrong
Enum ValuesDocumentation
Increment 

incremented according to PeripheralDataSize

enum modm::platform::DmaBase::Signal : uint8_t
inheritedstrong

Peripheral signals that can be used in DMA channels

Member Function Documentation

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::configure ( DataTransferDirection  direction,
MemoryDataSize  memoryDataSize,
PeripheralDataSize  peripheralDataSize,
MemoryIncrementMode  memoryIncrement,
PeripheralIncrementMode  peripheralIncrement,
Priority  priority = Priority::Medium,
CircularMode  circularMode = CircularMode::Disabled 
)
inlinestatic

Configure the DMA channel (HAL)

Stops the DMA channel and writes the new values to its control register.

Parameters
[in]directionDirection of the DMA channel
[in]memoryDataSizeSize of data in memory (byte, halfword, word)
[in]peripheralDataSizeSize of data in peripheral (byte, halfword, word)
[in]memoryIncrementDefines whether the memory address is incremented after a transfer completed
[in]peripheralIncrementDefines whether the peripheral address is incremented after a transfer completed
[in]priorityPriority of the DMA channel
[in]circularModeTransfer data in circular mode?
template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::disableInterrupt ( InterruptEnable_t  irq)
inlinestatic

Disable IRQ of this DMA channel (e.g. transfer complete or error)

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::enableInterrupt ( InterruptEnable_t  irq)
inlinestatic

Enable IRQ of this DMA channel (e.g. transfer complete or error)

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static DataTransferDirection modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::getDataTransferDirection ( )
static

Get the direction of the data transfer

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::setDataLength ( std::size_t  length)
inlinestatic

Set length of data to transfer

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::setMemoryAddress ( uintptr_t  address)
inlinestatic

Set the memory address of the DMA channel

Note
In Mem2Mem mode use this method to set the memory source address.
Parameters
[in]addressSource address
template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::setMemoryIncrementMode ( bool  increment)
inlinestatic

Enable/disable memory increment

When enabled, the memory address is incremented by the size of the data (e.g. 1 for byte transfers, 4 for word transfers) after the transfer completed.

Parameters
[in]incrementEnable/disable
template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::setPeripheralAddress ( uintptr_t  address)
inlinestatic

Set the peripheral address of the DMA channel

Note
In Mem2Mem mode use this method to set the memory destination address.
Parameters
[in]addressDestination address
template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::setPeripheralIncrementMode ( bool  increment)
inlinestatic

Enable/disable peripheral increment

When enabled, the peripheral address is incremented by the size of the data (e.g. 1 for byte transfers, 4 for word transfers) after the transfer completed.

Parameters
[in]incrementEnable/disable
template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::start ( )
static

Start the transfer of the DMA channel

template<DmaBase::Channel ChannelID, uint32_t CHANNEL_BASE>
static void modm::platform::DmaChannelHal< ChannelID, CHANNEL_BASE >::stop ( )
static

Stop a DMA channel transfer

Member Data Documentation

constexpr uint32_t modm::platform::DmaBase::configmask
inheritedstaticprotectedconstexpr
Initial value:
DMA_SxCR_CHSEL_Msk |
DMA_SxCR_PL_Msk |
DMA_SxCR_CIRC_Msk |
DMA_SxCR_PFCTRL_Msk
constexpr uint32_t modm::platform::DmaBase::memoryMask
inheritedstaticprotectedconstexpr
Initial value:
DMA_SxCR_MBURST_Msk |
DMA_SxCR_MSIZE_Msk |
DMA_SxCR_MINC |
DMA_SxCR_DIR_Msk
constexpr uint32_t modm::platform::DmaBase::peripheralMask
inheritedstaticprotectedconstexpr
Initial value:
DMA_SxCR_PBURST_Msk |
DMA_SxCR_PSIZE_Msk |
DMA_SxCR_PINC_Msk |
DMA_SxCR_DIR_Msk

The documentation for this class was generated from the following file: