diff options
Diffstat (limited to 'embassy-rp/src')
| -rw-r--r-- | embassy-rp/src/multicore.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index d10b6837c..64065fcba 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -57,6 +57,26 @@ const PAUSE_TOKEN: u32 = 0xDEADBEEF; | |||
| 57 | const RESUME_TOKEN: u32 = !0xDEADBEEF; | 57 | const RESUME_TOKEN: u32 = !0xDEADBEEF; |
| 58 | static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); | 58 | static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); |
| 59 | 59 | ||
| 60 | /// Represents a partiticular CPU core (SIO_CPUID) | ||
| 61 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] | ||
| 62 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 63 | #[repr(u8)] | ||
| 64 | pub enum CoreId { | ||
| 65 | /// Core 0 | ||
| 66 | Core0 = 0x0, | ||
| 67 | /// Core 1 | ||
| 68 | Core1 = 0x1, | ||
| 69 | } | ||
| 70 | |||
| 71 | /// Gets which core we are currently executing from | ||
| 72 | pub fn current_core() -> CoreId { | ||
| 73 | if pac::SIO.cpuid().read() == 0 { | ||
| 74 | CoreId::Core0 | ||
| 75 | } else { | ||
| 76 | CoreId::Core1 | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 60 | #[inline(always)] | 80 | #[inline(always)] |
| 61 | unsafe fn core1_setup(stack_bottom: *mut usize) { | 81 | unsafe fn core1_setup(stack_bottom: *mut usize) { |
| 62 | if install_stack_guard(stack_bottom).is_err() { | 82 | if install_stack_guard(stack_bottom).is_err() { |
