From 6ea69df2fa2308ca773148b946fb9920079f47ff Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Wed, 14 Feb 2024 10:13:50 +0100 Subject: [PATCH] Testing multicore --- CMakeLists.txt | 1 + src/raspi_keyer.cpp | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e97dcc4..72fb7c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ target_link_libraries(raspi_keyer hardware_exception hardware_pwm pico_flash + pico_multicore ) pico_add_extra_outputs(raspi_keyer) diff --git a/src/raspi_keyer.cpp b/src/raspi_keyer.cpp index 984a45c..e51e3a5 100644 --- a/src/raspi_keyer.cpp +++ b/src/raspi_keyer.cpp @@ -1,6 +1,8 @@ #include #include "pico/stdlib.h" +#include "pico/multicore.h" +#include "pico/util/queue.h" #include "settings.h" #include "keyer.h" @@ -15,6 +17,8 @@ extern const uint LEFT_PADDLE_PIN = 14; extern const uint RIGHT_PADDLE_PIN = 15; extern const uint BUZZER_PIN = 13; +queue_t keyerQueue; + void setup() { stdio_init_all(); @@ -33,6 +37,20 @@ void setup() sleep_ms(1000); } +void core1_main() +{ + Settings settings; + queue_remove_blocking(&keyerQueue, &settings); + + Keyer keyer(settings.wpm, settings.mode); + + while (true) + { + keyer.run(); + } + +} + int main() { timer_hw->dbgpause = 0; // workaround for problem with debug and sleep_ms @@ -42,12 +60,14 @@ int main() Settings settings{read_settings()}; - Keyer keyer(settings.wpm, settings.mode); + /*Keyer keyer(settings.wpm, settings.mode);*/ + + queue_add_blocking(&keyerQueue, &settings); while (true) { - keyer.run(); - } + sleep_ms(100); + } return 0; }