3 #include "pico/stdlib.h"
4 #include "pico/multicore.h"
7 typedef void (*ThreadCB)(
void* arg);
26 bool start(ThreadCB callback,
void* ptr=
nullptr){
30 staticCallback(callback);
33 multicore_launch_core1(callback_handler);
36 Logger.info(
"Thread started on core1");
38 Logger.info(
"Thread not started - because one is already active");
45 multicore_reset_core1();
59 static void callback_handler(){
60 ThreadCB cb = staticCallback();
61 void* ptr = staticPtr();
68 static void *staticPtr(
void* ptr =
nullptr){
69 static void *stat_ptr = {ptr};
74 static ThreadCB staticCallback(ThreadCB cb =
nullptr) {
75 static ThreadCB stat_cb = {cb};
81 bool started(
int flag=-1){
82 static bool started_flag;
Adds support for running code on the second processor core (core1)
Definition: PicoThread.h:15
bool start(ThreadCB callback, void *ptr=nullptr)
Run code on core 1 - we can pass a reference to an object which will be given to the callback as argu...
Definition: PicoThread.h:26
bool isRunning()
check if the core1 has been started and is not stoped
Definition: PicoThread.h:55
void stop()
resets the core 1
Definition: PicoThread.h:44