atsame70q21/pmc/
pmc_ocr.rs1#[doc = "Register `PMC_OCR` reader"]
2pub struct R(crate::R<PMC_OCR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PMC_OCR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PMC_OCR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PMC_OCR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PMC_OCR` writer"]
17pub struct W(crate::W<PMC_OCR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PMC_OCR_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<PMC_OCR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PMC_OCR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CAL4` reader - Main RC Oscillator Calibration Bits for 4 MHz"]
38pub struct CAL4_R(crate::FieldReader<u8, u8>);
39impl CAL4_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: u8) -> Self {
42 CAL4_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for CAL4_R {
46 type Target = crate::FieldReader<u8, u8>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `CAL4` writer - Main RC Oscillator Calibration Bits for 4 MHz"]
53pub struct CAL4_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> CAL4_W<'a> {
57 #[doc = r"Writes raw bits to the field"]
58 #[inline(always)]
59 pub unsafe fn bits(self, value: u8) -> &'a mut W {
60 self.w.bits = (self.w.bits & !0x7f) | (value as u32 & 0x7f);
61 self.w
62 }
63}
64#[doc = "Field `SEL4` reader - Selection of Main RC Oscillator Calibration Bits for 4 MHz"]
65pub struct SEL4_R(crate::FieldReader<bool, bool>);
66impl SEL4_R {
67 #[inline(always)]
68 pub(crate) fn new(bits: bool) -> Self {
69 SEL4_R(crate::FieldReader::new(bits))
70 }
71}
72impl core::ops::Deref for SEL4_R {
73 type Target = crate::FieldReader<bool, bool>;
74 #[inline(always)]
75 fn deref(&self) -> &Self::Target {
76 &self.0
77 }
78}
79#[doc = "Field `SEL4` writer - Selection of Main RC Oscillator Calibration Bits for 4 MHz"]
80pub struct SEL4_W<'a> {
81 w: &'a mut W,
82}
83impl<'a> SEL4_W<'a> {
84 #[doc = r"Sets the field bit"]
85 #[inline(always)]
86 pub fn set_bit(self) -> &'a mut W {
87 self.bit(true)
88 }
89 #[doc = r"Clears the field bit"]
90 #[inline(always)]
91 pub fn clear_bit(self) -> &'a mut W {
92 self.bit(false)
93 }
94 #[doc = r"Writes raw bits to the field"]
95 #[inline(always)]
96 pub fn bit(self, value: bool) -> &'a mut W {
97 self.w.bits = (self.w.bits & !(0x01 << 7)) | ((value as u32 & 0x01) << 7);
98 self.w
99 }
100}
101#[doc = "Field `CAL8` reader - Main RC Oscillator Calibration Bits for 8 MHz"]
102pub struct CAL8_R(crate::FieldReader<u8, u8>);
103impl CAL8_R {
104 #[inline(always)]
105 pub(crate) fn new(bits: u8) -> Self {
106 CAL8_R(crate::FieldReader::new(bits))
107 }
108}
109impl core::ops::Deref for CAL8_R {
110 type Target = crate::FieldReader<u8, u8>;
111 #[inline(always)]
112 fn deref(&self) -> &Self::Target {
113 &self.0
114 }
115}
116#[doc = "Field `CAL8` writer - Main RC Oscillator Calibration Bits for 8 MHz"]
117pub struct CAL8_W<'a> {
118 w: &'a mut W,
119}
120impl<'a> CAL8_W<'a> {
121 #[doc = r"Writes raw bits to the field"]
122 #[inline(always)]
123 pub unsafe fn bits(self, value: u8) -> &'a mut W {
124 self.w.bits = (self.w.bits & !(0x7f << 8)) | ((value as u32 & 0x7f) << 8);
125 self.w
126 }
127}
128#[doc = "Field `SEL8` reader - Selection of Main RC Oscillator Calibration Bits for 8 MHz"]
129pub struct SEL8_R(crate::FieldReader<bool, bool>);
130impl SEL8_R {
131 #[inline(always)]
132 pub(crate) fn new(bits: bool) -> Self {
133 SEL8_R(crate::FieldReader::new(bits))
134 }
135}
136impl core::ops::Deref for SEL8_R {
137 type Target = crate::FieldReader<bool, bool>;
138 #[inline(always)]
139 fn deref(&self) -> &Self::Target {
140 &self.0
141 }
142}
143#[doc = "Field `SEL8` writer - Selection of Main RC Oscillator Calibration Bits for 8 MHz"]
144pub struct SEL8_W<'a> {
145 w: &'a mut W,
146}
147impl<'a> SEL8_W<'a> {
148 #[doc = r"Sets the field bit"]
149 #[inline(always)]
150 pub fn set_bit(self) -> &'a mut W {
151 self.bit(true)
152 }
153 #[doc = r"Clears the field bit"]
154 #[inline(always)]
155 pub fn clear_bit(self) -> &'a mut W {
156 self.bit(false)
157 }
158 #[doc = r"Writes raw bits to the field"]
159 #[inline(always)]
160 pub fn bit(self, value: bool) -> &'a mut W {
161 self.w.bits = (self.w.bits & !(0x01 << 15)) | ((value as u32 & 0x01) << 15);
162 self.w
163 }
164}
165#[doc = "Field `CAL12` reader - Main RC Oscillator Calibration Bits for 12 MHz"]
166pub struct CAL12_R(crate::FieldReader<u8, u8>);
167impl CAL12_R {
168 #[inline(always)]
169 pub(crate) fn new(bits: u8) -> Self {
170 CAL12_R(crate::FieldReader::new(bits))
171 }
172}
173impl core::ops::Deref for CAL12_R {
174 type Target = crate::FieldReader<u8, u8>;
175 #[inline(always)]
176 fn deref(&self) -> &Self::Target {
177 &self.0
178 }
179}
180#[doc = "Field `CAL12` writer - Main RC Oscillator Calibration Bits for 12 MHz"]
181pub struct CAL12_W<'a> {
182 w: &'a mut W,
183}
184impl<'a> CAL12_W<'a> {
185 #[doc = r"Writes raw bits to the field"]
186 #[inline(always)]
187 pub unsafe fn bits(self, value: u8) -> &'a mut W {
188 self.w.bits = (self.w.bits & !(0x7f << 16)) | ((value as u32 & 0x7f) << 16);
189 self.w
190 }
191}
192#[doc = "Field `SEL12` reader - Selection of Main RC Oscillator Calibration Bits for 12 MHz"]
193pub struct SEL12_R(crate::FieldReader<bool, bool>);
194impl SEL12_R {
195 #[inline(always)]
196 pub(crate) fn new(bits: bool) -> Self {
197 SEL12_R(crate::FieldReader::new(bits))
198 }
199}
200impl core::ops::Deref for SEL12_R {
201 type Target = crate::FieldReader<bool, bool>;
202 #[inline(always)]
203 fn deref(&self) -> &Self::Target {
204 &self.0
205 }
206}
207#[doc = "Field `SEL12` writer - Selection of Main RC Oscillator Calibration Bits for 12 MHz"]
208pub struct SEL12_W<'a> {
209 w: &'a mut W,
210}
211impl<'a> SEL12_W<'a> {
212 #[doc = r"Sets the field bit"]
213 #[inline(always)]
214 pub fn set_bit(self) -> &'a mut W {
215 self.bit(true)
216 }
217 #[doc = r"Clears the field bit"]
218 #[inline(always)]
219 pub fn clear_bit(self) -> &'a mut W {
220 self.bit(false)
221 }
222 #[doc = r"Writes raw bits to the field"]
223 #[inline(always)]
224 pub fn bit(self, value: bool) -> &'a mut W {
225 self.w.bits = (self.w.bits & !(0x01 << 23)) | ((value as u32 & 0x01) << 23);
226 self.w
227 }
228}
229impl R {
230 #[doc = "Bits 0:6 - Main RC Oscillator Calibration Bits for 4 MHz"]
231 #[inline(always)]
232 pub fn cal4(&self) -> CAL4_R {
233 CAL4_R::new((self.bits & 0x7f) as u8)
234 }
235 #[doc = "Bit 7 - Selection of Main RC Oscillator Calibration Bits for 4 MHz"]
236 #[inline(always)]
237 pub fn sel4(&self) -> SEL4_R {
238 SEL4_R::new(((self.bits >> 7) & 0x01) != 0)
239 }
240 #[doc = "Bits 8:14 - Main RC Oscillator Calibration Bits for 8 MHz"]
241 #[inline(always)]
242 pub fn cal8(&self) -> CAL8_R {
243 CAL8_R::new(((self.bits >> 8) & 0x7f) as u8)
244 }
245 #[doc = "Bit 15 - Selection of Main RC Oscillator Calibration Bits for 8 MHz"]
246 #[inline(always)]
247 pub fn sel8(&self) -> SEL8_R {
248 SEL8_R::new(((self.bits >> 15) & 0x01) != 0)
249 }
250 #[doc = "Bits 16:22 - Main RC Oscillator Calibration Bits for 12 MHz"]
251 #[inline(always)]
252 pub fn cal12(&self) -> CAL12_R {
253 CAL12_R::new(((self.bits >> 16) & 0x7f) as u8)
254 }
255 #[doc = "Bit 23 - Selection of Main RC Oscillator Calibration Bits for 12 MHz"]
256 #[inline(always)]
257 pub fn sel12(&self) -> SEL12_R {
258 SEL12_R::new(((self.bits >> 23) & 0x01) != 0)
259 }
260}
261impl W {
262 #[doc = "Bits 0:6 - Main RC Oscillator Calibration Bits for 4 MHz"]
263 #[inline(always)]
264 pub fn cal4(&mut self) -> CAL4_W {
265 CAL4_W { w: self }
266 }
267 #[doc = "Bit 7 - Selection of Main RC Oscillator Calibration Bits for 4 MHz"]
268 #[inline(always)]
269 pub fn sel4(&mut self) -> SEL4_W {
270 SEL4_W { w: self }
271 }
272 #[doc = "Bits 8:14 - Main RC Oscillator Calibration Bits for 8 MHz"]
273 #[inline(always)]
274 pub fn cal8(&mut self) -> CAL8_W {
275 CAL8_W { w: self }
276 }
277 #[doc = "Bit 15 - Selection of Main RC Oscillator Calibration Bits for 8 MHz"]
278 #[inline(always)]
279 pub fn sel8(&mut self) -> SEL8_W {
280 SEL8_W { w: self }
281 }
282 #[doc = "Bits 16:22 - Main RC Oscillator Calibration Bits for 12 MHz"]
283 #[inline(always)]
284 pub fn cal12(&mut self) -> CAL12_W {
285 CAL12_W { w: self }
286 }
287 #[doc = "Bit 23 - Selection of Main RC Oscillator Calibration Bits for 12 MHz"]
288 #[inline(always)]
289 pub fn sel12(&mut self) -> SEL12_W {
290 SEL12_W { w: self }
291 }
292 #[doc = "Writes raw bits to the register."]
293 #[inline(always)]
294 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
295 self.0.bits(bits);
296 self
297 }
298}
299#[doc = "Oscillator Calibration 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 [pmc_ocr](index.html) module"]
300pub struct PMC_OCR_SPEC;
301impl crate::RegisterSpec for PMC_OCR_SPEC {
302 type Ux = u32;
303}
304#[doc = "`read()` method returns [pmc_ocr::R](R) reader structure"]
305impl crate::Readable for PMC_OCR_SPEC {
306 type Reader = R;
307}
308#[doc = "`write(|w| ..)` method takes [pmc_ocr::W](W) writer structure"]
309impl crate::Writable for PMC_OCR_SPEC {
310 type Writer = W;
311}
312#[doc = "`reset()` method sets PMC_OCR to value 0"]
313impl crate::Resettable for PMC_OCR_SPEC {
314 #[inline(always)]
315 fn reset_value() -> Self::Ux {
316 0
317 }
318}