1#[doc = "Register `BCR` reader"]
2pub struct R(crate::R<BCR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BCR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BCR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BCR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BCR` writer"]
17pub struct W(crate::W<BCR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BCR_SPEC>;
20 #[inline(always)]
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::ops::DerefMut for W {
26 #[inline(always)]
27 fn deref_mut(&mut self) -> &mut Self::Target {
28 &mut self.0
29 }
30}
31impl From<crate::W<BCR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BCR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CCLKS` reader - CAN Clock Source Selection"]
38pub type CCLKS_R = crate::BitReader<CCLKS_A>;
39#[doc = "CAN Clock Source Selection\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum CCLKS_A {
42 #[doc = "0: PCLK (generated by the PLL clock)"]
43 _0 = 0,
44 #[doc = "1: CANMCLK (generated by the main clock)"]
45 _1 = 1,
46}
47impl From<CCLKS_A> for bool {
48 #[inline(always)]
49 fn from(variant: CCLKS_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl CCLKS_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> CCLKS_A {
57 match self.bits {
58 false => CCLKS_A::_0,
59 true => CCLKS_A::_1,
60 }
61 }
62 #[doc = "Checks if the value of the field is `_0`"]
63 #[inline(always)]
64 pub fn is_0(&self) -> bool {
65 *self == CCLKS_A::_0
66 }
67 #[doc = "Checks if the value of the field is `_1`"]
68 #[inline(always)]
69 pub fn is_1(&self) -> bool {
70 *self == CCLKS_A::_1
71 }
72}
73#[doc = "Field `CCLKS` writer - CAN Clock Source Selection"]
74pub type CCLKS_W<'a, const O: u8> = crate::BitWriter<'a, u32, BCR_SPEC, CCLKS_A, O>;
75impl<'a, const O: u8> CCLKS_W<'a, O> {
76 #[doc = "PCLK (generated by the PLL clock)"]
77 #[inline(always)]
78 pub fn _0(self) -> &'a mut W {
79 self.variant(CCLKS_A::_0)
80 }
81 #[doc = "CANMCLK (generated by the main clock)"]
82 #[inline(always)]
83 pub fn _1(self) -> &'a mut W {
84 self.variant(CCLKS_A::_1)
85 }
86}
87#[doc = "Field `TSEG2` reader - Time Segment 2 Control"]
88pub type TSEG2_R = crate::FieldReader<u8, TSEG2_A>;
89#[doc = "Time Segment 2 Control\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum TSEG2_A {
93 #[doc = "0: Setting prohibited"]
94 _000 = 0,
95 #[doc = "1: 2 Tq"]
96 _001 = 1,
97 #[doc = "2: 3 Tq"]
98 _010 = 2,
99 #[doc = "3: 4 Tq"]
100 _011 = 3,
101 #[doc = "4: 5 Tq"]
102 _100 = 4,
103 #[doc = "5: 6 Tq"]
104 _101 = 5,
105 #[doc = "6: 7 Tq"]
106 _110 = 6,
107 #[doc = "7: 8 Tq"]
108 _111 = 7,
109}
110impl From<TSEG2_A> for u8 {
111 #[inline(always)]
112 fn from(variant: TSEG2_A) -> Self {
113 variant as _
114 }
115}
116impl TSEG2_R {
117 #[doc = "Get enumerated values variant"]
118 #[inline(always)]
119 pub fn variant(&self) -> TSEG2_A {
120 match self.bits {
121 0 => TSEG2_A::_000,
122 1 => TSEG2_A::_001,
123 2 => TSEG2_A::_010,
124 3 => TSEG2_A::_011,
125 4 => TSEG2_A::_100,
126 5 => TSEG2_A::_101,
127 6 => TSEG2_A::_110,
128 7 => TSEG2_A::_111,
129 _ => unreachable!(),
130 }
131 }
132 #[doc = "Checks if the value of the field is `_000`"]
133 #[inline(always)]
134 pub fn is_000(&self) -> bool {
135 *self == TSEG2_A::_000
136 }
137 #[doc = "Checks if the value of the field is `_001`"]
138 #[inline(always)]
139 pub fn is_001(&self) -> bool {
140 *self == TSEG2_A::_001
141 }
142 #[doc = "Checks if the value of the field is `_010`"]
143 #[inline(always)]
144 pub fn is_010(&self) -> bool {
145 *self == TSEG2_A::_010
146 }
147 #[doc = "Checks if the value of the field is `_011`"]
148 #[inline(always)]
149 pub fn is_011(&self) -> bool {
150 *self == TSEG2_A::_011
151 }
152 #[doc = "Checks if the value of the field is `_100`"]
153 #[inline(always)]
154 pub fn is_100(&self) -> bool {
155 *self == TSEG2_A::_100
156 }
157 #[doc = "Checks if the value of the field is `_101`"]
158 #[inline(always)]
159 pub fn is_101(&self) -> bool {
160 *self == TSEG2_A::_101
161 }
162 #[doc = "Checks if the value of the field is `_110`"]
163 #[inline(always)]
164 pub fn is_110(&self) -> bool {
165 *self == TSEG2_A::_110
166 }
167 #[doc = "Checks if the value of the field is `_111`"]
168 #[inline(always)]
169 pub fn is_111(&self) -> bool {
170 *self == TSEG2_A::_111
171 }
172}
173#[doc = "Field `TSEG2` writer - Time Segment 2 Control"]
174pub type TSEG2_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, BCR_SPEC, u8, TSEG2_A, 3, O>;
175impl<'a, const O: u8> TSEG2_W<'a, O> {
176 #[doc = "Setting prohibited"]
177 #[inline(always)]
178 pub fn _000(self) -> &'a mut W {
179 self.variant(TSEG2_A::_000)
180 }
181 #[doc = "2 Tq"]
182 #[inline(always)]
183 pub fn _001(self) -> &'a mut W {
184 self.variant(TSEG2_A::_001)
185 }
186 #[doc = "3 Tq"]
187 #[inline(always)]
188 pub fn _010(self) -> &'a mut W {
189 self.variant(TSEG2_A::_010)
190 }
191 #[doc = "4 Tq"]
192 #[inline(always)]
193 pub fn _011(self) -> &'a mut W {
194 self.variant(TSEG2_A::_011)
195 }
196 #[doc = "5 Tq"]
197 #[inline(always)]
198 pub fn _100(self) -> &'a mut W {
199 self.variant(TSEG2_A::_100)
200 }
201 #[doc = "6 Tq"]
202 #[inline(always)]
203 pub fn _101(self) -> &'a mut W {
204 self.variant(TSEG2_A::_101)
205 }
206 #[doc = "7 Tq"]
207 #[inline(always)]
208 pub fn _110(self) -> &'a mut W {
209 self.variant(TSEG2_A::_110)
210 }
211 #[doc = "8 Tq"]
212 #[inline(always)]
213 pub fn _111(self) -> &'a mut W {
214 self.variant(TSEG2_A::_111)
215 }
216}
217#[doc = "Field `SJW` reader - Resynchronization Jump Width Control"]
218pub type SJW_R = crate::FieldReader<u8, SJW_A>;
219#[doc = "Resynchronization Jump Width Control\n\nValue on reset: 0"]
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221#[repr(u8)]
222pub enum SJW_A {
223 #[doc = "0: 1 Tq"]
224 _00 = 0,
225 #[doc = "1: 2 Tq"]
226 _01 = 1,
227 #[doc = "2: 3 Tq"]
228 _10 = 2,
229 #[doc = "3: 4 Tq"]
230 _11 = 3,
231}
232impl From<SJW_A> for u8 {
233 #[inline(always)]
234 fn from(variant: SJW_A) -> Self {
235 variant as _
236 }
237}
238impl SJW_R {
239 #[doc = "Get enumerated values variant"]
240 #[inline(always)]
241 pub fn variant(&self) -> SJW_A {
242 match self.bits {
243 0 => SJW_A::_00,
244 1 => SJW_A::_01,
245 2 => SJW_A::_10,
246 3 => SJW_A::_11,
247 _ => unreachable!(),
248 }
249 }
250 #[doc = "Checks if the value of the field is `_00`"]
251 #[inline(always)]
252 pub fn is_00(&self) -> bool {
253 *self == SJW_A::_00
254 }
255 #[doc = "Checks if the value of the field is `_01`"]
256 #[inline(always)]
257 pub fn is_01(&self) -> bool {
258 *self == SJW_A::_01
259 }
260 #[doc = "Checks if the value of the field is `_10`"]
261 #[inline(always)]
262 pub fn is_10(&self) -> bool {
263 *self == SJW_A::_10
264 }
265 #[doc = "Checks if the value of the field is `_11`"]
266 #[inline(always)]
267 pub fn is_11(&self) -> bool {
268 *self == SJW_A::_11
269 }
270}
271#[doc = "Field `SJW` writer - Resynchronization Jump Width Control"]
272pub type SJW_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, BCR_SPEC, u8, SJW_A, 2, O>;
273impl<'a, const O: u8> SJW_W<'a, O> {
274 #[doc = "1 Tq"]
275 #[inline(always)]
276 pub fn _00(self) -> &'a mut W {
277 self.variant(SJW_A::_00)
278 }
279 #[doc = "2 Tq"]
280 #[inline(always)]
281 pub fn _01(self) -> &'a mut W {
282 self.variant(SJW_A::_01)
283 }
284 #[doc = "3 Tq"]
285 #[inline(always)]
286 pub fn _10(self) -> &'a mut W {
287 self.variant(SJW_A::_10)
288 }
289 #[doc = "4 Tq"]
290 #[inline(always)]
291 pub fn _11(self) -> &'a mut W {
292 self.variant(SJW_A::_11)
293 }
294}
295#[doc = "Field `BRP` reader - Prescaler Division Ratio Select . These bits set the frequency of the CAN communication clock (fCANCLK)."]
296pub type BRP_R = crate::FieldReader<u16, u16>;
297#[doc = "Field `BRP` writer - Prescaler Division Ratio Select . These bits set the frequency of the CAN communication clock (fCANCLK)."]
298pub type BRP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BCR_SPEC, u16, u16, 10, O>;
299#[doc = "Field `TSEG1` reader - Time Segment 1 Control"]
300pub type TSEG1_R = crate::FieldReader<u8, TSEG1_A>;
301#[doc = "Time Segment 1 Control\n\nValue on reset: 0"]
302#[derive(Clone, Copy, Debug, PartialEq, Eq)]
303#[repr(u8)]
304pub enum TSEG1_A {
305 #[doc = "0: Setting prohibited"]
306 _0000 = 0,
307 #[doc = "1: Setting prohibited"]
308 _0001 = 1,
309 #[doc = "2: Setting prohibited"]
310 _0010 = 2,
311 #[doc = "3: 4 Tq"]
312 _0011 = 3,
313 #[doc = "4: 5 Tq"]
314 _0100 = 4,
315 #[doc = "5: 6 Tq"]
316 _0101 = 5,
317 #[doc = "6: 7 Tq"]
318 _0110 = 6,
319 #[doc = "7: 8 Tq"]
320 _0111 = 7,
321 #[doc = "8: 9 Tq"]
322 _1000 = 8,
323 #[doc = "9: 10 Tq"]
324 _1001 = 9,
325 #[doc = "10: 11 Tq"]
326 _1010 = 10,
327 #[doc = "11: 12 Tq"]
328 _1011 = 11,
329 #[doc = "12: 13 Tq"]
330 _1100 = 12,
331 #[doc = "13: 14 Tq"]
332 _1101 = 13,
333 #[doc = "14: 15 Tq"]
334 _1110 = 14,
335 #[doc = "15: 16 Tq"]
336 _1111 = 15,
337}
338impl From<TSEG1_A> for u8 {
339 #[inline(always)]
340 fn from(variant: TSEG1_A) -> Self {
341 variant as _
342 }
343}
344impl TSEG1_R {
345 #[doc = "Get enumerated values variant"]
346 #[inline(always)]
347 pub fn variant(&self) -> TSEG1_A {
348 match self.bits {
349 0 => TSEG1_A::_0000,
350 1 => TSEG1_A::_0001,
351 2 => TSEG1_A::_0010,
352 3 => TSEG1_A::_0011,
353 4 => TSEG1_A::_0100,
354 5 => TSEG1_A::_0101,
355 6 => TSEG1_A::_0110,
356 7 => TSEG1_A::_0111,
357 8 => TSEG1_A::_1000,
358 9 => TSEG1_A::_1001,
359 10 => TSEG1_A::_1010,
360 11 => TSEG1_A::_1011,
361 12 => TSEG1_A::_1100,
362 13 => TSEG1_A::_1101,
363 14 => TSEG1_A::_1110,
364 15 => TSEG1_A::_1111,
365 _ => unreachable!(),
366 }
367 }
368 #[doc = "Checks if the value of the field is `_0000`"]
369 #[inline(always)]
370 pub fn is_0000(&self) -> bool {
371 *self == TSEG1_A::_0000
372 }
373 #[doc = "Checks if the value of the field is `_0001`"]
374 #[inline(always)]
375 pub fn is_0001(&self) -> bool {
376 *self == TSEG1_A::_0001
377 }
378 #[doc = "Checks if the value of the field is `_0010`"]
379 #[inline(always)]
380 pub fn is_0010(&self) -> bool {
381 *self == TSEG1_A::_0010
382 }
383 #[doc = "Checks if the value of the field is `_0011`"]
384 #[inline(always)]
385 pub fn is_0011(&self) -> bool {
386 *self == TSEG1_A::_0011
387 }
388 #[doc = "Checks if the value of the field is `_0100`"]
389 #[inline(always)]
390 pub fn is_0100(&self) -> bool {
391 *self == TSEG1_A::_0100
392 }
393 #[doc = "Checks if the value of the field is `_0101`"]
394 #[inline(always)]
395 pub fn is_0101(&self) -> bool {
396 *self == TSEG1_A::_0101
397 }
398 #[doc = "Checks if the value of the field is `_0110`"]
399 #[inline(always)]
400 pub fn is_0110(&self) -> bool {
401 *self == TSEG1_A::_0110
402 }
403 #[doc = "Checks if the value of the field is `_0111`"]
404 #[inline(always)]
405 pub fn is_0111(&self) -> bool {
406 *self == TSEG1_A::_0111
407 }
408 #[doc = "Checks if the value of the field is `_1000`"]
409 #[inline(always)]
410 pub fn is_1000(&self) -> bool {
411 *self == TSEG1_A::_1000
412 }
413 #[doc = "Checks if the value of the field is `_1001`"]
414 #[inline(always)]
415 pub fn is_1001(&self) -> bool {
416 *self == TSEG1_A::_1001
417 }
418 #[doc = "Checks if the value of the field is `_1010`"]
419 #[inline(always)]
420 pub fn is_1010(&self) -> bool {
421 *self == TSEG1_A::_1010
422 }
423 #[doc = "Checks if the value of the field is `_1011`"]
424 #[inline(always)]
425 pub fn is_1011(&self) -> bool {
426 *self == TSEG1_A::_1011
427 }
428 #[doc = "Checks if the value of the field is `_1100`"]
429 #[inline(always)]
430 pub fn is_1100(&self) -> bool {
431 *self == TSEG1_A::_1100
432 }
433 #[doc = "Checks if the value of the field is `_1101`"]
434 #[inline(always)]
435 pub fn is_1101(&self) -> bool {
436 *self == TSEG1_A::_1101
437 }
438 #[doc = "Checks if the value of the field is `_1110`"]
439 #[inline(always)]
440 pub fn is_1110(&self) -> bool {
441 *self == TSEG1_A::_1110
442 }
443 #[doc = "Checks if the value of the field is `_1111`"]
444 #[inline(always)]
445 pub fn is_1111(&self) -> bool {
446 *self == TSEG1_A::_1111
447 }
448}
449#[doc = "Field `TSEG1` writer - Time Segment 1 Control"]
450pub type TSEG1_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, BCR_SPEC, u8, TSEG1_A, 4, O>;
451impl<'a, const O: u8> TSEG1_W<'a, O> {
452 #[doc = "Setting prohibited"]
453 #[inline(always)]
454 pub fn _0000(self) -> &'a mut W {
455 self.variant(TSEG1_A::_0000)
456 }
457 #[doc = "Setting prohibited"]
458 #[inline(always)]
459 pub fn _0001(self) -> &'a mut W {
460 self.variant(TSEG1_A::_0001)
461 }
462 #[doc = "Setting prohibited"]
463 #[inline(always)]
464 pub fn _0010(self) -> &'a mut W {
465 self.variant(TSEG1_A::_0010)
466 }
467 #[doc = "4 Tq"]
468 #[inline(always)]
469 pub fn _0011(self) -> &'a mut W {
470 self.variant(TSEG1_A::_0011)
471 }
472 #[doc = "5 Tq"]
473 #[inline(always)]
474 pub fn _0100(self) -> &'a mut W {
475 self.variant(TSEG1_A::_0100)
476 }
477 #[doc = "6 Tq"]
478 #[inline(always)]
479 pub fn _0101(self) -> &'a mut W {
480 self.variant(TSEG1_A::_0101)
481 }
482 #[doc = "7 Tq"]
483 #[inline(always)]
484 pub fn _0110(self) -> &'a mut W {
485 self.variant(TSEG1_A::_0110)
486 }
487 #[doc = "8 Tq"]
488 #[inline(always)]
489 pub fn _0111(self) -> &'a mut W {
490 self.variant(TSEG1_A::_0111)
491 }
492 #[doc = "9 Tq"]
493 #[inline(always)]
494 pub fn _1000(self) -> &'a mut W {
495 self.variant(TSEG1_A::_1000)
496 }
497 #[doc = "10 Tq"]
498 #[inline(always)]
499 pub fn _1001(self) -> &'a mut W {
500 self.variant(TSEG1_A::_1001)
501 }
502 #[doc = "11 Tq"]
503 #[inline(always)]
504 pub fn _1010(self) -> &'a mut W {
505 self.variant(TSEG1_A::_1010)
506 }
507 #[doc = "12 Tq"]
508 #[inline(always)]
509 pub fn _1011(self) -> &'a mut W {
510 self.variant(TSEG1_A::_1011)
511 }
512 #[doc = "13 Tq"]
513 #[inline(always)]
514 pub fn _1100(self) -> &'a mut W {
515 self.variant(TSEG1_A::_1100)
516 }
517 #[doc = "14 Tq"]
518 #[inline(always)]
519 pub fn _1101(self) -> &'a mut W {
520 self.variant(TSEG1_A::_1101)
521 }
522 #[doc = "15 Tq"]
523 #[inline(always)]
524 pub fn _1110(self) -> &'a mut W {
525 self.variant(TSEG1_A::_1110)
526 }
527 #[doc = "16 Tq"]
528 #[inline(always)]
529 pub fn _1111(self) -> &'a mut W {
530 self.variant(TSEG1_A::_1111)
531 }
532}
533impl R {
534 #[doc = "Bit 0 - CAN Clock Source Selection"]
535 #[inline(always)]
536 pub fn cclks(&self) -> CCLKS_R {
537 CCLKS_R::new((self.bits & 1) != 0)
538 }
539 #[doc = "Bits 8:10 - Time Segment 2 Control"]
540 #[inline(always)]
541 pub fn tseg2(&self) -> TSEG2_R {
542 TSEG2_R::new(((self.bits >> 8) & 7) as u8)
543 }
544 #[doc = "Bits 12:13 - Resynchronization Jump Width Control"]
545 #[inline(always)]
546 pub fn sjw(&self) -> SJW_R {
547 SJW_R::new(((self.bits >> 12) & 3) as u8)
548 }
549 #[doc = "Bits 16:25 - Prescaler Division Ratio Select . These bits set the frequency of the CAN communication clock (fCANCLK)."]
550 #[inline(always)]
551 pub fn brp(&self) -> BRP_R {
552 BRP_R::new(((self.bits >> 16) & 0x03ff) as u16)
553 }
554 #[doc = "Bits 28:31 - Time Segment 1 Control"]
555 #[inline(always)]
556 pub fn tseg1(&self) -> TSEG1_R {
557 TSEG1_R::new(((self.bits >> 28) & 0x0f) as u8)
558 }
559}
560impl W {
561 #[doc = "Bit 0 - CAN Clock Source Selection"]
562 #[inline(always)]
563 #[must_use]
564 pub fn cclks(&mut self) -> CCLKS_W<0> {
565 CCLKS_W::new(self)
566 }
567 #[doc = "Bits 8:10 - Time Segment 2 Control"]
568 #[inline(always)]
569 #[must_use]
570 pub fn tseg2(&mut self) -> TSEG2_W<8> {
571 TSEG2_W::new(self)
572 }
573 #[doc = "Bits 12:13 - Resynchronization Jump Width Control"]
574 #[inline(always)]
575 #[must_use]
576 pub fn sjw(&mut self) -> SJW_W<12> {
577 SJW_W::new(self)
578 }
579 #[doc = "Bits 16:25 - Prescaler Division Ratio Select . These bits set the frequency of the CAN communication clock (fCANCLK)."]
580 #[inline(always)]
581 #[must_use]
582 pub fn brp(&mut self) -> BRP_W<16> {
583 BRP_W::new(self)
584 }
585 #[doc = "Bits 28:31 - Time Segment 1 Control"]
586 #[inline(always)]
587 #[must_use]
588 pub fn tseg1(&mut self) -> TSEG1_W<28> {
589 TSEG1_W::new(self)
590 }
591 #[doc = "Writes raw bits to the register."]
592 #[inline(always)]
593 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
594 self.0.bits(bits);
595 self
596 }
597}
598#[doc = "Bit Configuration Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [bcr](index.html) module"]
599pub struct BCR_SPEC;
600impl crate::RegisterSpec for BCR_SPEC {
601 type Ux = u32;
602}
603#[doc = "`read()` method returns [bcr::R](R) reader structure"]
604impl crate::Readable for BCR_SPEC {
605 type Reader = R;
606}
607#[doc = "`write(|w| ..)` method takes [bcr::W](W) writer structure"]
608impl crate::Writable for BCR_SPEC {
609 type Writer = W;
610 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
611 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
612}
613#[doc = "`reset()` method sets BCR to value 0"]
614impl crate::Resettable for BCR_SPEC {
615 const RESET_VALUE: Self::Ux = 0;
616}