Skip to main content

mcxa_pac/can0/
ctrl1_pn.rs

1#[doc = "Register `CTRL1_PN` reader"]
2pub type R = crate::R<Ctrl1PnSpec>;
3#[doc = "Register `CTRL1_PN` writer"]
4pub type W = crate::W<Ctrl1PnSpec>;
5#[doc = "Filtering Combination Selection\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum Fcs {
10    #[doc = "0: Message ID filtering only"]
11    IdFiltering = 0,
12    #[doc = "1: Message ID filtering and payload filtering"]
13    IdPayloadFiltering = 1,
14    #[doc = "2: Message ID filtering occurring a specified number of times"]
15    IdFilteringNumber = 2,
16    #[doc = "3: Message ID filtering and payload filtering a specified number of times"]
17    IdPayloadFilteringNumber = 3,
18}
19impl From<Fcs> for u8 {
20    #[inline(always)]
21    fn from(variant: Fcs) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for Fcs {
26    type Ux = u8;
27}
28impl crate::IsEnum for Fcs {}
29#[doc = "Field `FCS` reader - Filtering Combination Selection"]
30pub type FcsR = crate::FieldReader<Fcs>;
31impl FcsR {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> Fcs {
35        match self.bits {
36            0 => Fcs::IdFiltering,
37            1 => Fcs::IdPayloadFiltering,
38            2 => Fcs::IdFilteringNumber,
39            3 => Fcs::IdPayloadFilteringNumber,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "Message ID filtering only"]
44    #[inline(always)]
45    pub fn is_id_filtering(&self) -> bool {
46        *self == Fcs::IdFiltering
47    }
48    #[doc = "Message ID filtering and payload filtering"]
49    #[inline(always)]
50    pub fn is_id_payload_filtering(&self) -> bool {
51        *self == Fcs::IdPayloadFiltering
52    }
53    #[doc = "Message ID filtering occurring a specified number of times"]
54    #[inline(always)]
55    pub fn is_id_filtering_number(&self) -> bool {
56        *self == Fcs::IdFilteringNumber
57    }
58    #[doc = "Message ID filtering and payload filtering a specified number of times"]
59    #[inline(always)]
60    pub fn is_id_payload_filtering_number(&self) -> bool {
61        *self == Fcs::IdPayloadFilteringNumber
62    }
63}
64#[doc = "Field `FCS` writer - Filtering Combination Selection"]
65pub type FcsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Fcs, crate::Safe>;
66impl<'a, REG> FcsW<'a, REG>
67where
68    REG: crate::Writable + crate::RegisterSpec,
69    REG::Ux: From<u8>,
70{
71    #[doc = "Message ID filtering only"]
72    #[inline(always)]
73    pub fn id_filtering(self) -> &'a mut crate::W<REG> {
74        self.variant(Fcs::IdFiltering)
75    }
76    #[doc = "Message ID filtering and payload filtering"]
77    #[inline(always)]
78    pub fn id_payload_filtering(self) -> &'a mut crate::W<REG> {
79        self.variant(Fcs::IdPayloadFiltering)
80    }
81    #[doc = "Message ID filtering occurring a specified number of times"]
82    #[inline(always)]
83    pub fn id_filtering_number(self) -> &'a mut crate::W<REG> {
84        self.variant(Fcs::IdFilteringNumber)
85    }
86    #[doc = "Message ID filtering and payload filtering a specified number of times"]
87    #[inline(always)]
88    pub fn id_payload_filtering_number(self) -> &'a mut crate::W<REG> {
89        self.variant(Fcs::IdPayloadFilteringNumber)
90    }
91}
92#[doc = "ID Filtering Selection\n\nValue on reset: 0"]
93#[cfg_attr(feature = "defmt", derive(defmt::Format))]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum Idfs {
97    #[doc = "0: Match ID contents to an exact target value"]
98    MatchExact = 0,
99    #[doc = "1: Match an ID value greater than or equal to a specified target value"]
100    MatchGte = 1,
101    #[doc = "2: Match an ID value smaller than or equal to a specified target value"]
102    MatchLte = 2,
103    #[doc = "3: Match an ID value within a range of values, inclusive"]
104    MatchRange = 3,
105}
106impl From<Idfs> for u8 {
107    #[inline(always)]
108    fn from(variant: Idfs) -> Self {
109        variant as _
110    }
111}
112impl crate::FieldSpec for Idfs {
113    type Ux = u8;
114}
115impl crate::IsEnum for Idfs {}
116#[doc = "Field `IDFS` reader - ID Filtering Selection"]
117pub type IdfsR = crate::FieldReader<Idfs>;
118impl IdfsR {
119    #[doc = "Get enumerated values variant"]
120    #[inline(always)]
121    pub const fn variant(&self) -> Idfs {
122        match self.bits {
123            0 => Idfs::MatchExact,
124            1 => Idfs::MatchGte,
125            2 => Idfs::MatchLte,
126            3 => Idfs::MatchRange,
127            _ => unreachable!(),
128        }
129    }
130    #[doc = "Match ID contents to an exact target value"]
131    #[inline(always)]
132    pub fn is_match_exact(&self) -> bool {
133        *self == Idfs::MatchExact
134    }
135    #[doc = "Match an ID value greater than or equal to a specified target value"]
136    #[inline(always)]
137    pub fn is_match_gte(&self) -> bool {
138        *self == Idfs::MatchGte
139    }
140    #[doc = "Match an ID value smaller than or equal to a specified target value"]
141    #[inline(always)]
142    pub fn is_match_lte(&self) -> bool {
143        *self == Idfs::MatchLte
144    }
145    #[doc = "Match an ID value within a range of values, inclusive"]
146    #[inline(always)]
147    pub fn is_match_range(&self) -> bool {
148        *self == Idfs::MatchRange
149    }
150}
151#[doc = "Field `IDFS` writer - ID Filtering Selection"]
152pub type IdfsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Idfs, crate::Safe>;
153impl<'a, REG> IdfsW<'a, REG>
154where
155    REG: crate::Writable + crate::RegisterSpec,
156    REG::Ux: From<u8>,
157{
158    #[doc = "Match ID contents to an exact target value"]
159    #[inline(always)]
160    pub fn match_exact(self) -> &'a mut crate::W<REG> {
161        self.variant(Idfs::MatchExact)
162    }
163    #[doc = "Match an ID value greater than or equal to a specified target value"]
164    #[inline(always)]
165    pub fn match_gte(self) -> &'a mut crate::W<REG> {
166        self.variant(Idfs::MatchGte)
167    }
168    #[doc = "Match an ID value smaller than or equal to a specified target value"]
169    #[inline(always)]
170    pub fn match_lte(self) -> &'a mut crate::W<REG> {
171        self.variant(Idfs::MatchLte)
172    }
173    #[doc = "Match an ID value within a range of values, inclusive"]
174    #[inline(always)]
175    pub fn match_range(self) -> &'a mut crate::W<REG> {
176        self.variant(Idfs::MatchRange)
177    }
178}
179#[doc = "Payload Filtering Selection\n\nValue on reset: 0"]
180#[cfg_attr(feature = "defmt", derive(defmt::Format))]
181#[derive(Clone, Copy, Debug, PartialEq, Eq)]
182#[repr(u8)]
183pub enum Plfs {
184    #[doc = "0: Match payload contents to an exact target value"]
185    MatchExact = 0,
186    #[doc = "1: Match a payload value greater than or equal to a specified target value"]
187    MatchGte = 1,
188    #[doc = "2: Match a payload value smaller than or equal to a specified target value"]
189    MatchLte = 2,
190    #[doc = "3: Match upon a payload value within a range of values, inclusive"]
191    MatchRange = 3,
192}
193impl From<Plfs> for u8 {
194    #[inline(always)]
195    fn from(variant: Plfs) -> Self {
196        variant as _
197    }
198}
199impl crate::FieldSpec for Plfs {
200    type Ux = u8;
201}
202impl crate::IsEnum for Plfs {}
203#[doc = "Field `PLFS` reader - Payload Filtering Selection"]
204pub type PlfsR = crate::FieldReader<Plfs>;
205impl PlfsR {
206    #[doc = "Get enumerated values variant"]
207    #[inline(always)]
208    pub const fn variant(&self) -> Plfs {
209        match self.bits {
210            0 => Plfs::MatchExact,
211            1 => Plfs::MatchGte,
212            2 => Plfs::MatchLte,
213            3 => Plfs::MatchRange,
214            _ => unreachable!(),
215        }
216    }
217    #[doc = "Match payload contents to an exact target value"]
218    #[inline(always)]
219    pub fn is_match_exact(&self) -> bool {
220        *self == Plfs::MatchExact
221    }
222    #[doc = "Match a payload value greater than or equal to a specified target value"]
223    #[inline(always)]
224    pub fn is_match_gte(&self) -> bool {
225        *self == Plfs::MatchGte
226    }
227    #[doc = "Match a payload value smaller than or equal to a specified target value"]
228    #[inline(always)]
229    pub fn is_match_lte(&self) -> bool {
230        *self == Plfs::MatchLte
231    }
232    #[doc = "Match upon a payload value within a range of values, inclusive"]
233    #[inline(always)]
234    pub fn is_match_range(&self) -> bool {
235        *self == Plfs::MatchRange
236    }
237}
238#[doc = "Field `PLFS` writer - Payload Filtering Selection"]
239pub type PlfsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Plfs, crate::Safe>;
240impl<'a, REG> PlfsW<'a, REG>
241where
242    REG: crate::Writable + crate::RegisterSpec,
243    REG::Ux: From<u8>,
244{
245    #[doc = "Match payload contents to an exact target value"]
246    #[inline(always)]
247    pub fn match_exact(self) -> &'a mut crate::W<REG> {
248        self.variant(Plfs::MatchExact)
249    }
250    #[doc = "Match a payload value greater than or equal to a specified target value"]
251    #[inline(always)]
252    pub fn match_gte(self) -> &'a mut crate::W<REG> {
253        self.variant(Plfs::MatchGte)
254    }
255    #[doc = "Match a payload value smaller than or equal to a specified target value"]
256    #[inline(always)]
257    pub fn match_lte(self) -> &'a mut crate::W<REG> {
258        self.variant(Plfs::MatchLte)
259    }
260    #[doc = "Match upon a payload value within a range of values, inclusive"]
261    #[inline(always)]
262    pub fn match_range(self) -> &'a mut crate::W<REG> {
263        self.variant(Plfs::MatchRange)
264    }
265}
266#[doc = "Number of Messages Matching the Same Filtering Criteria\n\nValue on reset: 1"]
267#[cfg_attr(feature = "defmt", derive(defmt::Format))]
268#[derive(Clone, Copy, Debug, PartialEq, Eq)]
269#[repr(u8)]
270pub enum Nmatch {
271    #[doc = "1: Once"]
272    Match1 = 1,
273    #[doc = "2: Twice"]
274    Match2 = 2,
275    #[doc = "255: 255 times"]
276    Match255 = 255,
277}
278impl From<Nmatch> for u8 {
279    #[inline(always)]
280    fn from(variant: Nmatch) -> Self {
281        variant as _
282    }
283}
284impl crate::FieldSpec for Nmatch {
285    type Ux = u8;
286}
287impl crate::IsEnum for Nmatch {}
288#[doc = "Field `NMATCH` reader - Number of Messages Matching the Same Filtering Criteria"]
289pub type NmatchR = crate::FieldReader<Nmatch>;
290impl NmatchR {
291    #[doc = "Get enumerated values variant"]
292    #[inline(always)]
293    pub const fn variant(&self) -> Option<Nmatch> {
294        match self.bits {
295            1 => Some(Nmatch::Match1),
296            2 => Some(Nmatch::Match2),
297            255 => Some(Nmatch::Match255),
298            _ => None,
299        }
300    }
301    #[doc = "Once"]
302    #[inline(always)]
303    pub fn is_match_1(&self) -> bool {
304        *self == Nmatch::Match1
305    }
306    #[doc = "Twice"]
307    #[inline(always)]
308    pub fn is_match_2(&self) -> bool {
309        *self == Nmatch::Match2
310    }
311    #[doc = "255 times"]
312    #[inline(always)]
313    pub fn is_match_255(&self) -> bool {
314        *self == Nmatch::Match255
315    }
316}
317#[doc = "Field `NMATCH` writer - Number of Messages Matching the Same Filtering Criteria"]
318pub type NmatchW<'a, REG> = crate::FieldWriter<'a, REG, 8, Nmatch>;
319impl<'a, REG> NmatchW<'a, REG>
320where
321    REG: crate::Writable + crate::RegisterSpec,
322    REG::Ux: From<u8>,
323{
324    #[doc = "Once"]
325    #[inline(always)]
326    pub fn match_1(self) -> &'a mut crate::W<REG> {
327        self.variant(Nmatch::Match1)
328    }
329    #[doc = "Twice"]
330    #[inline(always)]
331    pub fn match_2(self) -> &'a mut crate::W<REG> {
332        self.variant(Nmatch::Match2)
333    }
334    #[doc = "255 times"]
335    #[inline(always)]
336    pub fn match_255(self) -> &'a mut crate::W<REG> {
337        self.variant(Nmatch::Match255)
338    }
339}
340#[doc = "Wake-up by Matching Flag Mask\n\nValue on reset: 0"]
341#[cfg_attr(feature = "defmt", derive(defmt::Format))]
342#[derive(Clone, Copy, Debug, PartialEq, Eq)]
343pub enum WumfMsk {
344    #[doc = "0: Disable"]
345    Disable = 0,
346    #[doc = "1: Enable"]
347    Enable = 1,
348}
349impl From<WumfMsk> for bool {
350    #[inline(always)]
351    fn from(variant: WumfMsk) -> Self {
352        variant as u8 != 0
353    }
354}
355#[doc = "Field `WUMF_MSK` reader - Wake-up by Matching Flag Mask"]
356pub type WumfMskR = crate::BitReader<WumfMsk>;
357impl WumfMskR {
358    #[doc = "Get enumerated values variant"]
359    #[inline(always)]
360    pub const fn variant(&self) -> WumfMsk {
361        match self.bits {
362            false => WumfMsk::Disable,
363            true => WumfMsk::Enable,
364        }
365    }
366    #[doc = "Disable"]
367    #[inline(always)]
368    pub fn is_disable(&self) -> bool {
369        *self == WumfMsk::Disable
370    }
371    #[doc = "Enable"]
372    #[inline(always)]
373    pub fn is_enable(&self) -> bool {
374        *self == WumfMsk::Enable
375    }
376}
377#[doc = "Field `WUMF_MSK` writer - Wake-up by Matching Flag Mask"]
378pub type WumfMskW<'a, REG> = crate::BitWriter<'a, REG, WumfMsk>;
379impl<'a, REG> WumfMskW<'a, REG>
380where
381    REG: crate::Writable + crate::RegisterSpec,
382{
383    #[doc = "Disable"]
384    #[inline(always)]
385    pub fn disable(self) -> &'a mut crate::W<REG> {
386        self.variant(WumfMsk::Disable)
387    }
388    #[doc = "Enable"]
389    #[inline(always)]
390    pub fn enable(self) -> &'a mut crate::W<REG> {
391        self.variant(WumfMsk::Enable)
392    }
393}
394#[doc = "Wake-up by Timeout Flag Mask\n\nValue on reset: 0"]
395#[cfg_attr(feature = "defmt", derive(defmt::Format))]
396#[derive(Clone, Copy, Debug, PartialEq, Eq)]
397pub enum WtofMsk {
398    #[doc = "0: Disable"]
399    Disable = 0,
400    #[doc = "1: Enable"]
401    Enable = 1,
402}
403impl From<WtofMsk> for bool {
404    #[inline(always)]
405    fn from(variant: WtofMsk) -> Self {
406        variant as u8 != 0
407    }
408}
409#[doc = "Field `WTOF_MSK` reader - Wake-up by Timeout Flag Mask"]
410pub type WtofMskR = crate::BitReader<WtofMsk>;
411impl WtofMskR {
412    #[doc = "Get enumerated values variant"]
413    #[inline(always)]
414    pub const fn variant(&self) -> WtofMsk {
415        match self.bits {
416            false => WtofMsk::Disable,
417            true => WtofMsk::Enable,
418        }
419    }
420    #[doc = "Disable"]
421    #[inline(always)]
422    pub fn is_disable(&self) -> bool {
423        *self == WtofMsk::Disable
424    }
425    #[doc = "Enable"]
426    #[inline(always)]
427    pub fn is_enable(&self) -> bool {
428        *self == WtofMsk::Enable
429    }
430}
431#[doc = "Field `WTOF_MSK` writer - Wake-up by Timeout Flag Mask"]
432pub type WtofMskW<'a, REG> = crate::BitWriter<'a, REG, WtofMsk>;
433impl<'a, REG> WtofMskW<'a, REG>
434where
435    REG: crate::Writable + crate::RegisterSpec,
436{
437    #[doc = "Disable"]
438    #[inline(always)]
439    pub fn disable(self) -> &'a mut crate::W<REG> {
440        self.variant(WtofMsk::Disable)
441    }
442    #[doc = "Enable"]
443    #[inline(always)]
444    pub fn enable(self) -> &'a mut crate::W<REG> {
445        self.variant(WtofMsk::Enable)
446    }
447}
448impl R {
449    #[doc = "Bits 0:1 - Filtering Combination Selection"]
450    #[inline(always)]
451    pub fn fcs(&self) -> FcsR {
452        FcsR::new((self.bits & 3) as u8)
453    }
454    #[doc = "Bits 2:3 - ID Filtering Selection"]
455    #[inline(always)]
456    pub fn idfs(&self) -> IdfsR {
457        IdfsR::new(((self.bits >> 2) & 3) as u8)
458    }
459    #[doc = "Bits 4:5 - Payload Filtering Selection"]
460    #[inline(always)]
461    pub fn plfs(&self) -> PlfsR {
462        PlfsR::new(((self.bits >> 4) & 3) as u8)
463    }
464    #[doc = "Bits 8:15 - Number of Messages Matching the Same Filtering Criteria"]
465    #[inline(always)]
466    pub fn nmatch(&self) -> NmatchR {
467        NmatchR::new(((self.bits >> 8) & 0xff) as u8)
468    }
469    #[doc = "Bit 16 - Wake-up by Matching Flag Mask"]
470    #[inline(always)]
471    pub fn wumf_msk(&self) -> WumfMskR {
472        WumfMskR::new(((self.bits >> 16) & 1) != 0)
473    }
474    #[doc = "Bit 17 - Wake-up by Timeout Flag Mask"]
475    #[inline(always)]
476    pub fn wtof_msk(&self) -> WtofMskR {
477        WtofMskR::new(((self.bits >> 17) & 1) != 0)
478    }
479}
480#[cfg(feature = "debug")]
481impl core::fmt::Debug for R {
482    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
483        f.debug_struct("CTRL1_PN")
484            .field("fcs", &self.fcs())
485            .field("idfs", &self.idfs())
486            .field("plfs", &self.plfs())
487            .field("nmatch", &self.nmatch())
488            .field("wumf_msk", &self.wumf_msk())
489            .field("wtof_msk", &self.wtof_msk())
490            .finish()
491    }
492}
493impl W {
494    #[doc = "Bits 0:1 - Filtering Combination Selection"]
495    #[inline(always)]
496    pub fn fcs(&mut self) -> FcsW<'_, Ctrl1PnSpec> {
497        FcsW::new(self, 0)
498    }
499    #[doc = "Bits 2:3 - ID Filtering Selection"]
500    #[inline(always)]
501    pub fn idfs(&mut self) -> IdfsW<'_, Ctrl1PnSpec> {
502        IdfsW::new(self, 2)
503    }
504    #[doc = "Bits 4:5 - Payload Filtering Selection"]
505    #[inline(always)]
506    pub fn plfs(&mut self) -> PlfsW<'_, Ctrl1PnSpec> {
507        PlfsW::new(self, 4)
508    }
509    #[doc = "Bits 8:15 - Number of Messages Matching the Same Filtering Criteria"]
510    #[inline(always)]
511    pub fn nmatch(&mut self) -> NmatchW<'_, Ctrl1PnSpec> {
512        NmatchW::new(self, 8)
513    }
514    #[doc = "Bit 16 - Wake-up by Matching Flag Mask"]
515    #[inline(always)]
516    pub fn wumf_msk(&mut self) -> WumfMskW<'_, Ctrl1PnSpec> {
517        WumfMskW::new(self, 16)
518    }
519    #[doc = "Bit 17 - Wake-up by Timeout Flag Mask"]
520    #[inline(always)]
521    pub fn wtof_msk(&mut self) -> WtofMskW<'_, Ctrl1PnSpec> {
522        WtofMskW::new(self, 17)
523    }
524}
525#[doc = "Pretended Networking Control 1\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl1_pn::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl1_pn::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
526pub struct Ctrl1PnSpec;
527impl crate::RegisterSpec for Ctrl1PnSpec {
528    type Ux = u32;
529}
530#[doc = "`read()` method returns [`ctrl1_pn::R`](R) reader structure"]
531impl crate::Readable for Ctrl1PnSpec {}
532#[doc = "`write(|w| ..)` method takes [`ctrl1_pn::W`](W) writer structure"]
533impl crate::Writable for Ctrl1PnSpec {
534    type Safety = crate::Unsafe;
535}
536#[doc = "`reset()` method sets CTRL1_PN to value 0x0100"]
537impl crate::Resettable for Ctrl1PnSpec {
538    const RESET_VALUE: u32 = 0x0100;
539}