xmc4100/can_node0/
nfcr.rs1#[doc = "Register `NFCR` reader"]
2pub type R = crate::R<NFCR_SPEC>;
3#[doc = "Register `NFCR` writer"]
4pub type W = crate::W<NFCR_SPEC>;
5#[doc = "Field `CFC` reader - CAN Frame Counter"]
6pub type CFC_R = crate::FieldReader<u16>;
7#[doc = "Field `CFC` writer - CAN Frame Counter"]
8pub type CFC_W<'a, REG> = crate::FieldWriter<'a, REG, 16, u16>;
9#[doc = "CAN Frame Count Selection\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum CFSEL_A {
13 #[doc = "0: The frame counter is incremented (internally) at the beginning of a new bit time. The value is sampled during the SOF bit of a new frame. The sampled value is visible in the CFC field."]
14 VALUE1 = 0,
15}
16impl From<CFSEL_A> for u8 {
17 #[inline(always)]
18 fn from(variant: CFSEL_A) -> Self {
19 variant as _
20 }
21}
22impl crate::FieldSpec for CFSEL_A {
23 type Ux = u8;
24}
25impl crate::IsEnum for CFSEL_A {}
26#[doc = "Field `CFSEL` reader - CAN Frame Count Selection"]
27pub type CFSEL_R = crate::FieldReader<CFSEL_A>;
28impl CFSEL_R {
29 #[doc = "Get enumerated values variant"]
30 #[inline(always)]
31 pub const fn variant(&self) -> Option<CFSEL_A> {
32 match self.bits {
33 0 => Some(CFSEL_A::VALUE1),
34 _ => None,
35 }
36 }
37 #[doc = "The frame counter is incremented (internally) at the beginning of a new bit time. The value is sampled during the SOF bit of a new frame. The sampled value is visible in the CFC field."]
38 #[inline(always)]
39 pub fn is_value1(&self) -> bool {
40 *self == CFSEL_A::VALUE1
41 }
42}
43#[doc = "Field `CFSEL` writer - CAN Frame Count Selection"]
44pub type CFSEL_W<'a, REG> = crate::FieldWriter<'a, REG, 3, CFSEL_A>;
45impl<'a, REG> CFSEL_W<'a, REG>
46where
47 REG: crate::Writable + crate::RegisterSpec,
48 REG::Ux: From<u8>,
49{
50 #[doc = "The frame counter is incremented (internally) at the beginning of a new bit time. The value is sampled during the SOF bit of a new frame. The sampled value is visible in the CFC field."]
51 #[inline(always)]
52 pub fn value1(self) -> &'a mut crate::W<REG> {
53 self.variant(CFSEL_A::VALUE1)
54 }
55}
56#[doc = "CAN Frame Counter Mode\n\nValue on reset: 0"]
57#[derive(Clone, Copy, Debug, PartialEq, Eq)]
58#[repr(u8)]
59pub enum CFMOD_A {
60 #[doc = "0: Frame Count Mode: The frame counter is incremented upon the reception and transmission of frames."]
61 VALUE1 = 0,
62 #[doc = "1: Time Stamp Mode: The frame counter is used to count bit times."]
63 VALUE2 = 1,
64 #[doc = "2: Bit Timing Mode: The frame counter is used for analysis of the bit timing."]
65 VALUE3 = 2,
66}
67impl From<CFMOD_A> for u8 {
68 #[inline(always)]
69 fn from(variant: CFMOD_A) -> Self {
70 variant as _
71 }
72}
73impl crate::FieldSpec for CFMOD_A {
74 type Ux = u8;
75}
76impl crate::IsEnum for CFMOD_A {}
77#[doc = "Field `CFMOD` reader - CAN Frame Counter Mode"]
78pub type CFMOD_R = crate::FieldReader<CFMOD_A>;
79impl CFMOD_R {
80 #[doc = "Get enumerated values variant"]
81 #[inline(always)]
82 pub const fn variant(&self) -> Option<CFMOD_A> {
83 match self.bits {
84 0 => Some(CFMOD_A::VALUE1),
85 1 => Some(CFMOD_A::VALUE2),
86 2 => Some(CFMOD_A::VALUE3),
87 _ => None,
88 }
89 }
90 #[doc = "Frame Count Mode: The frame counter is incremented upon the reception and transmission of frames."]
91 #[inline(always)]
92 pub fn is_value1(&self) -> bool {
93 *self == CFMOD_A::VALUE1
94 }
95 #[doc = "Time Stamp Mode: The frame counter is used to count bit times."]
96 #[inline(always)]
97 pub fn is_value2(&self) -> bool {
98 *self == CFMOD_A::VALUE2
99 }
100 #[doc = "Bit Timing Mode: The frame counter is used for analysis of the bit timing."]
101 #[inline(always)]
102 pub fn is_value3(&self) -> bool {
103 *self == CFMOD_A::VALUE3
104 }
105}
106#[doc = "Field `CFMOD` writer - CAN Frame Counter Mode"]
107pub type CFMOD_W<'a, REG> = crate::FieldWriter<'a, REG, 2, CFMOD_A>;
108impl<'a, REG> CFMOD_W<'a, REG>
109where
110 REG: crate::Writable + crate::RegisterSpec,
111 REG::Ux: From<u8>,
112{
113 #[doc = "Frame Count Mode: The frame counter is incremented upon the reception and transmission of frames."]
114 #[inline(always)]
115 pub fn value1(self) -> &'a mut crate::W<REG> {
116 self.variant(CFMOD_A::VALUE1)
117 }
118 #[doc = "Time Stamp Mode: The frame counter is used to count bit times."]
119 #[inline(always)]
120 pub fn value2(self) -> &'a mut crate::W<REG> {
121 self.variant(CFMOD_A::VALUE2)
122 }
123 #[doc = "Bit Timing Mode: The frame counter is used for analysis of the bit timing."]
124 #[inline(always)]
125 pub fn value3(self) -> &'a mut crate::W<REG> {
126 self.variant(CFMOD_A::VALUE3)
127 }
128}
129#[doc = "CAN Frame Count Interrupt Enable\n\nValue on reset: 0"]
130#[derive(Clone, Copy, Debug, PartialEq, Eq)]
131pub enum CFCIE_A {
132 #[doc = "0: CAN frame counter overflow interrupt is disabled."]
133 VALUE1 = 0,
134 #[doc = "1: CAN frame counter overflow interrupt is enabled."]
135 VALUE2 = 1,
136}
137impl From<CFCIE_A> for bool {
138 #[inline(always)]
139 fn from(variant: CFCIE_A) -> Self {
140 variant as u8 != 0
141 }
142}
143#[doc = "Field `CFCIE` reader - CAN Frame Count Interrupt Enable"]
144pub type CFCIE_R = crate::BitReader<CFCIE_A>;
145impl CFCIE_R {
146 #[doc = "Get enumerated values variant"]
147 #[inline(always)]
148 pub const fn variant(&self) -> CFCIE_A {
149 match self.bits {
150 false => CFCIE_A::VALUE1,
151 true => CFCIE_A::VALUE2,
152 }
153 }
154 #[doc = "CAN frame counter overflow interrupt is disabled."]
155 #[inline(always)]
156 pub fn is_value1(&self) -> bool {
157 *self == CFCIE_A::VALUE1
158 }
159 #[doc = "CAN frame counter overflow interrupt is enabled."]
160 #[inline(always)]
161 pub fn is_value2(&self) -> bool {
162 *self == CFCIE_A::VALUE2
163 }
164}
165#[doc = "Field `CFCIE` writer - CAN Frame Count Interrupt Enable"]
166pub type CFCIE_W<'a, REG> = crate::BitWriter<'a, REG, CFCIE_A>;
167impl<'a, REG> CFCIE_W<'a, REG>
168where
169 REG: crate::Writable + crate::RegisterSpec,
170{
171 #[doc = "CAN frame counter overflow interrupt is disabled."]
172 #[inline(always)]
173 pub fn value1(self) -> &'a mut crate::W<REG> {
174 self.variant(CFCIE_A::VALUE1)
175 }
176 #[doc = "CAN frame counter overflow interrupt is enabled."]
177 #[inline(always)]
178 pub fn value2(self) -> &'a mut crate::W<REG> {
179 self.variant(CFCIE_A::VALUE2)
180 }
181}
182#[doc = "CAN Frame Counter Overflow Flag\n\nValue on reset: 0"]
183#[derive(Clone, Copy, Debug, PartialEq, Eq)]
184pub enum CFCOV_A {
185 #[doc = "0: No overflow has occurred since last flag reset."]
186 VALUE1 = 0,
187 #[doc = "1: An overflow has occurred since last flag reset."]
188 VALUE2 = 1,
189}
190impl From<CFCOV_A> for bool {
191 #[inline(always)]
192 fn from(variant: CFCOV_A) -> Self {
193 variant as u8 != 0
194 }
195}
196#[doc = "Field `CFCOV` reader - CAN Frame Counter Overflow Flag"]
197pub type CFCOV_R = crate::BitReader<CFCOV_A>;
198impl CFCOV_R {
199 #[doc = "Get enumerated values variant"]
200 #[inline(always)]
201 pub const fn variant(&self) -> CFCOV_A {
202 match self.bits {
203 false => CFCOV_A::VALUE1,
204 true => CFCOV_A::VALUE2,
205 }
206 }
207 #[doc = "No overflow has occurred since last flag reset."]
208 #[inline(always)]
209 pub fn is_value1(&self) -> bool {
210 *self == CFCOV_A::VALUE1
211 }
212 #[doc = "An overflow has occurred since last flag reset."]
213 #[inline(always)]
214 pub fn is_value2(&self) -> bool {
215 *self == CFCOV_A::VALUE2
216 }
217}
218#[doc = "Field `CFCOV` writer - CAN Frame Counter Overflow Flag"]
219pub type CFCOV_W<'a, REG> = crate::BitWriter<'a, REG, CFCOV_A>;
220impl<'a, REG> CFCOV_W<'a, REG>
221where
222 REG: crate::Writable + crate::RegisterSpec,
223{
224 #[doc = "No overflow has occurred since last flag reset."]
225 #[inline(always)]
226 pub fn value1(self) -> &'a mut crate::W<REG> {
227 self.variant(CFCOV_A::VALUE1)
228 }
229 #[doc = "An overflow has occurred since last flag reset."]
230 #[inline(always)]
231 pub fn value2(self) -> &'a mut crate::W<REG> {
232 self.variant(CFCOV_A::VALUE2)
233 }
234}
235impl R {
236 #[doc = "Bits 0:15 - CAN Frame Counter"]
237 #[inline(always)]
238 pub fn cfc(&self) -> CFC_R {
239 CFC_R::new((self.bits & 0xffff) as u16)
240 }
241 #[doc = "Bits 16:18 - CAN Frame Count Selection"]
242 #[inline(always)]
243 pub fn cfsel(&self) -> CFSEL_R {
244 CFSEL_R::new(((self.bits >> 16) & 7) as u8)
245 }
246 #[doc = "Bits 19:20 - CAN Frame Counter Mode"]
247 #[inline(always)]
248 pub fn cfmod(&self) -> CFMOD_R {
249 CFMOD_R::new(((self.bits >> 19) & 3) as u8)
250 }
251 #[doc = "Bit 22 - CAN Frame Count Interrupt Enable"]
252 #[inline(always)]
253 pub fn cfcie(&self) -> CFCIE_R {
254 CFCIE_R::new(((self.bits >> 22) & 1) != 0)
255 }
256 #[doc = "Bit 23 - CAN Frame Counter Overflow Flag"]
257 #[inline(always)]
258 pub fn cfcov(&self) -> CFCOV_R {
259 CFCOV_R::new(((self.bits >> 23) & 1) != 0)
260 }
261}
262impl W {
263 #[doc = "Bits 0:15 - CAN Frame Counter"]
264 #[inline(always)]
265 pub fn cfc(&mut self) -> CFC_W<NFCR_SPEC> {
266 CFC_W::new(self, 0)
267 }
268 #[doc = "Bits 16:18 - CAN Frame Count Selection"]
269 #[inline(always)]
270 pub fn cfsel(&mut self) -> CFSEL_W<NFCR_SPEC> {
271 CFSEL_W::new(self, 16)
272 }
273 #[doc = "Bits 19:20 - CAN Frame Counter Mode"]
274 #[inline(always)]
275 pub fn cfmod(&mut self) -> CFMOD_W<NFCR_SPEC> {
276 CFMOD_W::new(self, 19)
277 }
278 #[doc = "Bit 22 - CAN Frame Count Interrupt Enable"]
279 #[inline(always)]
280 pub fn cfcie(&mut self) -> CFCIE_W<NFCR_SPEC> {
281 CFCIE_W::new(self, 22)
282 }
283 #[doc = "Bit 23 - CAN Frame Counter Overflow Flag"]
284 #[inline(always)]
285 pub fn cfcov(&mut self) -> CFCOV_W<NFCR_SPEC> {
286 CFCOV_W::new(self, 23)
287 }
288}
289#[doc = "Node Frame Counter Register\n\nYou can [`read`](crate::Reg::read) this register and get [`nfcr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`nfcr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
290pub struct NFCR_SPEC;
291impl crate::RegisterSpec for NFCR_SPEC {
292 type Ux = u32;
293}
294#[doc = "`read()` method returns [`nfcr::R`](R) reader structure"]
295impl crate::Readable for NFCR_SPEC {}
296#[doc = "`write(|w| ..)` method takes [`nfcr::W`](W) writer structure"]
297impl crate::Writable for NFCR_SPEC {
298 type Safety = crate::Unsafe;
299 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
300 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
301}
302#[doc = "`reset()` method sets NFCR to value 0"]
303impl crate::Resettable for NFCR_SPEC {
304 const RESET_VALUE: u32 = 0;
305}