pico_multicore

Adds support for running code on the second processor core (core 1) More...

Modules

 fifo
 Functions for the inter-core FIFOs.
 
 lockout
 Functions to enable one core to force the other core to pause execution in a known state.
 

Functions

void multicore_reset_core1 (void)
 Reset core 1. More...
 
void multicore_launch_core1 (void(*entry)(void))
 Run code on core 1. More...
 
void multicore_launch_core1_with_stack (void(*entry)(void), uint32_t *stack_bottom, size_t stack_size_bytes)
 Launch code on core 1 with stack. More...
 
void multicore_launch_core1_raw (void(*entry)(void), uint32_t *sp, uint32_t vector_table)
 Launch code on core 1 with no stack protection. More...
 

Detailed Description

Adds support for running code on the second processor core (core 1)

Example

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#define FLAG_VALUE 123
void core1_entry() {
if (g != FLAG_VALUE)
printf("Hmm, that's not right on core 1!\n");
else
printf("Its all gone well on core 1!");
while (1)
}
int main() {
printf("Hello, multicore!\n");
multicore_launch_core1(core1_entry);
// Wait for it to start up
if (g != FLAG_VALUE)
printf("Hmm, that's not right on core 0!\n");
else {
printf("It's all gone well on core 0!");
}
}

Function Documentation

◆ multicore_launch_core1()

void multicore_launch_core1 ( void(*)(void)  entry)

Run code on core 1.

Wake up (a previously reset) core 1 and enter the given function on core 1 using the default core 1 stack (below core 0 stack).

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

core 1 will use the same vector table as core 0

Parameters
entryFunction entry point
See also
multicore_reset_core1

◆ multicore_launch_core1_raw()

void multicore_launch_core1_raw ( void(*)(void)  entry,
uint32_t *  sp,
uint32_t  vector_table 
)

Launch code on core 1 with no stack protection.

Wake up (a previously reset) core 1 and start it executing with a specific entry point, stack pointer and vector table.

This is a low level function that does not provide a stack guard even if USE_STACK_GUARDS is defined

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

Parameters
entryFunction entry point
spPointer to the top of the core 1 stack
vector_tableaddress of the vector table to use for core 1
See also
multicore_reset_core1

◆ multicore_launch_core1_with_stack()

void multicore_launch_core1_with_stack ( void(*)(void)  entry,
uint32_t *  stack_bottom,
size_t  stack_size_bytes 
)

Launch code on core 1 with stack.

Wake up (a previously reset) core 1 and enter the given function on core 1 using the passed stack for core 1

core 1 must previously have been reset either as a result of a system reset or by calling multicore_reset_core1

core 1 will use the same vector table as core 0

Parameters
entryFunction entry point
stack_bottomThe bottom (lowest address) of the stack
stack_size_bytesThe size of the stack in bytes (must be a multiple of 4)
See also
multicore_reset_core1

◆ multicore_reset_core1()

void multicore_reset_core1 ( void  )

Reset core 1.

This function can be used to reset core 1 into its initial state (ready for launching code against via multicore_launch_core1 and similar methods)

Note
this function should only be called from core 0
multicore_fifo_push_blocking
void multicore_fifo_push_blocking(uint32_t data)
Push data on to the write FIFO (data to the other core).
Definition: multicore.c:29
multicore_fifo_pop_blocking
uint32_t multicore_fifo_pop_blocking(void)
Pop data from the read FIFO (data from the other core).
Definition: multicore.c:57
stdio.h
tight_loop_contents
static __always_inline void tight_loop_contents(void)
No-op function for the body of tight loops.
Definition: platform.h:358
multicore_launch_core1
void multicore_launch_core1(void(*entry)(void))
Run code on core 1.
Definition: multicore.c:124
multicore.h
stdlib.h
stdio_init_all
bool stdio_init_all(void)
Initialize all of the present standard stdio types that are linked into the binary.
Definition: stdio.c:283