Unverified Commit 5c186d84 authored by Magnus Nordlander's avatar Magnus Nordlander Committed by GitHub

Added ability to reset and relaunch core 1 (#493)

parent 25b34913
...@@ -94,6 +94,18 @@ public: ...@@ -94,6 +94,18 @@ public:
// once otherIdled == false. // once otherIdled == false.
} }
void clear() {
uint32_t val;
while (queue_try_remove(&_queue[0], &val)) {
tight_loop_contents();
}
while (queue_try_remove(&_queue[1], &val)) {
tight_loop_contents();
}
}
private: private:
static void __no_inline_not_in_flash_func(_irq)() { static void __no_inline_not_in_flash_func(_irq)() {
multicore_fifo_clear_irq(); multicore_fifo_clear_irq();
...@@ -118,6 +130,8 @@ private: ...@@ -118,6 +130,8 @@ private:
class RP2040; class RP2040;
extern RP2040 rp2040; extern RP2040 rp2040;
extern "C" void main1();
class RP2040 { class RP2040 {
public: public:
RP2040() { RP2040() {
...@@ -172,6 +186,12 @@ public: ...@@ -172,6 +186,12 @@ public:
fifo.resumeOtherCore(); fifo.resumeOtherCore();
} }
void restartCore1() {
multicore_reset_core1();
fifo.clear();
multicore_launch_core1(main1);
}
// Multicore comms FIFO // Multicore comms FIFO
_MFIFO fifo; _MFIFO fifo;
......
...@@ -41,7 +41,7 @@ void initVariant() { } ...@@ -41,7 +41,7 @@ void initVariant() { }
// Optional 2nd core setup and loop // Optional 2nd core setup and loop
extern void setup1() __attribute__((weak)); extern void setup1() __attribute__((weak));
extern void loop1() __attribute__((weak)); extern void loop1() __attribute__((weak));
static void main1() { extern "C" void main1() {
rp2040.fifo.registerCore(); rp2040.fifo.registerCore();
if (setup1) { if (setup1) {
setup1(); setup1();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment