aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorAdrian Wowk <[email protected]>2025-07-02 12:31:38 -0500
committerAdrian Wowk <[email protected]>2025-07-02 12:31:38 -0500
commit3c0d5063fe59c6831fbcfeae04338606aec05d05 (patch)
tree9c1e86d7ab88b6bd97cba4cdf2ab3f6ed14c5690 /embassy-rp
parentb528ed06e3025e0803e8fd6dc53ac968df9f49bc (diff)
rp: add current_core api
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/src/multicore.rs20
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;
57const RESUME_TOKEN: u32 = !0xDEADBEEF; 57const RESUME_TOKEN: u32 = !0xDEADBEEF;
58static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); 58static 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)]
64pub 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
72pub 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)]
61unsafe fn core1_setup(stack_bottom: *mut usize) { 81unsafe 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() {