mcxa_pac/can0/
erfsr.rs

1#[doc = "Register `ERFSR` reader"]
2pub type R = crate::R<ErfsrSpec>;
3#[doc = "Register `ERFSR` writer"]
4pub type W = crate::W<ErfsrSpec>;
5#[doc = "Field `ERFEL` reader - Enhanced RX FIFO Elements"]
6pub type ErfelR = crate::FieldReader;
7#[doc = "Enhanced RX FIFO Full Flag\n\nValue on reset: 0"]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum Erff {
11    #[doc = "0: Not full"]
12    NotFull = 0,
13    #[doc = "1: Full"]
14    Full = 1,
15}
16impl From<Erff> for bool {
17    #[inline(always)]
18    fn from(variant: Erff) -> Self {
19        variant as u8 != 0
20    }
21}
22#[doc = "Field `ERFF` reader - Enhanced RX FIFO Full Flag"]
23pub type ErffR = crate::BitReader<Erff>;
24impl ErffR {
25    #[doc = "Get enumerated values variant"]
26    #[inline(always)]
27    pub const fn variant(&self) -> Erff {
28        match self.bits {
29            false => Erff::NotFull,
30            true => Erff::Full,
31        }
32    }
33    #[doc = "Not full"]
34    #[inline(always)]
35    pub fn is_not_full(&self) -> bool {
36        *self == Erff::NotFull
37    }
38    #[doc = "Full"]
39    #[inline(always)]
40    pub fn is_full(&self) -> bool {
41        *self == Erff::Full
42    }
43}
44#[doc = "Enhanced RX FIFO Empty Flag\n\nValue on reset: 0"]
45#[cfg_attr(feature = "defmt", derive(defmt::Format))]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum Erfe {
48    #[doc = "0: Not empty"]
49    NotEmpty = 0,
50    #[doc = "1: Empty"]
51    Empty = 1,
52}
53impl From<Erfe> for bool {
54    #[inline(always)]
55    fn from(variant: Erfe) -> Self {
56        variant as u8 != 0
57    }
58}
59#[doc = "Field `ERFE` reader - Enhanced RX FIFO Empty Flag"]
60pub type ErfeR = crate::BitReader<Erfe>;
61impl ErfeR {
62    #[doc = "Get enumerated values variant"]
63    #[inline(always)]
64    pub const fn variant(&self) -> Erfe {
65        match self.bits {
66            false => Erfe::NotEmpty,
67            true => Erfe::Empty,
68        }
69    }
70    #[doc = "Not empty"]
71    #[inline(always)]
72    pub fn is_not_empty(&self) -> bool {
73        *self == Erfe::NotEmpty
74    }
75    #[doc = "Empty"]
76    #[inline(always)]
77    pub fn is_empty(&self) -> bool {
78        *self == Erfe::Empty
79    }
80}
81#[doc = "Enhanced RX FIFO Clear\n\nValue on reset: 0"]
82#[cfg_attr(feature = "defmt", derive(defmt::Format))]
83#[derive(Clone, Copy, Debug, PartialEq, Eq)]
84pub enum Erfclr {
85    #[doc = "0: No effect"]
86    NoEffect = 0,
87    #[doc = "1: Clear enhanced RX FIFO content"]
88    Clear = 1,
89}
90impl From<Erfclr> for bool {
91    #[inline(always)]
92    fn from(variant: Erfclr) -> Self {
93        variant as u8 != 0
94    }
95}
96#[doc = "Field `ERFCLR` reader - Enhanced RX FIFO Clear"]
97pub type ErfclrR = crate::BitReader<Erfclr>;
98impl ErfclrR {
99    #[doc = "Get enumerated values variant"]
100    #[inline(always)]
101    pub const fn variant(&self) -> Erfclr {
102        match self.bits {
103            false => Erfclr::NoEffect,
104            true => Erfclr::Clear,
105        }
106    }
107    #[doc = "No effect"]
108    #[inline(always)]
109    pub fn is_no_effect(&self) -> bool {
110        *self == Erfclr::NoEffect
111    }
112    #[doc = "Clear enhanced RX FIFO content"]
113    #[inline(always)]
114    pub fn is_clear(&self) -> bool {
115        *self == Erfclr::Clear
116    }
117}
118#[doc = "Field `ERFCLR` writer - Enhanced RX FIFO Clear"]
119pub type ErfclrW<'a, REG> = crate::BitWriter<'a, REG, Erfclr>;
120impl<'a, REG> ErfclrW<'a, REG>
121where
122    REG: crate::Writable + crate::RegisterSpec,
123{
124    #[doc = "No effect"]
125    #[inline(always)]
126    pub fn no_effect(self) -> &'a mut crate::W<REG> {
127        self.variant(Erfclr::NoEffect)
128    }
129    #[doc = "Clear enhanced RX FIFO content"]
130    #[inline(always)]
131    pub fn clear(self) -> &'a mut crate::W<REG> {
132        self.variant(Erfclr::Clear)
133    }
134}
135#[doc = "Enhanced RX FIFO Data Available Flag\n\nValue on reset: 0"]
136#[cfg_attr(feature = "defmt", derive(defmt::Format))]
137#[derive(Clone, Copy, Debug, PartialEq, Eq)]
138pub enum Erfda {
139    #[doc = "0: No such occurrence"]
140    NoMessageStored = 0,
141    #[doc = "1: At least one message stored in Enhanced RX FIFO"]
142    MessageStored = 1,
143}
144impl From<Erfda> for bool {
145    #[inline(always)]
146    fn from(variant: Erfda) -> Self {
147        variant as u8 != 0
148    }
149}
150#[doc = "Field `ERFDA` reader - Enhanced RX FIFO Data Available Flag"]
151pub type ErfdaR = crate::BitReader<Erfda>;
152impl ErfdaR {
153    #[doc = "Get enumerated values variant"]
154    #[inline(always)]
155    pub const fn variant(&self) -> Erfda {
156        match self.bits {
157            false => Erfda::NoMessageStored,
158            true => Erfda::MessageStored,
159        }
160    }
161    #[doc = "No such occurrence"]
162    #[inline(always)]
163    pub fn is_no_message_stored(&self) -> bool {
164        *self == Erfda::NoMessageStored
165    }
166    #[doc = "At least one message stored in Enhanced RX FIFO"]
167    #[inline(always)]
168    pub fn is_message_stored(&self) -> bool {
169        *self == Erfda::MessageStored
170    }
171}
172#[doc = "Field `ERFDA` writer - Enhanced RX FIFO Data Available Flag"]
173pub type ErfdaW<'a, REG> = crate::BitWriter1C<'a, REG, Erfda>;
174impl<'a, REG> ErfdaW<'a, REG>
175where
176    REG: crate::Writable + crate::RegisterSpec,
177{
178    #[doc = "No such occurrence"]
179    #[inline(always)]
180    pub fn no_message_stored(self) -> &'a mut crate::W<REG> {
181        self.variant(Erfda::NoMessageStored)
182    }
183    #[doc = "At least one message stored in Enhanced RX FIFO"]
184    #[inline(always)]
185    pub fn message_stored(self) -> &'a mut crate::W<REG> {
186        self.variant(Erfda::MessageStored)
187    }
188}
189#[doc = "Enhanced RX FIFO Watermark Indication Flag\n\nValue on reset: 0"]
190#[cfg_attr(feature = "defmt", derive(defmt::Format))]
191#[derive(Clone, Copy, Debug, PartialEq, Eq)]
192pub enum Erfwmi {
193    #[doc = "0: No such occurrence"]
194    WatermarkNo = 0,
195    #[doc = "1: Number of messages in FIFO is greater than the watermark"]
196    WatermarkYes = 1,
197}
198impl From<Erfwmi> for bool {
199    #[inline(always)]
200    fn from(variant: Erfwmi) -> Self {
201        variant as u8 != 0
202    }
203}
204#[doc = "Field `ERFWMI` reader - Enhanced RX FIFO Watermark Indication Flag"]
205pub type ErfwmiR = crate::BitReader<Erfwmi>;
206impl ErfwmiR {
207    #[doc = "Get enumerated values variant"]
208    #[inline(always)]
209    pub const fn variant(&self) -> Erfwmi {
210        match self.bits {
211            false => Erfwmi::WatermarkNo,
212            true => Erfwmi::WatermarkYes,
213        }
214    }
215    #[doc = "No such occurrence"]
216    #[inline(always)]
217    pub fn is_watermark_no(&self) -> bool {
218        *self == Erfwmi::WatermarkNo
219    }
220    #[doc = "Number of messages in FIFO is greater than the watermark"]
221    #[inline(always)]
222    pub fn is_watermark_yes(&self) -> bool {
223        *self == Erfwmi::WatermarkYes
224    }
225}
226#[doc = "Field `ERFWMI` writer - Enhanced RX FIFO Watermark Indication Flag"]
227pub type ErfwmiW<'a, REG> = crate::BitWriter1C<'a, REG, Erfwmi>;
228impl<'a, REG> ErfwmiW<'a, REG>
229where
230    REG: crate::Writable + crate::RegisterSpec,
231{
232    #[doc = "No such occurrence"]
233    #[inline(always)]
234    pub fn watermark_no(self) -> &'a mut crate::W<REG> {
235        self.variant(Erfwmi::WatermarkNo)
236    }
237    #[doc = "Number of messages in FIFO is greater than the watermark"]
238    #[inline(always)]
239    pub fn watermark_yes(self) -> &'a mut crate::W<REG> {
240        self.variant(Erfwmi::WatermarkYes)
241    }
242}
243#[doc = "Enhanced RX FIFO Overflow Flag\n\nValue on reset: 0"]
244#[cfg_attr(feature = "defmt", derive(defmt::Format))]
245#[derive(Clone, Copy, Debug, PartialEq, Eq)]
246pub enum Erfovf {
247    #[doc = "0: No such occurrence"]
248    NoOverflow = 0,
249    #[doc = "1: Overflow"]
250    Overflow = 1,
251}
252impl From<Erfovf> for bool {
253    #[inline(always)]
254    fn from(variant: Erfovf) -> Self {
255        variant as u8 != 0
256    }
257}
258#[doc = "Field `ERFOVF` reader - Enhanced RX FIFO Overflow Flag"]
259pub type ErfovfR = crate::BitReader<Erfovf>;
260impl ErfovfR {
261    #[doc = "Get enumerated values variant"]
262    #[inline(always)]
263    pub const fn variant(&self) -> Erfovf {
264        match self.bits {
265            false => Erfovf::NoOverflow,
266            true => Erfovf::Overflow,
267        }
268    }
269    #[doc = "No such occurrence"]
270    #[inline(always)]
271    pub fn is_no_overflow(&self) -> bool {
272        *self == Erfovf::NoOverflow
273    }
274    #[doc = "Overflow"]
275    #[inline(always)]
276    pub fn is_overflow(&self) -> bool {
277        *self == Erfovf::Overflow
278    }
279}
280#[doc = "Field `ERFOVF` writer - Enhanced RX FIFO Overflow Flag"]
281pub type ErfovfW<'a, REG> = crate::BitWriter1C<'a, REG, Erfovf>;
282impl<'a, REG> ErfovfW<'a, REG>
283where
284    REG: crate::Writable + crate::RegisterSpec,
285{
286    #[doc = "No such occurrence"]
287    #[inline(always)]
288    pub fn no_overflow(self) -> &'a mut crate::W<REG> {
289        self.variant(Erfovf::NoOverflow)
290    }
291    #[doc = "Overflow"]
292    #[inline(always)]
293    pub fn overflow(self) -> &'a mut crate::W<REG> {
294        self.variant(Erfovf::Overflow)
295    }
296}
297#[doc = "Enhanced RX FIFO Underflow Flag\n\nValue on reset: 0"]
298#[cfg_attr(feature = "defmt", derive(defmt::Format))]
299#[derive(Clone, Copy, Debug, PartialEq, Eq)]
300pub enum Erfufw {
301    #[doc = "0: No such occurrence"]
302    NoUnderflow = 0,
303    #[doc = "1: Underflow"]
304    Underflow = 1,
305}
306impl From<Erfufw> for bool {
307    #[inline(always)]
308    fn from(variant: Erfufw) -> Self {
309        variant as u8 != 0
310    }
311}
312#[doc = "Field `ERFUFW` reader - Enhanced RX FIFO Underflow Flag"]
313pub type ErfufwR = crate::BitReader<Erfufw>;
314impl ErfufwR {
315    #[doc = "Get enumerated values variant"]
316    #[inline(always)]
317    pub const fn variant(&self) -> Erfufw {
318        match self.bits {
319            false => Erfufw::NoUnderflow,
320            true => Erfufw::Underflow,
321        }
322    }
323    #[doc = "No such occurrence"]
324    #[inline(always)]
325    pub fn is_no_underflow(&self) -> bool {
326        *self == Erfufw::NoUnderflow
327    }
328    #[doc = "Underflow"]
329    #[inline(always)]
330    pub fn is_underflow(&self) -> bool {
331        *self == Erfufw::Underflow
332    }
333}
334#[doc = "Field `ERFUFW` writer - Enhanced RX FIFO Underflow Flag"]
335pub type ErfufwW<'a, REG> = crate::BitWriter1C<'a, REG, Erfufw>;
336impl<'a, REG> ErfufwW<'a, REG>
337where
338    REG: crate::Writable + crate::RegisterSpec,
339{
340    #[doc = "No such occurrence"]
341    #[inline(always)]
342    pub fn no_underflow(self) -> &'a mut crate::W<REG> {
343        self.variant(Erfufw::NoUnderflow)
344    }
345    #[doc = "Underflow"]
346    #[inline(always)]
347    pub fn underflow(self) -> &'a mut crate::W<REG> {
348        self.variant(Erfufw::Underflow)
349    }
350}
351impl R {
352    #[doc = "Bits 0:5 - Enhanced RX FIFO Elements"]
353    #[inline(always)]
354    pub fn erfel(&self) -> ErfelR {
355        ErfelR::new((self.bits & 0x3f) as u8)
356    }
357    #[doc = "Bit 16 - Enhanced RX FIFO Full Flag"]
358    #[inline(always)]
359    pub fn erff(&self) -> ErffR {
360        ErffR::new(((self.bits >> 16) & 1) != 0)
361    }
362    #[doc = "Bit 17 - Enhanced RX FIFO Empty Flag"]
363    #[inline(always)]
364    pub fn erfe(&self) -> ErfeR {
365        ErfeR::new(((self.bits >> 17) & 1) != 0)
366    }
367    #[doc = "Bit 27 - Enhanced RX FIFO Clear"]
368    #[inline(always)]
369    pub fn erfclr(&self) -> ErfclrR {
370        ErfclrR::new(((self.bits >> 27) & 1) != 0)
371    }
372    #[doc = "Bit 28 - Enhanced RX FIFO Data Available Flag"]
373    #[inline(always)]
374    pub fn erfda(&self) -> ErfdaR {
375        ErfdaR::new(((self.bits >> 28) & 1) != 0)
376    }
377    #[doc = "Bit 29 - Enhanced RX FIFO Watermark Indication Flag"]
378    #[inline(always)]
379    pub fn erfwmi(&self) -> ErfwmiR {
380        ErfwmiR::new(((self.bits >> 29) & 1) != 0)
381    }
382    #[doc = "Bit 30 - Enhanced RX FIFO Overflow Flag"]
383    #[inline(always)]
384    pub fn erfovf(&self) -> ErfovfR {
385        ErfovfR::new(((self.bits >> 30) & 1) != 0)
386    }
387    #[doc = "Bit 31 - Enhanced RX FIFO Underflow Flag"]
388    #[inline(always)]
389    pub fn erfufw(&self) -> ErfufwR {
390        ErfufwR::new(((self.bits >> 31) & 1) != 0)
391    }
392}
393#[cfg(feature = "debug")]
394impl core::fmt::Debug for R {
395    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
396        f.debug_struct("ERFSR")
397            .field("erfel", &self.erfel())
398            .field("erff", &self.erff())
399            .field("erfe", &self.erfe())
400            .field("erfclr", &self.erfclr())
401            .field("erfda", &self.erfda())
402            .field("erfwmi", &self.erfwmi())
403            .field("erfovf", &self.erfovf())
404            .field("erfufw", &self.erfufw())
405            .finish()
406    }
407}
408impl W {
409    #[doc = "Bit 27 - Enhanced RX FIFO Clear"]
410    #[inline(always)]
411    pub fn erfclr(&mut self) -> ErfclrW<'_, ErfsrSpec> {
412        ErfclrW::new(self, 27)
413    }
414    #[doc = "Bit 28 - Enhanced RX FIFO Data Available Flag"]
415    #[inline(always)]
416    pub fn erfda(&mut self) -> ErfdaW<'_, ErfsrSpec> {
417        ErfdaW::new(self, 28)
418    }
419    #[doc = "Bit 29 - Enhanced RX FIFO Watermark Indication Flag"]
420    #[inline(always)]
421    pub fn erfwmi(&mut self) -> ErfwmiW<'_, ErfsrSpec> {
422        ErfwmiW::new(self, 29)
423    }
424    #[doc = "Bit 30 - Enhanced RX FIFO Overflow Flag"]
425    #[inline(always)]
426    pub fn erfovf(&mut self) -> ErfovfW<'_, ErfsrSpec> {
427        ErfovfW::new(self, 30)
428    }
429    #[doc = "Bit 31 - Enhanced RX FIFO Underflow Flag"]
430    #[inline(always)]
431    pub fn erfufw(&mut self) -> ErfufwW<'_, ErfsrSpec> {
432        ErfufwW::new(self, 31)
433    }
434}
435#[doc = "Enhanced RX FIFO Status\n\nYou can [`read`](crate::Reg::read) this register and get [`erfsr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`erfsr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
436pub struct ErfsrSpec;
437impl crate::RegisterSpec for ErfsrSpec {
438    type Ux = u32;
439}
440#[doc = "`read()` method returns [`erfsr::R`](R) reader structure"]
441impl crate::Readable for ErfsrSpec {}
442#[doc = "`write(|w| ..)` method takes [`erfsr::W`](W) writer structure"]
443impl crate::Writable for ErfsrSpec {
444    type Safety = crate::Unsafe;
445    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0xf000_0000;
446}
447#[doc = "`reset()` method sets ERFSR to value 0"]
448impl crate::Resettable for ErfsrSpec {}