1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use crate::thr::{prelude::*, wake::WakeInt, NvicBlock}; use core::task::Waker; /// An interrupt token. pub trait IntToken: ThrToken { /// NVIC block the interrupt belongs to. type NvicBlock: NvicBlock; /// The number of the interrupt. const INT_NUM: u16; /// Wakes up the thread. /// /// # Safety /// /// This function doesn't check for the interrupt token ownership. #[inline] unsafe fn wakeup_unchecked() { WakeInt::new(Self::INT_NUM).wakeup(); } /// Returns a handle for waking up a thread. /// /// # Safety /// /// This function doesn't check for the interrupt token ownership. #[inline] unsafe fn waker_unchecked() -> Waker { WakeInt::new(Self::INT_NUM).to_waker() } }