1#[doc = "Register `XOSCCTRL[%s]` reader"]
2pub type R = crate::R<XoscctrlSpec>;
3#[doc = "Register `XOSCCTRL[%s]` writer"]
4pub type W = crate::W<XoscctrlSpec>;
5#[doc = "Field `ENABLE` reader - Oscillator Enable"]
6pub type EnableR = crate::BitReader;
7#[doc = "Field `ENABLE` writer - Oscillator Enable"]
8pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `XTALEN` reader - Crystal Oscillator Enable"]
10pub type XtalenR = crate::BitReader;
11#[doc = "Field `XTALEN` writer - Crystal Oscillator Enable"]
12pub type XtalenW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `RUNSTDBY` reader - Run in Standby"]
14pub type RunstdbyR = crate::BitReader;
15#[doc = "Field `RUNSTDBY` writer - Run in Standby"]
16pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `ONDEMAND` reader - On Demand Control"]
18pub type OndemandR = crate::BitReader;
19#[doc = "Field `ONDEMAND` writer - On Demand Control"]
20pub type OndemandW<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Field `LOWBUFGAIN` reader - Low Buffer Gain Enable"]
22pub type LowbufgainR = crate::BitReader;
23#[doc = "Field `LOWBUFGAIN` writer - Low Buffer Gain Enable"]
24pub type LowbufgainW<'a, REG> = crate::BitWriter<'a, REG>;
25#[doc = "Field `IPTAT` reader - Oscillator Current Reference"]
26pub type IptatR = crate::FieldReader;
27#[doc = "Field `IPTAT` writer - Oscillator Current Reference"]
28pub type IptatW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
29#[doc = "Field `IMULT` reader - Oscillator Current Multiplier"]
30pub type ImultR = crate::FieldReader;
31#[doc = "Field `IMULT` writer - Oscillator Current Multiplier"]
32pub type ImultW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
33#[doc = "Field `ENALC` reader - Automatic Loop Control Enable"]
34pub type EnalcR = crate::BitReader;
35#[doc = "Field `ENALC` writer - Automatic Loop Control Enable"]
36pub type EnalcW<'a, REG> = crate::BitWriter<'a, REG>;
37#[doc = "Field `CFDEN` reader - Clock Failure Detector Enable"]
38pub type CfdenR = crate::BitReader;
39#[doc = "Field `CFDEN` writer - Clock Failure Detector Enable"]
40pub type CfdenW<'a, REG> = crate::BitWriter<'a, REG>;
41#[doc = "Field `SWBEN` reader - Xosc Clock Switch Enable"]
42pub type SwbenR = crate::BitReader;
43#[doc = "Field `SWBEN` writer - Xosc Clock Switch Enable"]
44pub type SwbenW<'a, REG> = crate::BitWriter<'a, REG>;
45#[doc = "Start-Up Time\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47#[repr(u8)]
48pub enum Startupselect {
49 #[doc = "0: 31 us"]
50 Cycle1 = 0,
51 #[doc = "1: 61 us"]
52 Cycle2 = 1,
53 #[doc = "2: 122 us"]
54 Cycle4 = 2,
55 #[doc = "3: 244 us"]
56 Cycle8 = 3,
57 #[doc = "4: 488 us"]
58 Cycle16 = 4,
59 #[doc = "5: 977 us"]
60 Cycle32 = 5,
61 #[doc = "6: 1953 us"]
62 Cycle64 = 6,
63 #[doc = "7: 3906 us"]
64 Cycle128 = 7,
65 #[doc = "8: 7813 us"]
66 Cycle256 = 8,
67 #[doc = "9: 15625 us"]
68 Cycle512 = 9,
69 #[doc = "10: 31250 us"]
70 Cycle1024 = 10,
71 #[doc = "11: 62500 us"]
72 Cycle2048 = 11,
73 #[doc = "12: 125000 us"]
74 Cycle4096 = 12,
75 #[doc = "13: 250000 us"]
76 Cycle8192 = 13,
77 #[doc = "14: 500000 us"]
78 Cycle16384 = 14,
79 #[doc = "15: 1000000 us"]
80 Cycle32768 = 15,
81}
82impl From<Startupselect> for u8 {
83 #[inline(always)]
84 fn from(variant: Startupselect) -> Self {
85 variant as _
86 }
87}
88impl crate::FieldSpec for Startupselect {
89 type Ux = u8;
90}
91impl crate::IsEnum for Startupselect {}
92#[doc = "Field `STARTUP` reader - Start-Up Time"]
93pub type StartupR = crate::FieldReader<Startupselect>;
94impl StartupR {
95 #[doc = "Get enumerated values variant"]
96 #[inline(always)]
97 pub const fn variant(&self) -> Startupselect {
98 match self.bits {
99 0 => Startupselect::Cycle1,
100 1 => Startupselect::Cycle2,
101 2 => Startupselect::Cycle4,
102 3 => Startupselect::Cycle8,
103 4 => Startupselect::Cycle16,
104 5 => Startupselect::Cycle32,
105 6 => Startupselect::Cycle64,
106 7 => Startupselect::Cycle128,
107 8 => Startupselect::Cycle256,
108 9 => Startupselect::Cycle512,
109 10 => Startupselect::Cycle1024,
110 11 => Startupselect::Cycle2048,
111 12 => Startupselect::Cycle4096,
112 13 => Startupselect::Cycle8192,
113 14 => Startupselect::Cycle16384,
114 15 => Startupselect::Cycle32768,
115 _ => unreachable!(),
116 }
117 }
118 #[doc = "31 us"]
119 #[inline(always)]
120 pub fn is_cycle1(&self) -> bool {
121 *self == Startupselect::Cycle1
122 }
123 #[doc = "61 us"]
124 #[inline(always)]
125 pub fn is_cycle2(&self) -> bool {
126 *self == Startupselect::Cycle2
127 }
128 #[doc = "122 us"]
129 #[inline(always)]
130 pub fn is_cycle4(&self) -> bool {
131 *self == Startupselect::Cycle4
132 }
133 #[doc = "244 us"]
134 #[inline(always)]
135 pub fn is_cycle8(&self) -> bool {
136 *self == Startupselect::Cycle8
137 }
138 #[doc = "488 us"]
139 #[inline(always)]
140 pub fn is_cycle16(&self) -> bool {
141 *self == Startupselect::Cycle16
142 }
143 #[doc = "977 us"]
144 #[inline(always)]
145 pub fn is_cycle32(&self) -> bool {
146 *self == Startupselect::Cycle32
147 }
148 #[doc = "1953 us"]
149 #[inline(always)]
150 pub fn is_cycle64(&self) -> bool {
151 *self == Startupselect::Cycle64
152 }
153 #[doc = "3906 us"]
154 #[inline(always)]
155 pub fn is_cycle128(&self) -> bool {
156 *self == Startupselect::Cycle128
157 }
158 #[doc = "7813 us"]
159 #[inline(always)]
160 pub fn is_cycle256(&self) -> bool {
161 *self == Startupselect::Cycle256
162 }
163 #[doc = "15625 us"]
164 #[inline(always)]
165 pub fn is_cycle512(&self) -> bool {
166 *self == Startupselect::Cycle512
167 }
168 #[doc = "31250 us"]
169 #[inline(always)]
170 pub fn is_cycle1024(&self) -> bool {
171 *self == Startupselect::Cycle1024
172 }
173 #[doc = "62500 us"]
174 #[inline(always)]
175 pub fn is_cycle2048(&self) -> bool {
176 *self == Startupselect::Cycle2048
177 }
178 #[doc = "125000 us"]
179 #[inline(always)]
180 pub fn is_cycle4096(&self) -> bool {
181 *self == Startupselect::Cycle4096
182 }
183 #[doc = "250000 us"]
184 #[inline(always)]
185 pub fn is_cycle8192(&self) -> bool {
186 *self == Startupselect::Cycle8192
187 }
188 #[doc = "500000 us"]
189 #[inline(always)]
190 pub fn is_cycle16384(&self) -> bool {
191 *self == Startupselect::Cycle16384
192 }
193 #[doc = "1000000 us"]
194 #[inline(always)]
195 pub fn is_cycle32768(&self) -> bool {
196 *self == Startupselect::Cycle32768
197 }
198}
199#[doc = "Field `STARTUP` writer - Start-Up Time"]
200pub type StartupW<'a, REG> = crate::FieldWriter<'a, REG, 4, Startupselect, crate::Safe>;
201impl<'a, REG> StartupW<'a, REG>
202where
203 REG: crate::Writable + crate::RegisterSpec,
204 REG::Ux: From<u8>,
205{
206 #[doc = "31 us"]
207 #[inline(always)]
208 pub fn cycle1(self) -> &'a mut crate::W<REG> {
209 self.variant(Startupselect::Cycle1)
210 }
211 #[doc = "61 us"]
212 #[inline(always)]
213 pub fn cycle2(self) -> &'a mut crate::W<REG> {
214 self.variant(Startupselect::Cycle2)
215 }
216 #[doc = "122 us"]
217 #[inline(always)]
218 pub fn cycle4(self) -> &'a mut crate::W<REG> {
219 self.variant(Startupselect::Cycle4)
220 }
221 #[doc = "244 us"]
222 #[inline(always)]
223 pub fn cycle8(self) -> &'a mut crate::W<REG> {
224 self.variant(Startupselect::Cycle8)
225 }
226 #[doc = "488 us"]
227 #[inline(always)]
228 pub fn cycle16(self) -> &'a mut crate::W<REG> {
229 self.variant(Startupselect::Cycle16)
230 }
231 #[doc = "977 us"]
232 #[inline(always)]
233 pub fn cycle32(self) -> &'a mut crate::W<REG> {
234 self.variant(Startupselect::Cycle32)
235 }
236 #[doc = "1953 us"]
237 #[inline(always)]
238 pub fn cycle64(self) -> &'a mut crate::W<REG> {
239 self.variant(Startupselect::Cycle64)
240 }
241 #[doc = "3906 us"]
242 #[inline(always)]
243 pub fn cycle128(self) -> &'a mut crate::W<REG> {
244 self.variant(Startupselect::Cycle128)
245 }
246 #[doc = "7813 us"]
247 #[inline(always)]
248 pub fn cycle256(self) -> &'a mut crate::W<REG> {
249 self.variant(Startupselect::Cycle256)
250 }
251 #[doc = "15625 us"]
252 #[inline(always)]
253 pub fn cycle512(self) -> &'a mut crate::W<REG> {
254 self.variant(Startupselect::Cycle512)
255 }
256 #[doc = "31250 us"]
257 #[inline(always)]
258 pub fn cycle1024(self) -> &'a mut crate::W<REG> {
259 self.variant(Startupselect::Cycle1024)
260 }
261 #[doc = "62500 us"]
262 #[inline(always)]
263 pub fn cycle2048(self) -> &'a mut crate::W<REG> {
264 self.variant(Startupselect::Cycle2048)
265 }
266 #[doc = "125000 us"]
267 #[inline(always)]
268 pub fn cycle4096(self) -> &'a mut crate::W<REG> {
269 self.variant(Startupselect::Cycle4096)
270 }
271 #[doc = "250000 us"]
272 #[inline(always)]
273 pub fn cycle8192(self) -> &'a mut crate::W<REG> {
274 self.variant(Startupselect::Cycle8192)
275 }
276 #[doc = "500000 us"]
277 #[inline(always)]
278 pub fn cycle16384(self) -> &'a mut crate::W<REG> {
279 self.variant(Startupselect::Cycle16384)
280 }
281 #[doc = "1000000 us"]
282 #[inline(always)]
283 pub fn cycle32768(self) -> &'a mut crate::W<REG> {
284 self.variant(Startupselect::Cycle32768)
285 }
286}
287#[doc = "Clock Failure Detector Prescaler\n\nValue on reset: 0"]
288#[derive(Clone, Copy, Debug, PartialEq, Eq)]
289#[repr(u8)]
290pub enum Cfdprescselect {
291 #[doc = "0: 48 MHz"]
292 Div1 = 0,
293 #[doc = "1: 24 MHz"]
294 Div2 = 1,
295 #[doc = "2: 12 MHz"]
296 Div4 = 2,
297 #[doc = "3: 6 MHz"]
298 Div8 = 3,
299 #[doc = "4: 3 MHz"]
300 Div16 = 4,
301 #[doc = "5: 1.5 MHz"]
302 Div32 = 5,
303 #[doc = "6: 0.75 MHz"]
304 Div64 = 6,
305 #[doc = "7: 0.3125 MHz"]
306 Div128 = 7,
307}
308impl From<Cfdprescselect> for u8 {
309 #[inline(always)]
310 fn from(variant: Cfdprescselect) -> Self {
311 variant as _
312 }
313}
314impl crate::FieldSpec for Cfdprescselect {
315 type Ux = u8;
316}
317impl crate::IsEnum for Cfdprescselect {}
318#[doc = "Field `CFDPRESC` reader - Clock Failure Detector Prescaler"]
319pub type CfdprescR = crate::FieldReader<Cfdprescselect>;
320impl CfdprescR {
321 #[doc = "Get enumerated values variant"]
322 #[inline(always)]
323 pub const fn variant(&self) -> Option<Cfdprescselect> {
324 match self.bits {
325 0 => Some(Cfdprescselect::Div1),
326 1 => Some(Cfdprescselect::Div2),
327 2 => Some(Cfdprescselect::Div4),
328 3 => Some(Cfdprescselect::Div8),
329 4 => Some(Cfdprescselect::Div16),
330 5 => Some(Cfdprescselect::Div32),
331 6 => Some(Cfdprescselect::Div64),
332 7 => Some(Cfdprescselect::Div128),
333 _ => None,
334 }
335 }
336 #[doc = "48 MHz"]
337 #[inline(always)]
338 pub fn is_div1(&self) -> bool {
339 *self == Cfdprescselect::Div1
340 }
341 #[doc = "24 MHz"]
342 #[inline(always)]
343 pub fn is_div2(&self) -> bool {
344 *self == Cfdprescselect::Div2
345 }
346 #[doc = "12 MHz"]
347 #[inline(always)]
348 pub fn is_div4(&self) -> bool {
349 *self == Cfdprescselect::Div4
350 }
351 #[doc = "6 MHz"]
352 #[inline(always)]
353 pub fn is_div8(&self) -> bool {
354 *self == Cfdprescselect::Div8
355 }
356 #[doc = "3 MHz"]
357 #[inline(always)]
358 pub fn is_div16(&self) -> bool {
359 *self == Cfdprescselect::Div16
360 }
361 #[doc = "1.5 MHz"]
362 #[inline(always)]
363 pub fn is_div32(&self) -> bool {
364 *self == Cfdprescselect::Div32
365 }
366 #[doc = "0.75 MHz"]
367 #[inline(always)]
368 pub fn is_div64(&self) -> bool {
369 *self == Cfdprescselect::Div64
370 }
371 #[doc = "0.3125 MHz"]
372 #[inline(always)]
373 pub fn is_div128(&self) -> bool {
374 *self == Cfdprescselect::Div128
375 }
376}
377#[doc = "Field `CFDPRESC` writer - Clock Failure Detector Prescaler"]
378pub type CfdprescW<'a, REG> = crate::FieldWriter<'a, REG, 4, Cfdprescselect>;
379impl<'a, REG> CfdprescW<'a, REG>
380where
381 REG: crate::Writable + crate::RegisterSpec,
382 REG::Ux: From<u8>,
383{
384 #[doc = "48 MHz"]
385 #[inline(always)]
386 pub fn div1(self) -> &'a mut crate::W<REG> {
387 self.variant(Cfdprescselect::Div1)
388 }
389 #[doc = "24 MHz"]
390 #[inline(always)]
391 pub fn div2(self) -> &'a mut crate::W<REG> {
392 self.variant(Cfdprescselect::Div2)
393 }
394 #[doc = "12 MHz"]
395 #[inline(always)]
396 pub fn div4(self) -> &'a mut crate::W<REG> {
397 self.variant(Cfdprescselect::Div4)
398 }
399 #[doc = "6 MHz"]
400 #[inline(always)]
401 pub fn div8(self) -> &'a mut crate::W<REG> {
402 self.variant(Cfdprescselect::Div8)
403 }
404 #[doc = "3 MHz"]
405 #[inline(always)]
406 pub fn div16(self) -> &'a mut crate::W<REG> {
407 self.variant(Cfdprescselect::Div16)
408 }
409 #[doc = "1.5 MHz"]
410 #[inline(always)]
411 pub fn div32(self) -> &'a mut crate::W<REG> {
412 self.variant(Cfdprescselect::Div32)
413 }
414 #[doc = "0.75 MHz"]
415 #[inline(always)]
416 pub fn div64(self) -> &'a mut crate::W<REG> {
417 self.variant(Cfdprescselect::Div64)
418 }
419 #[doc = "0.3125 MHz"]
420 #[inline(always)]
421 pub fn div128(self) -> &'a mut crate::W<REG> {
422 self.variant(Cfdprescselect::Div128)
423 }
424}
425impl R {
426 #[doc = "Bit 1 - Oscillator Enable"]
427 #[inline(always)]
428 pub fn enable(&self) -> EnableR {
429 EnableR::new(((self.bits >> 1) & 1) != 0)
430 }
431 #[doc = "Bit 2 - Crystal Oscillator Enable"]
432 #[inline(always)]
433 pub fn xtalen(&self) -> XtalenR {
434 XtalenR::new(((self.bits >> 2) & 1) != 0)
435 }
436 #[doc = "Bit 6 - Run in Standby"]
437 #[inline(always)]
438 pub fn runstdby(&self) -> RunstdbyR {
439 RunstdbyR::new(((self.bits >> 6) & 1) != 0)
440 }
441 #[doc = "Bit 7 - On Demand Control"]
442 #[inline(always)]
443 pub fn ondemand(&self) -> OndemandR {
444 OndemandR::new(((self.bits >> 7) & 1) != 0)
445 }
446 #[doc = "Bit 8 - Low Buffer Gain Enable"]
447 #[inline(always)]
448 pub fn lowbufgain(&self) -> LowbufgainR {
449 LowbufgainR::new(((self.bits >> 8) & 1) != 0)
450 }
451 #[doc = "Bits 9:10 - Oscillator Current Reference"]
452 #[inline(always)]
453 pub fn iptat(&self) -> IptatR {
454 IptatR::new(((self.bits >> 9) & 3) as u8)
455 }
456 #[doc = "Bits 11:14 - Oscillator Current Multiplier"]
457 #[inline(always)]
458 pub fn imult(&self) -> ImultR {
459 ImultR::new(((self.bits >> 11) & 0x0f) as u8)
460 }
461 #[doc = "Bit 15 - Automatic Loop Control Enable"]
462 #[inline(always)]
463 pub fn enalc(&self) -> EnalcR {
464 EnalcR::new(((self.bits >> 15) & 1) != 0)
465 }
466 #[doc = "Bit 16 - Clock Failure Detector Enable"]
467 #[inline(always)]
468 pub fn cfden(&self) -> CfdenR {
469 CfdenR::new(((self.bits >> 16) & 1) != 0)
470 }
471 #[doc = "Bit 17 - Xosc Clock Switch Enable"]
472 #[inline(always)]
473 pub fn swben(&self) -> SwbenR {
474 SwbenR::new(((self.bits >> 17) & 1) != 0)
475 }
476 #[doc = "Bits 20:23 - Start-Up Time"]
477 #[inline(always)]
478 pub fn startup(&self) -> StartupR {
479 StartupR::new(((self.bits >> 20) & 0x0f) as u8)
480 }
481 #[doc = "Bits 24:27 - Clock Failure Detector Prescaler"]
482 #[inline(always)]
483 pub fn cfdpresc(&self) -> CfdprescR {
484 CfdprescR::new(((self.bits >> 24) & 0x0f) as u8)
485 }
486}
487impl W {
488 #[doc = "Bit 1 - Oscillator Enable"]
489 #[inline(always)]
490 #[must_use]
491 pub fn enable(&mut self) -> EnableW<XoscctrlSpec> {
492 EnableW::new(self, 1)
493 }
494 #[doc = "Bit 2 - Crystal Oscillator Enable"]
495 #[inline(always)]
496 #[must_use]
497 pub fn xtalen(&mut self) -> XtalenW<XoscctrlSpec> {
498 XtalenW::new(self, 2)
499 }
500 #[doc = "Bit 6 - Run in Standby"]
501 #[inline(always)]
502 #[must_use]
503 pub fn runstdby(&mut self) -> RunstdbyW<XoscctrlSpec> {
504 RunstdbyW::new(self, 6)
505 }
506 #[doc = "Bit 7 - On Demand Control"]
507 #[inline(always)]
508 #[must_use]
509 pub fn ondemand(&mut self) -> OndemandW<XoscctrlSpec> {
510 OndemandW::new(self, 7)
511 }
512 #[doc = "Bit 8 - Low Buffer Gain Enable"]
513 #[inline(always)]
514 #[must_use]
515 pub fn lowbufgain(&mut self) -> LowbufgainW<XoscctrlSpec> {
516 LowbufgainW::new(self, 8)
517 }
518 #[doc = "Bits 9:10 - Oscillator Current Reference"]
519 #[inline(always)]
520 #[must_use]
521 pub fn iptat(&mut self) -> IptatW<XoscctrlSpec> {
522 IptatW::new(self, 9)
523 }
524 #[doc = "Bits 11:14 - Oscillator Current Multiplier"]
525 #[inline(always)]
526 #[must_use]
527 pub fn imult(&mut self) -> ImultW<XoscctrlSpec> {
528 ImultW::new(self, 11)
529 }
530 #[doc = "Bit 15 - Automatic Loop Control Enable"]
531 #[inline(always)]
532 #[must_use]
533 pub fn enalc(&mut self) -> EnalcW<XoscctrlSpec> {
534 EnalcW::new(self, 15)
535 }
536 #[doc = "Bit 16 - Clock Failure Detector Enable"]
537 #[inline(always)]
538 #[must_use]
539 pub fn cfden(&mut self) -> CfdenW<XoscctrlSpec> {
540 CfdenW::new(self, 16)
541 }
542 #[doc = "Bit 17 - Xosc Clock Switch Enable"]
543 #[inline(always)]
544 #[must_use]
545 pub fn swben(&mut self) -> SwbenW<XoscctrlSpec> {
546 SwbenW::new(self, 17)
547 }
548 #[doc = "Bits 20:23 - Start-Up Time"]
549 #[inline(always)]
550 #[must_use]
551 pub fn startup(&mut self) -> StartupW<XoscctrlSpec> {
552 StartupW::new(self, 20)
553 }
554 #[doc = "Bits 24:27 - Clock Failure Detector Prescaler"]
555 #[inline(always)]
556 #[must_use]
557 pub fn cfdpresc(&mut self) -> CfdprescW<XoscctrlSpec> {
558 CfdprescW::new(self, 24)
559 }
560}
561#[doc = "External Multipurpose Crystal Oscillator Control\n\nYou can [`read`](crate::Reg::read) this register and get [`xoscctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`xoscctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
562pub struct XoscctrlSpec;
563impl crate::RegisterSpec for XoscctrlSpec {
564 type Ux = u32;
565}
566#[doc = "`read()` method returns [`xoscctrl::R`](R) reader structure"]
567impl crate::Readable for XoscctrlSpec {}
568#[doc = "`write(|w| ..)` method takes [`xoscctrl::W`](W) writer structure"]
569impl crate::Writable for XoscctrlSpec {
570 type Safety = crate::Unsafe;
571 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
572 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
573}
574#[doc = "`reset()` method sets XOSCCTRL[%s]
575to value 0x80"]
576impl crate::Resettable for XoscctrlSpec {
577 const RESET_VALUE: u32 = 0x80;
578}