cortex_m/register/
primask.rs

1//! Priority mask register
2
3/// All exceptions with configurable priority are ...
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub enum Primask {
6    /// Active
7    Active,
8    /// Inactive
9    Inactive,
10}
11
12impl Primask {
13    /// All exceptions with configurable priority are active
14    #[inline]
15    pub fn is_active(self) -> bool {
16        self == Primask::Active
17    }
18
19    /// All exceptions with configurable priority are inactive
20    #[inline]
21    pub fn is_inactive(self) -> bool {
22        self == Primask::Inactive
23    }
24}
25
26/// Reads the CPU register
27#[inline]
28pub fn read() -> Primask {
29    let r: u32 = call_asm!(__primask_r() -> u32);
30    if r & (1 << 0) == (1 << 0) {
31        Primask::Inactive
32    } else {
33        Primask::Active
34    }
35}