Skip to main content

mcxa_pac/can0/
wu_mtc.rs

1#[doc = "Register `WU_MTC` reader"]
2pub type R = crate::R<WuMtcSpec>;
3#[doc = "Register `WU_MTC` writer"]
4pub type W = crate::W<WuMtcSpec>;
5#[doc = "Field `MCOUNTER` reader - Number of Matches in Pretended Networking"]
6pub type McounterR = crate::FieldReader;
7#[doc = "Wake-up by Match Flag\n\nValue on reset: 0"]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum Wumf {
11    #[doc = "0: No event detected"]
12    NoMatch = 0,
13    #[doc = "1: Event detected"]
14    Match = 1,
15}
16impl From<Wumf> for bool {
17    #[inline(always)]
18    fn from(variant: Wumf) -> Self {
19        variant as u8 != 0
20    }
21}
22#[doc = "Field `WUMF` reader - Wake-up by Match Flag"]
23pub type WumfR = crate::BitReader<Wumf>;
24impl WumfR {
25    #[doc = "Get enumerated values variant"]
26    #[inline(always)]
27    pub const fn variant(&self) -> Wumf {
28        match self.bits {
29            false => Wumf::NoMatch,
30            true => Wumf::Match,
31        }
32    }
33    #[doc = "No event detected"]
34    #[inline(always)]
35    pub fn is_no_match(&self) -> bool {
36        *self == Wumf::NoMatch
37    }
38    #[doc = "Event detected"]
39    #[inline(always)]
40    pub fn is_match(&self) -> bool {
41        *self == Wumf::Match
42    }
43}
44#[doc = "Field `WUMF` writer - Wake-up by Match Flag"]
45pub type WumfW<'a, REG> = crate::BitWriter1C<'a, REG, Wumf>;
46impl<'a, REG> WumfW<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    #[doc = "No event detected"]
51    #[inline(always)]
52    pub fn no_match(self) -> &'a mut crate::W<REG> {
53        self.variant(Wumf::NoMatch)
54    }
55    #[doc = "Event detected"]
56    #[inline(always)]
57    pub fn match_(self) -> &'a mut crate::W<REG> {
58        self.variant(Wumf::Match)
59    }
60}
61#[doc = "Wake-up by Timeout Flag Bit\n\nValue on reset: 0"]
62#[cfg_attr(feature = "defmt", derive(defmt::Format))]
63#[derive(Clone, Copy, Debug, PartialEq, Eq)]
64pub enum Wtof {
65    #[doc = "0: No event detected"]
66    NoWakeup = 0,
67    #[doc = "1: Event detected"]
68    Wakeup = 1,
69}
70impl From<Wtof> for bool {
71    #[inline(always)]
72    fn from(variant: Wtof) -> Self {
73        variant as u8 != 0
74    }
75}
76#[doc = "Field `WTOF` reader - Wake-up by Timeout Flag Bit"]
77pub type WtofR = crate::BitReader<Wtof>;
78impl WtofR {
79    #[doc = "Get enumerated values variant"]
80    #[inline(always)]
81    pub const fn variant(&self) -> Wtof {
82        match self.bits {
83            false => Wtof::NoWakeup,
84            true => Wtof::Wakeup,
85        }
86    }
87    #[doc = "No event detected"]
88    #[inline(always)]
89    pub fn is_no_wakeup(&self) -> bool {
90        *self == Wtof::NoWakeup
91    }
92    #[doc = "Event detected"]
93    #[inline(always)]
94    pub fn is_wakeup(&self) -> bool {
95        *self == Wtof::Wakeup
96    }
97}
98#[doc = "Field `WTOF` writer - Wake-up by Timeout Flag Bit"]
99pub type WtofW<'a, REG> = crate::BitWriter1C<'a, REG, Wtof>;
100impl<'a, REG> WtofW<'a, REG>
101where
102    REG: crate::Writable + crate::RegisterSpec,
103{
104    #[doc = "No event detected"]
105    #[inline(always)]
106    pub fn no_wakeup(self) -> &'a mut crate::W<REG> {
107        self.variant(Wtof::NoWakeup)
108    }
109    #[doc = "Event detected"]
110    #[inline(always)]
111    pub fn wakeup(self) -> &'a mut crate::W<REG> {
112        self.variant(Wtof::Wakeup)
113    }
114}
115impl R {
116    #[doc = "Bits 8:15 - Number of Matches in Pretended Networking"]
117    #[inline(always)]
118    pub fn mcounter(&self) -> McounterR {
119        McounterR::new(((self.bits >> 8) & 0xff) as u8)
120    }
121    #[doc = "Bit 16 - Wake-up by Match Flag"]
122    #[inline(always)]
123    pub fn wumf(&self) -> WumfR {
124        WumfR::new(((self.bits >> 16) & 1) != 0)
125    }
126    #[doc = "Bit 17 - Wake-up by Timeout Flag Bit"]
127    #[inline(always)]
128    pub fn wtof(&self) -> WtofR {
129        WtofR::new(((self.bits >> 17) & 1) != 0)
130    }
131}
132#[cfg(feature = "debug")]
133impl core::fmt::Debug for R {
134    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
135        f.debug_struct("WU_MTC")
136            .field("mcounter", &self.mcounter())
137            .field("wumf", &self.wumf())
138            .field("wtof", &self.wtof())
139            .finish()
140    }
141}
142impl W {
143    #[doc = "Bit 16 - Wake-up by Match Flag"]
144    #[inline(always)]
145    pub fn wumf(&mut self) -> WumfW<'_, WuMtcSpec> {
146        WumfW::new(self, 16)
147    }
148    #[doc = "Bit 17 - Wake-up by Timeout Flag Bit"]
149    #[inline(always)]
150    pub fn wtof(&mut self) -> WtofW<'_, WuMtcSpec> {
151        WtofW::new(self, 17)
152    }
153}
154#[doc = "Pretended Networking Wake-Up Match\n\nYou can [`read`](crate::Reg::read) this register and get [`wu_mtc::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`wu_mtc::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
155pub struct WuMtcSpec;
156impl crate::RegisterSpec for WuMtcSpec {
157    type Ux = u32;
158}
159#[doc = "`read()` method returns [`wu_mtc::R`](R) reader structure"]
160impl crate::Readable for WuMtcSpec {}
161#[doc = "`write(|w| ..)` method takes [`wu_mtc::W`](W) writer structure"]
162impl crate::Writable for WuMtcSpec {
163    type Safety = crate::Unsafe;
164    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x0003_0000;
165}
166#[doc = "`reset()` method sets WU_MTC to value 0"]
167impl crate::Resettable for WuMtcSpec {}