Skip to main content

mcxa_pac/can0/
flt_id2_idmask.rs

1#[doc = "Register `FLT_ID2_IDMASK` reader"]
2pub type R = crate::R<FltId2IdmaskSpec>;
3#[doc = "Register `FLT_ID2_IDMASK` writer"]
4pub type W = crate::W<FltId2IdmaskSpec>;
5#[doc = "Field `FLT_ID2_IDMASK` reader - ID Filter 2 for Pretended Networking Filtering or ID Mask Bits for Pretended Networking ID Filtering"]
6pub type FltId2IdmaskR = crate::FieldReader<u32>;
7#[doc = "Field `FLT_ID2_IDMASK` writer - ID Filter 2 for Pretended Networking Filtering or ID Mask Bits for Pretended Networking ID Filtering"]
8pub type FltId2IdmaskW<'a, REG> = crate::FieldWriter<'a, REG, 29, u32>;
9#[doc = "Remote Transmission Request Mask\n\nValue on reset: 0"]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum RtrMsk {
13    #[doc = "0: The corresponding bit in the filter is \"don't care.\""]
14    FrameTypeNo = 0,
15    #[doc = "1: The corresponding bit in the filter is checked."]
16    FrameTypeYes = 1,
17}
18impl From<RtrMsk> for bool {
19    #[inline(always)]
20    fn from(variant: RtrMsk) -> Self {
21        variant as u8 != 0
22    }
23}
24#[doc = "Field `RTR_MSK` reader - Remote Transmission Request Mask"]
25pub type RtrMskR = crate::BitReader<RtrMsk>;
26impl RtrMskR {
27    #[doc = "Get enumerated values variant"]
28    #[inline(always)]
29    pub const fn variant(&self) -> RtrMsk {
30        match self.bits {
31            false => RtrMsk::FrameTypeNo,
32            true => RtrMsk::FrameTypeYes,
33        }
34    }
35    #[doc = "The corresponding bit in the filter is \"don't care.\""]
36    #[inline(always)]
37    pub fn is_frame_type_no(&self) -> bool {
38        *self == RtrMsk::FrameTypeNo
39    }
40    #[doc = "The corresponding bit in the filter is checked."]
41    #[inline(always)]
42    pub fn is_frame_type_yes(&self) -> bool {
43        *self == RtrMsk::FrameTypeYes
44    }
45}
46#[doc = "Field `RTR_MSK` writer - Remote Transmission Request Mask"]
47pub type RtrMskW<'a, REG> = crate::BitWriter<'a, REG, RtrMsk>;
48impl<'a, REG> RtrMskW<'a, REG>
49where
50    REG: crate::Writable + crate::RegisterSpec,
51{
52    #[doc = "The corresponding bit in the filter is \"don't care.\""]
53    #[inline(always)]
54    pub fn frame_type_no(self) -> &'a mut crate::W<REG> {
55        self.variant(RtrMsk::FrameTypeNo)
56    }
57    #[doc = "The corresponding bit in the filter is checked."]
58    #[inline(always)]
59    pub fn frame_type_yes(self) -> &'a mut crate::W<REG> {
60        self.variant(RtrMsk::FrameTypeYes)
61    }
62}
63#[doc = "ID Extended Mask\n\nValue on reset: 0"]
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum IdeMsk {
67    #[doc = "0: The corresponding bit in the filter is \"don't care.\""]
68    FrameFormatNo = 0,
69    #[doc = "1: The corresponding bit in the filter is checked."]
70    FrameFormatYes = 1,
71}
72impl From<IdeMsk> for bool {
73    #[inline(always)]
74    fn from(variant: IdeMsk) -> Self {
75        variant as u8 != 0
76    }
77}
78#[doc = "Field `IDE_MSK` reader - ID Extended Mask"]
79pub type IdeMskR = crate::BitReader<IdeMsk>;
80impl IdeMskR {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub const fn variant(&self) -> IdeMsk {
84        match self.bits {
85            false => IdeMsk::FrameFormatNo,
86            true => IdeMsk::FrameFormatYes,
87        }
88    }
89    #[doc = "The corresponding bit in the filter is \"don't care.\""]
90    #[inline(always)]
91    pub fn is_frame_format_no(&self) -> bool {
92        *self == IdeMsk::FrameFormatNo
93    }
94    #[doc = "The corresponding bit in the filter is checked."]
95    #[inline(always)]
96    pub fn is_frame_format_yes(&self) -> bool {
97        *self == IdeMsk::FrameFormatYes
98    }
99}
100#[doc = "Field `IDE_MSK` writer - ID Extended Mask"]
101pub type IdeMskW<'a, REG> = crate::BitWriter<'a, REG, IdeMsk>;
102impl<'a, REG> IdeMskW<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    #[doc = "The corresponding bit in the filter is \"don't care.\""]
107    #[inline(always)]
108    pub fn frame_format_no(self) -> &'a mut crate::W<REG> {
109        self.variant(IdeMsk::FrameFormatNo)
110    }
111    #[doc = "The corresponding bit in the filter is checked."]
112    #[inline(always)]
113    pub fn frame_format_yes(self) -> &'a mut crate::W<REG> {
114        self.variant(IdeMsk::FrameFormatYes)
115    }
116}
117impl R {
118    #[doc = "Bits 0:28 - ID Filter 2 for Pretended Networking Filtering or ID Mask Bits for Pretended Networking ID Filtering"]
119    #[inline(always)]
120    pub fn flt_id2_idmask(&self) -> FltId2IdmaskR {
121        FltId2IdmaskR::new(self.bits & 0x1fff_ffff)
122    }
123    #[doc = "Bit 29 - Remote Transmission Request Mask"]
124    #[inline(always)]
125    pub fn rtr_msk(&self) -> RtrMskR {
126        RtrMskR::new(((self.bits >> 29) & 1) != 0)
127    }
128    #[doc = "Bit 30 - ID Extended Mask"]
129    #[inline(always)]
130    pub fn ide_msk(&self) -> IdeMskR {
131        IdeMskR::new(((self.bits >> 30) & 1) != 0)
132    }
133}
134#[cfg(feature = "debug")]
135impl core::fmt::Debug for R {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("FLT_ID2_IDMASK")
138            .field("flt_id2_idmask", &self.flt_id2_idmask())
139            .field("rtr_msk", &self.rtr_msk())
140            .field("ide_msk", &self.ide_msk())
141            .finish()
142    }
143}
144impl W {
145    #[doc = "Bits 0:28 - ID Filter 2 for Pretended Networking Filtering or ID Mask Bits for Pretended Networking ID Filtering"]
146    #[inline(always)]
147    pub fn flt_id2_idmask(&mut self) -> FltId2IdmaskW<'_, FltId2IdmaskSpec> {
148        FltId2IdmaskW::new(self, 0)
149    }
150    #[doc = "Bit 29 - Remote Transmission Request Mask"]
151    #[inline(always)]
152    pub fn rtr_msk(&mut self) -> RtrMskW<'_, FltId2IdmaskSpec> {
153        RtrMskW::new(self, 29)
154    }
155    #[doc = "Bit 30 - ID Extended Mask"]
156    #[inline(always)]
157    pub fn ide_msk(&mut self) -> IdeMskW<'_, FltId2IdmaskSpec> {
158        IdeMskW::new(self, 30)
159    }
160}
161#[doc = "Pretended Networking ID Filter 2 or ID Mask\n\nYou can [`read`](crate::Reg::read) this register and get [`flt_id2_idmask::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`flt_id2_idmask::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
162pub struct FltId2IdmaskSpec;
163impl crate::RegisterSpec for FltId2IdmaskSpec {
164    type Ux = u32;
165}
166#[doc = "`read()` method returns [`flt_id2_idmask::R`](R) reader structure"]
167impl crate::Readable for FltId2IdmaskSpec {}
168#[doc = "`write(|w| ..)` method takes [`flt_id2_idmask::W`](W) writer structure"]
169impl crate::Writable for FltId2IdmaskSpec {
170    type Safety = crate::Unsafe;
171}
172#[doc = "`reset()` method sets FLT_ID2_IDMASK to value 0"]
173impl crate::Resettable for FltId2IdmaskSpec {}