diff options
Diffstat (limited to 'embassy-rp/src/multicore.rs')
| -rw-r--r-- | embassy-rp/src/multicore.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index adedc98ad..572d8db91 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | //! use embassy_rp::multicore::Stack; | 14 | //! use embassy_rp::multicore::Stack; |
| 15 | //! use static_cell::StaticCell; | 15 | //! use static_cell::StaticCell; |
| 16 | //! use embassy_executor::Executor; | 16 | //! use embassy_executor::Executor; |
| 17 | //! use core::ptr::addr_of_mut; | ||
| 17 | //! | 18 | //! |
| 18 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); | 19 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); |
| 19 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); | 20 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); |
| @@ -36,7 +37,7 @@ | |||
| 36 | //! fn main() -> ! { | 37 | //! fn main() -> ! { |
| 37 | //! let p = embassy_rp::init(Default::default()); | 38 | //! let p = embassy_rp::init(Default::default()); |
| 38 | //! | 39 | //! |
| 39 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut CORE1_STACK }, move || { | 40 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut *addr_of_mut!(CORE1_STACK) }, move || { |
| 40 | //! let executor1 = EXECUTOR1.init(Executor::new()); | 41 | //! let executor1 = EXECUTOR1.init(Executor::new()); |
| 41 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); | 42 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); |
| 42 | //! }); | 43 | //! }); |
| @@ -47,17 +48,17 @@ | |||
| 47 | //! ``` | 48 | //! ``` |
| 48 | 49 | ||
| 49 | use core::mem::ManuallyDrop; | 50 | use core::mem::ManuallyDrop; |
| 50 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 51 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 51 | 52 | ||
| 52 | use crate::interrupt::InterruptExt; | 53 | use crate::interrupt::InterruptExt; |
| 53 | use crate::peripherals::CORE1; | 54 | use crate::peripherals::CORE1; |
| 54 | use crate::{gpio, install_stack_guard, interrupt, pac, Peri}; | 55 | use crate::{Peri, gpio, install_stack_guard, interrupt, pac}; |
| 55 | 56 | ||
| 56 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; | 57 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; |
| 57 | const RESUME_TOKEN: u32 = !0xDEADBEEF; | 58 | const RESUME_TOKEN: u32 = !0xDEADBEEF; |
| 58 | static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); | 59 | static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); |
| 59 | 60 | ||
| 60 | /// Represents a partiticular CPU core (SIO_CPUID) | 61 | /// Represents a particular CPU core (SIO_CPUID) |
| 61 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] | 62 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] |
| 62 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 63 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 63 | #[repr(u8)] | 64 | #[repr(u8)] |
| @@ -110,7 +111,6 @@ impl<const SIZE: usize> Stack<SIZE> { | |||
| 110 | 111 | ||
| 111 | #[cfg(all(feature = "rt", feature = "rp2040"))] | 112 | #[cfg(all(feature = "rt", feature = "rp2040"))] |
| 112 | #[interrupt] | 113 | #[interrupt] |
| 113 | #[link_section = ".data.ram_func"] | ||
| 114 | unsafe fn SIO_IRQ_PROC1() { | 114 | unsafe fn SIO_IRQ_PROC1() { |
| 115 | let sio = pac::SIO; | 115 | let sio = pac::SIO; |
| 116 | // Clear IRQ | 116 | // Clear IRQ |
| @@ -135,7 +135,6 @@ unsafe fn SIO_IRQ_PROC1() { | |||
| 135 | 135 | ||
| 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] | 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] |
| 137 | #[interrupt] | 137 | #[interrupt] |
| 138 | #[link_section = ".data.ram_func"] | ||
| 139 | unsafe fn SIO_IRQ_FIFO() { | 138 | unsafe fn SIO_IRQ_FIFO() { |
| 140 | let sio = pac::SIO; | 139 | let sio = pac::SIO; |
| 141 | // Clear IRQ | 140 | // Clear IRQ |
