3 #include "pico/stdlib.h"
4 #include "pico/multicore.h"
9 typedef void (*ThreadCB)(
void* arg);
28 bool start(ThreadCB callback,
void* ptr=
nullptr){
32 staticCallback(callback);
35 multicore_launch_core1(callback_handler);
38 Logger.
info(
"Thread started on core1");
40 Logger.
info(
"Thread not started - because one is already active");
47 multicore_reset_core1();
56 static void callback_handler(){
57 ThreadCB cb = staticCallback();
58 void* ptr = staticPtr();
65 static void *staticPtr(
void* ptr =
nullptr){
66 static void *stat_ptr = {ptr};
71 static ThreadCB staticCallback(ThreadCB cb =
nullptr) {
72 static ThreadCB stat_cb = {cb};
78 bool started(
int flag=-1){
79 static bool started_flag;
virtual void info(const char *str, const char *str1=nullptr, const char *str2=nullptr)
logs an info message
Definition: PicoLogger.h:50
Adds support for running code on the second processor core (core1)
Definition: PicoThread.h:17
bool isRunning()
check if the core1 has been started and is not stoped
Definition: PicoThread.h:52
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:28
void stop()
resets the core 1
Definition: PicoThread.h:46
Pico Arduino Framework.
Definition: Arduino.cpp:26