modm API documentation
RP2040 multi-core module

Classes

struct  modm::platform::multicore::Core
 
struct  modm::platform::multicore::Core1
 
struct  modm::platform::multicore::Mailbox
 
class  modm::platform::multicore::Mutex
 
class  modm::platform::multicore::SpinLockBlocking< instance >
 
class  modm::platform::multicore::SpinLockGuard< SpinLock >
 
class  modm::platform::multicore::SpinLockGuard< SpinLockBlocking< instance > >
 
class  modm::platform::multicore::SpinLockUnsafe< instance >
 

Typedefs

using modm::platform::multicore::SystemSpinLock = SpinLockBlocking< 0 >
 
using modm::platform::multicore::SystemSpinLockGuard = SpinLockGuard< SystemSpinLock >
 
#define modm_fastdata_core0   modm_section(".data_core0")
 
#define modm_fastdata_core1   modm_section(".data_core1")
 Places initialized objects into the core1-coupled memory.
 
#define modm_bss_core0   modm_section(".bss_core0")
 Places zeroed objects into the core0-coupled memory.
 
#define modm_bss_core1   modm_section(".bss_core1")
 Places zeroed objects into the core1-coupled memory.
 
#define modm_noinit_core0   modm_section(".noinit_core0")
 Places uninitialized objects into the core0-coupled memory.
 
#define modm_noinit_core1   modm_section(".noinit_core1")
 Places uninitialized objects into the core1-coupled memory.
 
#define modm_faststack_core0   modm_noinit_core0
 Places stacks into the core0-coupled memory.
 
#define modm_faststack_core1   modm_noinit_core1
 Places stacks into the core1-coupled memory.
 
#define modm_fastcode_core0   modm_fastdata_core0
 Places functions into the core0-coupled memory.
 
#define modm_fastcode_core1   modm_fastdata_core1
 Places functions into the core1-coupled memory.
 
void modm_initialize_core1 (void)
 Weak callback to initialize CPU1.
 

Detailed Description

lbuild module: modm:platform:multicore

This module adds the ability to run code on CPU1 and provides mailbox, spinlock and mutex implementations, and additionally a stack of size modm:platform:cortex-m:main_stack_size is added to the CORE1 memory and the modm::atomic::Lock is made multicore safe. You can use attributes for placing objects into core-coupled memories:

modm_core0_data uint8_t data = 0xab;
modm_core1_bss uint16_t zero;
modm_core0_noinit uint32_t uninitialized;
modm_core1_code
void function()
{
data = 0xcd;
zero = 100;
uninitialized = 200;
}

We provide a symmetric multiprocessing (SMP) abstraction, where the same binary is used for both cores. By default CPU0 is used to boot the device and code running on CPU1 needs to be explicitly started:

void function()
{
uint8_t cpuid = Core::cpuId();
}
function(); // cpuid == 0
multicore::Core1::run(function); // cpuid == 1
// Before CPU1 executes code, this function is called
// so that you can customize the CPU1 environment
extern "C" void modm_initialize_core1()
{
// set a custom vector table for CPU1
SCB->VTOR = custom_vector_table;
}

Macro Definition Documentation

#define modm_fastdata_core0   modm_section(".data_core0")

Places initialized objects into the core0-coupled memory