Skip to main content

mcxa_pac/can0/wmb/
wmb_cs.rs

1#[doc = "Register `WMB_CS` reader"]
2pub type R = crate::R<WmbCsSpec>;
3#[doc = "Field `DLC` reader - Length of Data in Bytes"]
4pub type DlcR = crate::FieldReader;
5#[doc = "Remote Transmission Request\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Rtr {
9    #[doc = "0: Data"]
10    NotRemote = 0,
11    #[doc = "1: Remote"]
12    Remote = 1,
13}
14impl From<Rtr> for bool {
15    #[inline(always)]
16    fn from(variant: Rtr) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `RTR` reader - Remote Transmission Request"]
21pub type RtrR = crate::BitReader<Rtr>;
22impl RtrR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Rtr {
26        match self.bits {
27            false => Rtr::NotRemote,
28            true => Rtr::Remote,
29        }
30    }
31    #[doc = "Data"]
32    #[inline(always)]
33    pub fn is_not_remote(&self) -> bool {
34        *self == Rtr::NotRemote
35    }
36    #[doc = "Remote"]
37    #[inline(always)]
38    pub fn is_remote(&self) -> bool {
39        *self == Rtr::Remote
40    }
41}
42#[doc = "ID Extended Bit\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum Ide {
46    #[doc = "0: Standard"]
47    Standard = 0,
48    #[doc = "1: Extended"]
49    Extended = 1,
50}
51impl From<Ide> for bool {
52    #[inline(always)]
53    fn from(variant: Ide) -> Self {
54        variant as u8 != 0
55    }
56}
57#[doc = "Field `IDE` reader - ID Extended Bit"]
58pub type IdeR = crate::BitReader<Ide>;
59impl IdeR {
60    #[doc = "Get enumerated values variant"]
61    #[inline(always)]
62    pub const fn variant(&self) -> Ide {
63        match self.bits {
64            false => Ide::Standard,
65            true => Ide::Extended,
66        }
67    }
68    #[doc = "Standard"]
69    #[inline(always)]
70    pub fn is_standard(&self) -> bool {
71        *self == Ide::Standard
72    }
73    #[doc = "Extended"]
74    #[inline(always)]
75    pub fn is_extended(&self) -> bool {
76        *self == Ide::Extended
77    }
78}
79#[doc = "Substitute Remote Request\n\nValue on reset: 0"]
80#[cfg_attr(feature = "defmt", derive(defmt::Format))]
81#[derive(Clone, Copy, Debug, PartialEq, Eq)]
82pub enum Srr {
83    #[doc = "0: Dominant"]
84    Dominant = 0,
85    #[doc = "1: Recessive"]
86    Recessive = 1,
87}
88impl From<Srr> for bool {
89    #[inline(always)]
90    fn from(variant: Srr) -> Self {
91        variant as u8 != 0
92    }
93}
94#[doc = "Field `SRR` reader - Substitute Remote Request"]
95pub type SrrR = crate::BitReader<Srr>;
96impl SrrR {
97    #[doc = "Get enumerated values variant"]
98    #[inline(always)]
99    pub const fn variant(&self) -> Srr {
100        match self.bits {
101            false => Srr::Dominant,
102            true => Srr::Recessive,
103        }
104    }
105    #[doc = "Dominant"]
106    #[inline(always)]
107    pub fn is_dominant(&self) -> bool {
108        *self == Srr::Dominant
109    }
110    #[doc = "Recessive"]
111    #[inline(always)]
112    pub fn is_recessive(&self) -> bool {
113        *self == Srr::Recessive
114    }
115}
116impl R {
117    #[doc = "Bits 16:19 - Length of Data in Bytes"]
118    #[inline(always)]
119    pub fn dlc(&self) -> DlcR {
120        DlcR::new(((self.bits >> 16) & 0x0f) as u8)
121    }
122    #[doc = "Bit 20 - Remote Transmission Request"]
123    #[inline(always)]
124    pub fn rtr(&self) -> RtrR {
125        RtrR::new(((self.bits >> 20) & 1) != 0)
126    }
127    #[doc = "Bit 21 - ID Extended Bit"]
128    #[inline(always)]
129    pub fn ide(&self) -> IdeR {
130        IdeR::new(((self.bits >> 21) & 1) != 0)
131    }
132    #[doc = "Bit 22 - Substitute Remote Request"]
133    #[inline(always)]
134    pub fn srr(&self) -> SrrR {
135        SrrR::new(((self.bits >> 22) & 1) != 0)
136    }
137}
138#[cfg(feature = "debug")]
139impl core::fmt::Debug for R {
140    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
141        f.debug_struct("WMB_CS")
142            .field("dlc", &self.dlc())
143            .field("rtr", &self.rtr())
144            .field("ide", &self.ide())
145            .field("srr", &self.srr())
146            .finish()
147    }
148}
149#[doc = "Wake-Up Message Buffer\n\nYou can [`read`](crate::Reg::read) this register and get [`wmb_cs::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
150pub struct WmbCsSpec;
151impl crate::RegisterSpec for WmbCsSpec {
152    type Ux = u32;
153}
154#[doc = "`read()` method returns [`wmb_cs::R`](R) reader structure"]
155impl crate::Readable for WmbCsSpec {}
156#[doc = "`reset()` method sets WMB_CS to value 0"]
157impl crate::Resettable for WmbCsSpec {}