mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 04:10:25 +00:00
Merge pull request #4362 from adom-inc/rp-currrent-core
rp: add current_core api
This commit is contained in:
commit
ec812d3e66
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user