nrf52840_pac/spis0/
semstat.rs

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#[doc = "Register `SEMSTAT` reader"]
pub struct R(crate::R<SEMSTAT_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<SEMSTAT_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl From<crate::R<SEMSTAT_SPEC>> for R {
    #[inline(always)]
    fn from(reader: crate::R<SEMSTAT_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Field `SEMSTAT` reader - Semaphore status"]
pub type SEMSTAT_R = crate::FieldReader<u8, SEMSTAT_A>;
#[doc = "Semaphore status\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum SEMSTAT_A {
    #[doc = "0: Semaphore is free"]
    FREE = 0,
    #[doc = "1: Semaphore is assigned to CPU"]
    CPU = 1,
    #[doc = "2: Semaphore is assigned to SPI slave"]
    SPIS = 2,
    #[doc = "3: Semaphore is assigned to SPI but a handover to the CPU is pending"]
    CPUPENDING = 3,
}
impl From<SEMSTAT_A> for u8 {
    #[inline(always)]
    fn from(variant: SEMSTAT_A) -> Self {
        variant as _
    }
}
impl SEMSTAT_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> SEMSTAT_A {
        match self.bits {
            0 => SEMSTAT_A::FREE,
            1 => SEMSTAT_A::CPU,
            2 => SEMSTAT_A::SPIS,
            3 => SEMSTAT_A::CPUPENDING,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `FREE`"]
    #[inline(always)]
    pub fn is_free(&self) -> bool {
        *self == SEMSTAT_A::FREE
    }
    #[doc = "Checks if the value of the field is `CPU`"]
    #[inline(always)]
    pub fn is_cpu(&self) -> bool {
        *self == SEMSTAT_A::CPU
    }
    #[doc = "Checks if the value of the field is `SPIS`"]
    #[inline(always)]
    pub fn is_spis(&self) -> bool {
        *self == SEMSTAT_A::SPIS
    }
    #[doc = "Checks if the value of the field is `CPUPENDING`"]
    #[inline(always)]
    pub fn is_cpupending(&self) -> bool {
        *self == SEMSTAT_A::CPUPENDING
    }
}
impl R {
    #[doc = "Bits 0:1 - Semaphore status"]
    #[inline(always)]
    pub fn semstat(&self) -> SEMSTAT_R {
        SEMSTAT_R::new((self.bits & 3) as u8)
    }
}
#[doc = "Semaphore status register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [semstat](index.html) module"]
pub struct SEMSTAT_SPEC;
impl crate::RegisterSpec for SEMSTAT_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [semstat::R](R) reader structure"]
impl crate::Readable for SEMSTAT_SPEC {
    type Reader = R;
}
#[doc = "`reset()` method sets SEMSTAT to value 0x01"]
impl crate::Resettable for SEMSTAT_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0x01
    }
}