diff options
| author | Ulf Lilleengen <[email protected]> | 2025-07-03 11:34:27 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-03 11:34:27 +0200 |
| commit | ec812d3e66e699db671f262239dc7c277c6cef2d (patch) | |
| tree | ff7283f3e0c2516b1d25901bb50743c6a53d1ea3 | |
| parent | 2d74c09529752bb122f3cc346b75de5588efedc3 (diff) | |
| parent | 3c0d5063fe59c6831fbcfeae04338606aec05d05 (diff) | |
Merge pull request #4362 from adom-inc/rp-currrent-core
rp: add current_core api
| -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() { |
