modm API documentation
modm::platform::DmaController< ID >::Channel Class Reference

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

Inheritance diagram for modm::platform::DmaController< ID >::Channel:
modm::platform::DmaBase

Classes

struct  RequestMapping
 

Public Typedefs

using IrqHandler = void (*)(void)
 

Public Types

enum  Channel {
  Channel1 = 0, Channel2, Channel3, Channel4,
  Channel5, Channel6, Channel7
}
 
enum  CircularMode : uint32_t { Disabled = 0, CircularMode::Enabled = DMA_CCR_CIRC }
 
enum  DataTransferDirection : uint32_t { DataTransferDirection::PeripheralToMemory = 0, DataTransferDirection::MemoryToPeripheral = DMA_CCR_DIR, DataTransferDirection::MemoryToMemory = DMA_CCR_MEM2MEM }
 
enum  InterruptEnable : uint32_t { TransferComplete = DMA_CCR_TCIE, HalfTransfer = DMA_CCR_HTIE, TransferError = DMA_CCR_TEIE }
 
enum  InterruptFlags : uint8_t {
  Global = 0b0001, TransferComplete = 0b0010, HalfTransferComplete = 0b0100, Error = 0b1000,
  All = 0b1111
}
 
enum  MemoryDataSize : uint32_t {
  Byte = 0, Bit8 = Byte, HalfWord = DMA_CCR_MSIZE_0, Bit16 = HalfWord,
  Word = DMA_CCR_MSIZE_1, Bit32 = Word
}
 
enum  MemoryIncrementMode : uint32_t { Fixed = 0, MemoryIncrementMode::Increment = DMA_CCR_MINC }
 
enum  PeripheralDataSize : uint32_t {
  Byte = 0, Bit8 = Byte, HalfWord = DMA_CCR_PSIZE_0, Bit16 = HalfWord,
  Word = DMA_CCR_PSIZE_1, Bit32 = Word
}
 
enum  PeripheralIncrementMode : uint32_t { Fixed = 0, PeripheralIncrementMode::Increment = DMA_CCR_PINC }
 
enum  Priority : uint32_t { Low = 0, Medium = DMA_CCR_PL_0, High = DMA_CCR_PL_1, VeryHigh = DMA_CCR_PL_1 | DMA_CCR_PL_0 }
 
enum  Request { Any }
 
enum  Signal : uint8_t {
  NoSignal, Ch1, Ch2, Ch3,
  Ch4, 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 setTransferErrorIrqHandler (IrqHandler irqHandler)
 
static void setHalfTransferCompleteIrqHandler (IrqHandler irqHandler)
 
static void setTransferCompleteIrqHandler (IrqHandler irqHandler)
 
template<DmaBase::Request dmaRequest>
static void setPeripheralRequest ()
 
static void interruptHandler ()
 
static InterruptFlags_t getInterruptFlags ()
 
static void clearInterruptFlags (InterruptFlags_t flags=InterruptFlags::All)
 
static void enableInterruptVector (uint32_t priority=1)
 
static void disableInterruptVector ()
 
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<uint32_t ID>
class modm::platform::DmaController< ID >::Channel

Class representing a DMA channel/stream

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_CPARx; Sink: DMA_CMARx.

MemoryToPeripheral 

Source: DMA_CMARx; Sink: DMA_CPARx.

MemoryToMemory 

Source: DMA_CPARx; Sink: DMA_CMARx.

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<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::clearInterruptFlags ( InterruptFlags_t  flags = InterruptFlags::All)
inlinestatic

Clear channel interrupt flags. Use only when the channel interrupt is disabled.

Warning
Flags are automatically cleared in the ISR if the channel interrupt is enabled or when start() is called.
template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::configure ( DataTransferDirection  direction,
MemoryDataSize  memoryDataSize,
PeripheralDataSize  peripheralDataSize,
MemoryIncrementMode  memoryIncrement,
PeripheralIncrementMode  peripheralIncrement,
Priority  priority = Priority::Medium,
CircularMode  circularMode = CircularMode::Disabled 
)
inlinestatic

Configure the DMA channel

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<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::disableInterrupt ( InterruptEnable_t  irq)
inlinestatic

Disable the specified interrupt of the channel

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::disableInterruptVector ( )
inlinestatic

Disable the IRQ vector of the channel

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::enableInterrupt ( InterruptEnable_t  irq)
inlinestatic

Enable the specified interrupt of the channel

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::enableInterruptVector ( uint32_t  priority = 1)
inlinestatic

Enable the IRQ vector of the channel

Parameters
[in]priorityPriority of the IRQ
template<uint32_t ID>
static DataTransferDirection modm::platform::DmaController< ID >::Channel::getDataTransferDirection ( )
inlinestatic

Get the direction of the data transfer

template<uint32_t ID>
static InterruptFlags_t modm::platform::DmaController< ID >::Channel::getInterruptFlags ( )
inlinestatic

Read channel status flags when channel interrupts are disabled. This function is useful to query the transfer state when the use of the channel interrupt is not required for the application.

Warning
Flags are automatically cleared in the ISR if the channel interrupt is enabled or when start() is called.
template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::interruptHandler ( )
inlinestatic

IRQ handler of the DMA channel

Reads the IRQ status and checks for error or transfer complete. In case of error the DMA channel will be disabled.

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::setDataLength ( std::size_t  length)
inlinestatic

Set the length of data to be transfered

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::setHalfTransferCompleteIrqHandler ( IrqHandler  irqHandler)
inlinestatic

Set the IRQ handler for half transfer complete

Called by the channels IRQ handler when the transfer is half complete.

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::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<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::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<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::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<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::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<uint32_t ID>
template<DmaBase::Request dmaRequest>
static void modm::platform::DmaController< ID >::Channel::setPeripheralRequest ( )
inlinestatic

Set the peripheral that operates the channel

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::setTransferCompleteIrqHandler ( IrqHandler  irqHandler)
inlinestatic

Set the IRQ handler for transfer complete

Called by the channels IRQ handler when the transfer is complete.

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::setTransferErrorIrqHandler ( IrqHandler  irqHandler)
inlinestatic

Set the IRQ handler for transfer errors

The handler will be called from the channels IRQ handler function when the IRQ status indicates an error occured.

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::start ( )
inlinestatic

Start the transfer of the DMA channel and clear all interrupt flags.

template<uint32_t ID>
static void modm::platform::DmaController< ID >::Channel::stop ( )
inlinestatic

Stop a DMA channel transfer

Member Data Documentation

constexpr uint32_t modm::platform::DmaBase::configmask
inheritedstaticprotectedconstexpr
Initial value:
DMA_CCR_CIRC |
DMA_CCR_PL_1 | DMA_CCR_PL_0
constexpr uint32_t modm::platform::DmaBase::memoryMask
inheritedstaticprotectedconstexpr
Initial value:
DMA_CCR_MSIZE_0 | DMA_CCR_MSIZE_1 |
DMA_CCR_MINC |
DMA_CCR_DIR | DMA_CCR_MEM2MEM
constexpr uint32_t modm::platform::DmaBase::peripheralMask
inheritedstaticprotectedconstexpr
Initial value:
DMA_CCR_PSIZE_0 | DMA_CCR_PSIZE_1 |
DMA_CCR_PINC |
DMA_CCR_DIR | DMA_CCR_MEM2MEM

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