Merge pull request #4362 from adom-inc/rp-currrent-core

rp: add current_core api
This commit is contained in:
Ulf Lilleengen 2025-07-03 11:34:27 +02:00 committed by GitHub
commit ec812d3e66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,26 @@ const PAUSE_TOKEN: u32 = 0xDEADBEEF;
const RESUME_TOKEN: u32 = !0xDEADBEEF;
static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false);
/// Represents a partiticular CPU core (SIO_CPUID)
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[repr(u8)]
pub enum CoreId {
/// Core 0
Core0 = 0x0,
/// Core 1
Core1 = 0x1,
}
/// Gets which core we are currently executing from
pub fn current_core() -> CoreId {
if pac::SIO.cpuid().read() == 0 {
CoreId::Core0
} else {
CoreId::Core1
}
}
#[inline(always)]
unsafe fn core1_setup(stack_bottom: *mut usize) {
if install_stack_guard(stack_bottom).is_err() {