modm API documentation
void * operator new (std::size_t size, modm::MemoryTraits traits)
 
void * operator new[] (std::size_t size, modm::MemoryTraits traits)
 
void * operator new (std::size_t size, modm::MemoryTraits traits, const std::nothrow_t &) noexcept
 
void * operator new[] (std::size_t size, modm::MemoryTraits traits, const std::nothrow_t &) noexcept
 
enum  modm::MemoryTrait : uint16_t {
  modm::MemoryTrait::AccessSBus = Bit0, modm::MemoryTrait::AccessDBus = Bit1, modm::MemoryTrait::AccessIBus = Bit2, modm::MemoryTrait::AccessDMA = Bit3,
  modm::MemoryTrait::AccessDMA2D = Bit4, modm::MemoryTrait::AccessMDMA = Bit5, modm::MemoryTrait::TypeCoreCoupled = Bit13, modm::MemoryTrait::TypeNonVolatile = Bit14,
  modm::MemoryTrait::TypeExternal = Bit15
}
 Describes access and type of dynamic memory. More...
 
using modm::MemoryTraits = Flags16< MemoryTrait >
 A memory can have multiple traits.
 
constexpr MemoryTraits modm::MemoryFastCode = (MemoryTrait::AccessIBus | MemoryTrait::TypeCoreCoupled)
 
constexpr MemoryTraits modm::MemoryFastData = (MemoryTrait::AccessDBus | MemoryTrait::TypeCoreCoupled)
 
constexpr MemoryTraits modm::MemoryDMA = (MemoryTrait::AccessSBus | MemoryTrait::AccessDMA)
 
constexpr MemoryTraits modm::MemoryDMA2D = (MemoryTrait::AccessSBus | MemoryTrait::AccessDMA2D)
 
constexpr MemoryTraits modm::MemoryMDMA = (MemoryTrait::AccessSBus | MemoryTrait::AccessMDMA)
 
constexpr MemoryTraits modm::MemoryExternal = (MemoryTrait::AccessSBus | MemoryTrait::TypeExternal)
 
constexpr MemoryTraits modm::MemoryBackup = (MemoryTrait::AccessSBus | MemoryTrait::TypeNonVolatile)
 
constexpr MemoryTraits modm::MemoryDefault = MemoryDMA
 Default memory is DMA-able.
 

Detailed Description

lbuild module: modm:architecture:memory

Memories have different traits, such as DMA-ability or access time. The memory allocator functions (malloc(), operator new, etc) by default only return DMA-able memories, ordered by fastest access time. To allocate memory with specific traits, use the overloaded operator new:

auto *p = new (modm::MemoryFastData) Foo;
auto *q = new (modm::MemoryExternal, std::nothrow) Foo;
Note
You need to choose a heap implementation! You can include the modm:platform:heap module or supply your own implementation.

Enumeration Type Documentation

enum modm::MemoryTrait : uint16_t
strong

Describes access and type of dynamic memory.

Enum ValuesDocumentation
AccessSBus 

Memory is accessible via System-Bus.

AccessDBus 

Memory is accessible via Data-Bus.

AccessIBus 

Memory is accessible via Instruction-Bus.

AccessDMA 

Memory is accessible via DMA.

AccessDMA2D 

Memory is accessible via 2D DMA.

AccessMDMA 

Memory is accessible via MDMA.

TypeCoreCoupled 

Memory is coupled closely to the core.

TypeNonVolatile 

Memory is non-volatile (battery-backed)

TypeExternal 

Memory is external RAM.

Function Documentation

void* operator new ( std::size_t  size,
modm::MemoryTraits  traits 
)

Request object memory with defined traits.

Foo *p = new (modm::MemoryFastData) Foo;
void* operator new ( std::size_t  size,
modm::MemoryTraits  traits,
const std::nothrow_t &   
)
noexcept

Request object memory with defined traits and return nullptr if out-of-memory!

Foo *p = new (modm::MemoryFastData, std::nothrow) Foo;
void* operator new[] ( std::size_t  size,
modm::MemoryTraits  traits 
)

Request array memory with defined traits.

uint32_t *p = new (modm::MemoryFastData) uint32_t[200];
void* operator new[] ( std::size_t  size,
modm::MemoryTraits  traits,
const std::nothrow_t &   
)
noexcept

Request array memory with defined traits and return nullptr if out-of-memory!

uint32_t *p = new (modm::MemoryFastData, std::nothrow) uint32_t[200];

Variable Documentation

constexpr MemoryTraits modm::MemoryBackup = (MemoryTrait::AccessSBus | MemoryTrait::TypeNonVolatile)
constexpr

Backup memory is accessible by at least the S-Bus and it is non-volatile. There is no fallback memory on exhaustion.

constexpr MemoryTraits modm::MemoryDMA = (MemoryTrait::AccessSBus | MemoryTrait::AccessDMA)
constexpr

DMA-able memory is accessible by at least the S-Bus and DMA. There is no fallback memory on exhaustion.

constexpr MemoryTraits modm::MemoryDMA2D = (MemoryTrait::AccessSBus | MemoryTrait::AccessDMA2D)
constexpr

DMA-able memory is accessible by at least the S-Bus and 2D DMA. There is no fallback memory on exhaustion.

constexpr MemoryTraits modm::MemoryExternal = (MemoryTrait::AccessSBus | MemoryTrait::TypeExternal)
constexpr

External memory is accessible by at least the S-Bus and it is external. Fallback memory on exhaustion is internal.

constexpr MemoryTraits modm::MemoryFastCode = (MemoryTrait::AccessIBus | MemoryTrait::TypeCoreCoupled)
constexpr

Fast code memory is accessible by at least the I-Bus and it is core-coupled. Fallback memory on exhaustion is not core-coupled.

constexpr MemoryTraits modm::MemoryFastData = (MemoryTrait::AccessDBus | MemoryTrait::TypeCoreCoupled)
constexpr

Fast data memory is accessible by at least the D-Bus and it is core coupled. Fallback memory on exhaustion is not core-coupled.

constexpr MemoryTraits modm::MemoryMDMA = (MemoryTrait::AccessSBus | MemoryTrait::AccessMDMA)
constexpr

DMA-able memory is accessible by at least the S-Bus and MDMA. There is no fallback memory on exhaustion.