atsam4e16c_pac/can0/
br.rs1#[doc = "Register `BR` reader"]
2pub struct R(crate::R<BR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BR` writer"]
17pub struct W(crate::W<BR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BR_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<BR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `PHASE2` reader - Phase 2 segment"]
38pub type PHASE2_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `PHASE2` writer - Phase 2 segment"]
40pub type PHASE2_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BR_SPEC, u8, u8, 3, O>;
41#[doc = "Field `PHASE1` reader - Phase 1 segment"]
42pub type PHASE1_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `PHASE1` writer - Phase 1 segment"]
44pub type PHASE1_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BR_SPEC, u8, u8, 3, O>;
45#[doc = "Field `PROPAG` reader - Programming time segment"]
46pub type PROPAG_R = crate::FieldReader<u8, u8>;
47#[doc = "Field `PROPAG` writer - Programming time segment"]
48pub type PROPAG_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BR_SPEC, u8, u8, 3, O>;
49#[doc = "Field `SJW` reader - Re-synchronization jump width"]
50pub type SJW_R = crate::FieldReader<u8, u8>;
51#[doc = "Field `SJW` writer - Re-synchronization jump width"]
52pub type SJW_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BR_SPEC, u8, u8, 2, O>;
53#[doc = "Field `BRP` reader - Baudrate Prescaler."]
54pub type BRP_R = crate::FieldReader<u8, u8>;
55#[doc = "Field `BRP` writer - Baudrate Prescaler."]
56pub type BRP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, BR_SPEC, u8, u8, 7, O>;
57#[doc = "Field `SMP` reader - Sampling Mode"]
58pub type SMP_R = crate::BitReader<SMP_A>;
59#[doc = "Sampling Mode\n\nValue on reset: 0"]
60#[derive(Clone, Copy, Debug, PartialEq, Eq)]
61pub enum SMP_A {
62 #[doc = "0: The incoming bit stream is sampled once at sample point."]
63 ONCE = 0,
64 #[doc = "1: The incoming bit stream is sampled three times with a period of a peripheral clock, centered on sample point."]
65 THREE = 1,
66}
67impl From<SMP_A> for bool {
68 #[inline(always)]
69 fn from(variant: SMP_A) -> Self {
70 variant as u8 != 0
71 }
72}
73impl SMP_R {
74 #[doc = "Get enumerated values variant"]
75 #[inline(always)]
76 pub fn variant(&self) -> SMP_A {
77 match self.bits {
78 false => SMP_A::ONCE,
79 true => SMP_A::THREE,
80 }
81 }
82 #[doc = "Checks if the value of the field is `ONCE`"]
83 #[inline(always)]
84 pub fn is_once(&self) -> bool {
85 *self == SMP_A::ONCE
86 }
87 #[doc = "Checks if the value of the field is `THREE`"]
88 #[inline(always)]
89 pub fn is_three(&self) -> bool {
90 *self == SMP_A::THREE
91 }
92}
93#[doc = "Field `SMP` writer - Sampling Mode"]
94pub type SMP_W<'a, const O: u8> = crate::BitWriter<'a, u32, BR_SPEC, SMP_A, O>;
95impl<'a, const O: u8> SMP_W<'a, O> {
96 #[doc = "The incoming bit stream is sampled once at sample point."]
97 #[inline(always)]
98 pub fn once(self) -> &'a mut W {
99 self.variant(SMP_A::ONCE)
100 }
101 #[doc = "The incoming bit stream is sampled three times with a period of a peripheral clock, centered on sample point."]
102 #[inline(always)]
103 pub fn three(self) -> &'a mut W {
104 self.variant(SMP_A::THREE)
105 }
106}
107impl R {
108 #[doc = "Bits 0:2 - Phase 2 segment"]
109 #[inline(always)]
110 pub fn phase2(&self) -> PHASE2_R {
111 PHASE2_R::new((self.bits & 7) as u8)
112 }
113 #[doc = "Bits 4:6 - Phase 1 segment"]
114 #[inline(always)]
115 pub fn phase1(&self) -> PHASE1_R {
116 PHASE1_R::new(((self.bits >> 4) & 7) as u8)
117 }
118 #[doc = "Bits 8:10 - Programming time segment"]
119 #[inline(always)]
120 pub fn propag(&self) -> PROPAG_R {
121 PROPAG_R::new(((self.bits >> 8) & 7) as u8)
122 }
123 #[doc = "Bits 12:13 - Re-synchronization jump width"]
124 #[inline(always)]
125 pub fn sjw(&self) -> SJW_R {
126 SJW_R::new(((self.bits >> 12) & 3) as u8)
127 }
128 #[doc = "Bits 16:22 - Baudrate Prescaler."]
129 #[inline(always)]
130 pub fn brp(&self) -> BRP_R {
131 BRP_R::new(((self.bits >> 16) & 0x7f) as u8)
132 }
133 #[doc = "Bit 24 - Sampling Mode"]
134 #[inline(always)]
135 pub fn smp(&self) -> SMP_R {
136 SMP_R::new(((self.bits >> 24) & 1) != 0)
137 }
138}
139impl W {
140 #[doc = "Bits 0:2 - Phase 2 segment"]
141 #[inline(always)]
142 #[must_use]
143 pub fn phase2(&mut self) -> PHASE2_W<0> {
144 PHASE2_W::new(self)
145 }
146 #[doc = "Bits 4:6 - Phase 1 segment"]
147 #[inline(always)]
148 #[must_use]
149 pub fn phase1(&mut self) -> PHASE1_W<4> {
150 PHASE1_W::new(self)
151 }
152 #[doc = "Bits 8:10 - Programming time segment"]
153 #[inline(always)]
154 #[must_use]
155 pub fn propag(&mut self) -> PROPAG_W<8> {
156 PROPAG_W::new(self)
157 }
158 #[doc = "Bits 12:13 - Re-synchronization jump width"]
159 #[inline(always)]
160 #[must_use]
161 pub fn sjw(&mut self) -> SJW_W<12> {
162 SJW_W::new(self)
163 }
164 #[doc = "Bits 16:22 - Baudrate Prescaler."]
165 #[inline(always)]
166 #[must_use]
167 pub fn brp(&mut self) -> BRP_W<16> {
168 BRP_W::new(self)
169 }
170 #[doc = "Bit 24 - Sampling Mode"]
171 #[inline(always)]
172 #[must_use]
173 pub fn smp(&mut self) -> SMP_W<24> {
174 SMP_W::new(self)
175 }
176 #[doc = "Writes raw bits to the register."]
177 #[inline(always)]
178 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
179 self.0.bits(bits);
180 self
181 }
182}
183#[doc = "Baudrate 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 [br](index.html) module"]
184pub struct BR_SPEC;
185impl crate::RegisterSpec for BR_SPEC {
186 type Ux = u32;
187}
188#[doc = "`read()` method returns [br::R](R) reader structure"]
189impl crate::Readable for BR_SPEC {
190 type Reader = R;
191}
192#[doc = "`write(|w| ..)` method takes [br::W](W) writer structure"]
193impl crate::Writable for BR_SPEC {
194 type Writer = W;
195 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
196 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
197}
198#[doc = "`reset()` method sets BR to value 0"]
199impl crate::Resettable for BR_SPEC {
200 const RESET_VALUE: Self::Ux = 0;
201}