mcxa_pac/can0/
esr2.rs

1#[doc = "Register `ESR2` reader"]
2pub type R = crate::R<Esr2Spec>;
3#[doc = "Inactive Message Buffer\n\nValue on reset: 0"]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum Imb {
7    #[doc = "0: Message buffer indicated by ESR2\\[LPTM\\] is not inactive."]
8    InactiveMailboxNo = 0,
9    #[doc = "1: At least one message buffer is inactive."]
10    InactiveMailboxYes = 1,
11}
12impl From<Imb> for bool {
13    #[inline(always)]
14    fn from(variant: Imb) -> Self {
15        variant as u8 != 0
16    }
17}
18#[doc = "Field `IMB` reader - Inactive Message Buffer"]
19pub type ImbR = crate::BitReader<Imb>;
20impl ImbR {
21    #[doc = "Get enumerated values variant"]
22    #[inline(always)]
23    pub const fn variant(&self) -> Imb {
24        match self.bits {
25            false => Imb::InactiveMailboxNo,
26            true => Imb::InactiveMailboxYes,
27        }
28    }
29    #[doc = "Message buffer indicated by ESR2\\[LPTM\\] is not inactive."]
30    #[inline(always)]
31    pub fn is_inactive_mailbox_no(&self) -> bool {
32        *self == Imb::InactiveMailboxNo
33    }
34    #[doc = "At least one message buffer is inactive."]
35    #[inline(always)]
36    pub fn is_inactive_mailbox_yes(&self) -> bool {
37        *self == Imb::InactiveMailboxYes
38    }
39}
40#[doc = "Valid Priority Status\n\nValue on reset: 0"]
41#[cfg_attr(feature = "defmt", derive(defmt::Format))]
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum Vps {
44    #[doc = "0: Invalid"]
45    Invalid = 0,
46    #[doc = "1: Valid"]
47    Valid = 1,
48}
49impl From<Vps> for bool {
50    #[inline(always)]
51    fn from(variant: Vps) -> Self {
52        variant as u8 != 0
53    }
54}
55#[doc = "Field `VPS` reader - Valid Priority Status"]
56pub type VpsR = crate::BitReader<Vps>;
57impl VpsR {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub const fn variant(&self) -> Vps {
61        match self.bits {
62            false => Vps::Invalid,
63            true => Vps::Valid,
64        }
65    }
66    #[doc = "Invalid"]
67    #[inline(always)]
68    pub fn is_invalid(&self) -> bool {
69        *self == Vps::Invalid
70    }
71    #[doc = "Valid"]
72    #[inline(always)]
73    pub fn is_valid(&self) -> bool {
74        *self == Vps::Valid
75    }
76}
77#[doc = "Field `LPTM` reader - Lowest Priority TX Message Buffer"]
78pub type LptmR = crate::FieldReader;
79impl R {
80    #[doc = "Bit 13 - Inactive Message Buffer"]
81    #[inline(always)]
82    pub fn imb(&self) -> ImbR {
83        ImbR::new(((self.bits >> 13) & 1) != 0)
84    }
85    #[doc = "Bit 14 - Valid Priority Status"]
86    #[inline(always)]
87    pub fn vps(&self) -> VpsR {
88        VpsR::new(((self.bits >> 14) & 1) != 0)
89    }
90    #[doc = "Bits 16:22 - Lowest Priority TX Message Buffer"]
91    #[inline(always)]
92    pub fn lptm(&self) -> LptmR {
93        LptmR::new(((self.bits >> 16) & 0x7f) as u8)
94    }
95}
96#[cfg(feature = "debug")]
97impl core::fmt::Debug for R {
98    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
99        f.debug_struct("ESR2")
100            .field("imb", &self.imb())
101            .field("vps", &self.vps())
102            .field("lptm", &self.lptm())
103            .finish()
104    }
105}
106#[doc = "Error and Status 2\n\nYou can [`read`](crate::Reg::read) this register and get [`esr2::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
107pub struct Esr2Spec;
108impl crate::RegisterSpec for Esr2Spec {
109    type Ux = u32;
110}
111#[doc = "`read()` method returns [`esr2::R`](R) reader structure"]
112impl crate::Readable for Esr2Spec {}
113#[doc = "`reset()` method sets ESR2 to value 0"]
114impl crate::Resettable for Esr2Spec {}