Skip to main content

k22f/can0/
esr2.rs

1#[doc = "Reader of register ESR2"]
2pub type R = crate::R<u32, super::ESR2>;
3#[doc = "Inactive Mailbox\n\nValue on reset: 0"]
4#[derive(Clone, Copy, Debug, PartialEq)]
5pub enum IMB_A {
6    #[doc = "0: If ESR2\\[VPS\\]
7is asserted, the ESR2\\[LPTM\\]
8is not an inactive Mailbox."]
9    _0 = 0,
10    #[doc = "1: If ESR2\\[VPS\\]
11is asserted, there is at least one inactive Mailbox. LPTM content is the number of the first one."]
12    _1 = 1,
13}
14impl From<IMB_A> for bool {
15    #[inline(always)]
16    fn from(variant: IMB_A) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Reader of field `IMB`"]
21pub type IMB_R = crate::R<bool, IMB_A>;
22impl IMB_R {
23    #[doc = r"Get enumerated values variant"]
24    #[inline(always)]
25    pub fn variant(&self) -> IMB_A {
26        match self.bits {
27            false => IMB_A::_0,
28            true => IMB_A::_1,
29        }
30    }
31    #[doc = "Checks if the value of the field is `_0`"]
32    #[inline(always)]
33    pub fn is_0(&self) -> bool {
34        *self == IMB_A::_0
35    }
36    #[doc = "Checks if the value of the field is `_1`"]
37    #[inline(always)]
38    pub fn is_1(&self) -> bool {
39        *self == IMB_A::_1
40    }
41}
42#[doc = "Valid Priority Status\n\nValue on reset: 0"]
43#[derive(Clone, Copy, Debug, PartialEq)]
44pub enum VPS_A {
45    #[doc = "0: Contents of IMB and LPTM are invalid."]
46    _0 = 0,
47    #[doc = "1: Contents of IMB and LPTM are valid."]
48    _1 = 1,
49}
50impl From<VPS_A> for bool {
51    #[inline(always)]
52    fn from(variant: VPS_A) -> Self {
53        variant as u8 != 0
54    }
55}
56#[doc = "Reader of field `VPS`"]
57pub type VPS_R = crate::R<bool, VPS_A>;
58impl VPS_R {
59    #[doc = r"Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> VPS_A {
62        match self.bits {
63            false => VPS_A::_0,
64            true => VPS_A::_1,
65        }
66    }
67    #[doc = "Checks if the value of the field is `_0`"]
68    #[inline(always)]
69    pub fn is_0(&self) -> bool {
70        *self == VPS_A::_0
71    }
72    #[doc = "Checks if the value of the field is `_1`"]
73    #[inline(always)]
74    pub fn is_1(&self) -> bool {
75        *self == VPS_A::_1
76    }
77}
78#[doc = "Reader of field `LPTM`"]
79pub type LPTM_R = crate::R<u8, u8>;
80impl R {
81    #[doc = "Bit 13 - Inactive Mailbox"]
82    #[inline(always)]
83    pub fn imb(&self) -> IMB_R {
84        IMB_R::new(((self.bits >> 13) & 0x01) != 0)
85    }
86    #[doc = "Bit 14 - Valid Priority Status"]
87    #[inline(always)]
88    pub fn vps(&self) -> VPS_R {
89        VPS_R::new(((self.bits >> 14) & 0x01) != 0)
90    }
91    #[doc = "Bits 16:22 - Lowest Priority Tx Mailbox"]
92    #[inline(always)]
93    pub fn lptm(&self) -> LPTM_R {
94        LPTM_R::new(((self.bits >> 16) & 0x7f) as u8)
95    }
96}