mcxa_pac/can0/
erfcr.rs

1#[doc = "Register `ERFCR` reader"]
2pub type R = crate::R<ErfcrSpec>;
3#[doc = "Register `ERFCR` writer"]
4pub type W = crate::W<ErfcrSpec>;
5#[doc = "Field `ERFWM` reader - Enhanced RX FIFO Watermark"]
6pub type ErfwmR = crate::FieldReader;
7#[doc = "Field `ERFWM` writer - Enhanced RX FIFO Watermark"]
8pub type ErfwmW<'a, REG> = crate::FieldWriter<'a, REG, 5>;
9#[doc = "Field `NFE` reader - Number of Enhanced RX FIFO Filter Elements"]
10pub type NfeR = crate::FieldReader;
11#[doc = "Field `NFE` writer - Number of Enhanced RX FIFO Filter Elements"]
12pub type NfeW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
13#[doc = "Field `NEXIF` reader - Number of Extended ID Filter Elements"]
14pub type NexifR = crate::FieldReader;
15#[doc = "Field `NEXIF` writer - Number of Extended ID Filter Elements"]
16pub type NexifW<'a, REG> = crate::FieldWriter<'a, REG, 7>;
17#[doc = "Field `DMALW` reader - DMA Last Word"]
18pub type DmalwR = crate::FieldReader;
19#[doc = "Field `DMALW` writer - DMA Last Word"]
20pub type DmalwW<'a, REG> = crate::FieldWriter<'a, REG, 5>;
21#[doc = "Enhanced RX FIFO enable\n\nValue on reset: 0"]
22#[cfg_attr(feature = "defmt", derive(defmt::Format))]
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24pub enum Erfen {
25    #[doc = "0: Disable"]
26    Disable = 0,
27    #[doc = "1: Enable"]
28    Enable = 1,
29}
30impl From<Erfen> for bool {
31    #[inline(always)]
32    fn from(variant: Erfen) -> Self {
33        variant as u8 != 0
34    }
35}
36#[doc = "Field `ERFEN` reader - Enhanced RX FIFO enable"]
37pub type ErfenR = crate::BitReader<Erfen>;
38impl ErfenR {
39    #[doc = "Get enumerated values variant"]
40    #[inline(always)]
41    pub const fn variant(&self) -> Erfen {
42        match self.bits {
43            false => Erfen::Disable,
44            true => Erfen::Enable,
45        }
46    }
47    #[doc = "Disable"]
48    #[inline(always)]
49    pub fn is_disable(&self) -> bool {
50        *self == Erfen::Disable
51    }
52    #[doc = "Enable"]
53    #[inline(always)]
54    pub fn is_enable(&self) -> bool {
55        *self == Erfen::Enable
56    }
57}
58#[doc = "Field `ERFEN` writer - Enhanced RX FIFO enable"]
59pub type ErfenW<'a, REG> = crate::BitWriter<'a, REG, Erfen>;
60impl<'a, REG> ErfenW<'a, REG>
61where
62    REG: crate::Writable + crate::RegisterSpec,
63{
64    #[doc = "Disable"]
65    #[inline(always)]
66    pub fn disable(self) -> &'a mut crate::W<REG> {
67        self.variant(Erfen::Disable)
68    }
69    #[doc = "Enable"]
70    #[inline(always)]
71    pub fn enable(self) -> &'a mut crate::W<REG> {
72        self.variant(Erfen::Enable)
73    }
74}
75impl R {
76    #[doc = "Bits 0:4 - Enhanced RX FIFO Watermark"]
77    #[inline(always)]
78    pub fn erfwm(&self) -> ErfwmR {
79        ErfwmR::new((self.bits & 0x1f) as u8)
80    }
81    #[doc = "Bits 8:13 - Number of Enhanced RX FIFO Filter Elements"]
82    #[inline(always)]
83    pub fn nfe(&self) -> NfeR {
84        NfeR::new(((self.bits >> 8) & 0x3f) as u8)
85    }
86    #[doc = "Bits 16:22 - Number of Extended ID Filter Elements"]
87    #[inline(always)]
88    pub fn nexif(&self) -> NexifR {
89        NexifR::new(((self.bits >> 16) & 0x7f) as u8)
90    }
91    #[doc = "Bits 26:30 - DMA Last Word"]
92    #[inline(always)]
93    pub fn dmalw(&self) -> DmalwR {
94        DmalwR::new(((self.bits >> 26) & 0x1f) as u8)
95    }
96    #[doc = "Bit 31 - Enhanced RX FIFO enable"]
97    #[inline(always)]
98    pub fn erfen(&self) -> ErfenR {
99        ErfenR::new(((self.bits >> 31) & 1) != 0)
100    }
101}
102#[cfg(feature = "debug")]
103impl core::fmt::Debug for R {
104    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
105        f.debug_struct("ERFCR")
106            .field("erfwm", &self.erfwm())
107            .field("nfe", &self.nfe())
108            .field("nexif", &self.nexif())
109            .field("dmalw", &self.dmalw())
110            .field("erfen", &self.erfen())
111            .finish()
112    }
113}
114impl W {
115    #[doc = "Bits 0:4 - Enhanced RX FIFO Watermark"]
116    #[inline(always)]
117    pub fn erfwm(&mut self) -> ErfwmW<'_, ErfcrSpec> {
118        ErfwmW::new(self, 0)
119    }
120    #[doc = "Bits 8:13 - Number of Enhanced RX FIFO Filter Elements"]
121    #[inline(always)]
122    pub fn nfe(&mut self) -> NfeW<'_, ErfcrSpec> {
123        NfeW::new(self, 8)
124    }
125    #[doc = "Bits 16:22 - Number of Extended ID Filter Elements"]
126    #[inline(always)]
127    pub fn nexif(&mut self) -> NexifW<'_, ErfcrSpec> {
128        NexifW::new(self, 16)
129    }
130    #[doc = "Bits 26:30 - DMA Last Word"]
131    #[inline(always)]
132    pub fn dmalw(&mut self) -> DmalwW<'_, ErfcrSpec> {
133        DmalwW::new(self, 26)
134    }
135    #[doc = "Bit 31 - Enhanced RX FIFO enable"]
136    #[inline(always)]
137    pub fn erfen(&mut self) -> ErfenW<'_, ErfcrSpec> {
138        ErfenW::new(self, 31)
139    }
140}
141#[doc = "Enhanced RX FIFO Control\n\nYou can [`read`](crate::Reg::read) this register and get [`erfcr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`erfcr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
142pub struct ErfcrSpec;
143impl crate::RegisterSpec for ErfcrSpec {
144    type Ux = u32;
145}
146#[doc = "`read()` method returns [`erfcr::R`](R) reader structure"]
147impl crate::Readable for ErfcrSpec {}
148#[doc = "`write(|w| ..)` method takes [`erfcr::W`](W) writer structure"]
149impl crate::Writable for ErfcrSpec {
150    type Safety = crate::Unsafe;
151}
152#[doc = "`reset()` method sets ERFCR to value 0"]
153impl crate::Resettable for ErfcrSpec {}