atsame70j21/supc/
supc_mr.rs1#[doc = "Register `SUPC_MR` reader"]
2pub struct R(crate::R<SUPC_MR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<SUPC_MR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<SUPC_MR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<SUPC_MR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `SUPC_MR` writer"]
17pub struct W(crate::W<SUPC_MR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<SUPC_MR_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<SUPC_MR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<SUPC_MR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Brownout Detector Reset Enable\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum BODRSTEN_A {
40 #[doc = "0: The core reset signal vddcore_nreset is not affected when a brownout detection occurs."]
41 NOT_ENABLE = 0,
42 #[doc = "1: The core reset signal, vddcore_nreset is asserted when a brownout detection occurs."]
43 ENABLE = 1,
44}
45impl From<BODRSTEN_A> for bool {
46 #[inline(always)]
47 fn from(variant: BODRSTEN_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `BODRSTEN` reader - Brownout Detector Reset Enable"]
52pub struct BODRSTEN_R(crate::FieldReader<bool, BODRSTEN_A>);
53impl BODRSTEN_R {
54 #[inline(always)]
55 pub(crate) fn new(bits: bool) -> Self {
56 BODRSTEN_R(crate::FieldReader::new(bits))
57 }
58 #[doc = r"Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> BODRSTEN_A {
61 match self.bits {
62 false => BODRSTEN_A::NOT_ENABLE,
63 true => BODRSTEN_A::ENABLE,
64 }
65 }
66 #[doc = "Checks if the value of the field is `NOT_ENABLE`"]
67 #[inline(always)]
68 pub fn is_not_enable(&self) -> bool {
69 **self == BODRSTEN_A::NOT_ENABLE
70 }
71 #[doc = "Checks if the value of the field is `ENABLE`"]
72 #[inline(always)]
73 pub fn is_enable(&self) -> bool {
74 **self == BODRSTEN_A::ENABLE
75 }
76}
77impl core::ops::Deref for BODRSTEN_R {
78 type Target = crate::FieldReader<bool, BODRSTEN_A>;
79 #[inline(always)]
80 fn deref(&self) -> &Self::Target {
81 &self.0
82 }
83}
84#[doc = "Field `BODRSTEN` writer - Brownout Detector Reset Enable"]
85pub struct BODRSTEN_W<'a> {
86 w: &'a mut W,
87}
88impl<'a> BODRSTEN_W<'a> {
89 #[doc = r"Writes `variant` to the field"]
90 #[inline(always)]
91 pub fn variant(self, variant: BODRSTEN_A) -> &'a mut W {
92 self.bit(variant.into())
93 }
94 #[doc = "The core reset signal vddcore_nreset is not affected when a brownout detection occurs."]
95 #[inline(always)]
96 pub fn not_enable(self) -> &'a mut W {
97 self.variant(BODRSTEN_A::NOT_ENABLE)
98 }
99 #[doc = "The core reset signal, vddcore_nreset is asserted when a brownout detection occurs."]
100 #[inline(always)]
101 pub fn enable(self) -> &'a mut W {
102 self.variant(BODRSTEN_A::ENABLE)
103 }
104 #[doc = r"Sets the field bit"]
105 #[inline(always)]
106 pub fn set_bit(self) -> &'a mut W {
107 self.bit(true)
108 }
109 #[doc = r"Clears the field bit"]
110 #[inline(always)]
111 pub fn clear_bit(self) -> &'a mut W {
112 self.bit(false)
113 }
114 #[doc = r"Writes raw bits to the field"]
115 #[inline(always)]
116 pub fn bit(self, value: bool) -> &'a mut W {
117 self.w.bits = (self.w.bits & !(0x01 << 12)) | ((value as u32 & 0x01) << 12);
118 self.w
119 }
120}
121#[doc = "Brownout Detector Disable\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum BODDIS_A {
124 #[doc = "0: The core brownout detector is enabled."]
125 ENABLE = 0,
126 #[doc = "1: The core brownout detector is disabled."]
127 DISABLE = 1,
128}
129impl From<BODDIS_A> for bool {
130 #[inline(always)]
131 fn from(variant: BODDIS_A) -> Self {
132 variant as u8 != 0
133 }
134}
135#[doc = "Field `BODDIS` reader - Brownout Detector Disable"]
136pub struct BODDIS_R(crate::FieldReader<bool, BODDIS_A>);
137impl BODDIS_R {
138 #[inline(always)]
139 pub(crate) fn new(bits: bool) -> Self {
140 BODDIS_R(crate::FieldReader::new(bits))
141 }
142 #[doc = r"Get enumerated values variant"]
143 #[inline(always)]
144 pub fn variant(&self) -> BODDIS_A {
145 match self.bits {
146 false => BODDIS_A::ENABLE,
147 true => BODDIS_A::DISABLE,
148 }
149 }
150 #[doc = "Checks if the value of the field is `ENABLE`"]
151 #[inline(always)]
152 pub fn is_enable(&self) -> bool {
153 **self == BODDIS_A::ENABLE
154 }
155 #[doc = "Checks if the value of the field is `DISABLE`"]
156 #[inline(always)]
157 pub fn is_disable(&self) -> bool {
158 **self == BODDIS_A::DISABLE
159 }
160}
161impl core::ops::Deref for BODDIS_R {
162 type Target = crate::FieldReader<bool, BODDIS_A>;
163 #[inline(always)]
164 fn deref(&self) -> &Self::Target {
165 &self.0
166 }
167}
168#[doc = "Field `BODDIS` writer - Brownout Detector Disable"]
169pub struct BODDIS_W<'a> {
170 w: &'a mut W,
171}
172impl<'a> BODDIS_W<'a> {
173 #[doc = r"Writes `variant` to the field"]
174 #[inline(always)]
175 pub fn variant(self, variant: BODDIS_A) -> &'a mut W {
176 self.bit(variant.into())
177 }
178 #[doc = "The core brownout detector is enabled."]
179 #[inline(always)]
180 pub fn enable(self) -> &'a mut W {
181 self.variant(BODDIS_A::ENABLE)
182 }
183 #[doc = "The core brownout detector is disabled."]
184 #[inline(always)]
185 pub fn disable(self) -> &'a mut W {
186 self.variant(BODDIS_A::DISABLE)
187 }
188 #[doc = r"Sets the field bit"]
189 #[inline(always)]
190 pub fn set_bit(self) -> &'a mut W {
191 self.bit(true)
192 }
193 #[doc = r"Clears the field bit"]
194 #[inline(always)]
195 pub fn clear_bit(self) -> &'a mut W {
196 self.bit(false)
197 }
198 #[doc = r"Writes raw bits to the field"]
199 #[inline(always)]
200 pub fn bit(self, value: bool) -> &'a mut W {
201 self.w.bits = (self.w.bits & !(0x01 << 13)) | ((value as u32 & 0x01) << 13);
202 self.w
203 }
204}
205#[doc = "Voltage Regulator Enable\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207pub enum ONREG_A {
208 #[doc = "0: Internal voltage regulator is not used (external power supply is used)."]
209 ONREG_UNUSED = 0,
210 #[doc = "1: Internal voltage regulator is used."]
211 ONREG_USED = 1,
212}
213impl From<ONREG_A> for bool {
214 #[inline(always)]
215 fn from(variant: ONREG_A) -> Self {
216 variant as u8 != 0
217 }
218}
219#[doc = "Field `ONREG` reader - Voltage Regulator Enable"]
220pub struct ONREG_R(crate::FieldReader<bool, ONREG_A>);
221impl ONREG_R {
222 #[inline(always)]
223 pub(crate) fn new(bits: bool) -> Self {
224 ONREG_R(crate::FieldReader::new(bits))
225 }
226 #[doc = r"Get enumerated values variant"]
227 #[inline(always)]
228 pub fn variant(&self) -> ONREG_A {
229 match self.bits {
230 false => ONREG_A::ONREG_UNUSED,
231 true => ONREG_A::ONREG_USED,
232 }
233 }
234 #[doc = "Checks if the value of the field is `ONREG_UNUSED`"]
235 #[inline(always)]
236 pub fn is_onreg_unused(&self) -> bool {
237 **self == ONREG_A::ONREG_UNUSED
238 }
239 #[doc = "Checks if the value of the field is `ONREG_USED`"]
240 #[inline(always)]
241 pub fn is_onreg_used(&self) -> bool {
242 **self == ONREG_A::ONREG_USED
243 }
244}
245impl core::ops::Deref for ONREG_R {
246 type Target = crate::FieldReader<bool, ONREG_A>;
247 #[inline(always)]
248 fn deref(&self) -> &Self::Target {
249 &self.0
250 }
251}
252#[doc = "Field `ONREG` writer - Voltage Regulator Enable"]
253pub struct ONREG_W<'a> {
254 w: &'a mut W,
255}
256impl<'a> ONREG_W<'a> {
257 #[doc = r"Writes `variant` to the field"]
258 #[inline(always)]
259 pub fn variant(self, variant: ONREG_A) -> &'a mut W {
260 self.bit(variant.into())
261 }
262 #[doc = "Internal voltage regulator is not used (external power supply is used)."]
263 #[inline(always)]
264 pub fn onreg_unused(self) -> &'a mut W {
265 self.variant(ONREG_A::ONREG_UNUSED)
266 }
267 #[doc = "Internal voltage regulator is used."]
268 #[inline(always)]
269 pub fn onreg_used(self) -> &'a mut W {
270 self.variant(ONREG_A::ONREG_USED)
271 }
272 #[doc = r"Sets the field bit"]
273 #[inline(always)]
274 pub fn set_bit(self) -> &'a mut W {
275 self.bit(true)
276 }
277 #[doc = r"Clears the field bit"]
278 #[inline(always)]
279 pub fn clear_bit(self) -> &'a mut W {
280 self.bit(false)
281 }
282 #[doc = r"Writes raw bits to the field"]
283 #[inline(always)]
284 pub fn bit(self, value: bool) -> &'a mut W {
285 self.w.bits = (self.w.bits & !(0x01 << 14)) | ((value as u32 & 0x01) << 14);
286 self.w
287 }
288}
289#[doc = "Field `BKUPRETON` reader - SRAM On In Backup Mode"]
290pub struct BKUPRETON_R(crate::FieldReader<bool, bool>);
291impl BKUPRETON_R {
292 #[inline(always)]
293 pub(crate) fn new(bits: bool) -> Self {
294 BKUPRETON_R(crate::FieldReader::new(bits))
295 }
296}
297impl core::ops::Deref for BKUPRETON_R {
298 type Target = crate::FieldReader<bool, bool>;
299 #[inline(always)]
300 fn deref(&self) -> &Self::Target {
301 &self.0
302 }
303}
304#[doc = "Field `BKUPRETON` writer - SRAM On In Backup Mode"]
305pub struct BKUPRETON_W<'a> {
306 w: &'a mut W,
307}
308impl<'a> BKUPRETON_W<'a> {
309 #[doc = r"Sets the field bit"]
310 #[inline(always)]
311 pub fn set_bit(self) -> &'a mut W {
312 self.bit(true)
313 }
314 #[doc = r"Clears the field bit"]
315 #[inline(always)]
316 pub fn clear_bit(self) -> &'a mut W {
317 self.bit(false)
318 }
319 #[doc = r"Writes raw bits to the field"]
320 #[inline(always)]
321 pub fn bit(self, value: bool) -> &'a mut W {
322 self.w.bits = (self.w.bits & !(0x01 << 17)) | ((value as u32 & 0x01) << 17);
323 self.w
324 }
325}
326#[doc = "Oscillator Bypass\n\nValue on reset: 0"]
327#[derive(Clone, Copy, Debug, PartialEq)]
328pub enum OSCBYPASS_A {
329 #[doc = "0: No effect. Clock selection depends on the value of XTALSEL (SUPC_CR)."]
330 NO_EFFECT = 0,
331 #[doc = "1: The 32 kHz crystal oscillator is bypassed if XTALSEL (SUPC_CR) is set. OSCBYPASS must be set prior to setting XTALSEL."]
332 BYPASS = 1,
333}
334impl From<OSCBYPASS_A> for bool {
335 #[inline(always)]
336 fn from(variant: OSCBYPASS_A) -> Self {
337 variant as u8 != 0
338 }
339}
340#[doc = "Field `OSCBYPASS` reader - Oscillator Bypass"]
341pub struct OSCBYPASS_R(crate::FieldReader<bool, OSCBYPASS_A>);
342impl OSCBYPASS_R {
343 #[inline(always)]
344 pub(crate) fn new(bits: bool) -> Self {
345 OSCBYPASS_R(crate::FieldReader::new(bits))
346 }
347 #[doc = r"Get enumerated values variant"]
348 #[inline(always)]
349 pub fn variant(&self) -> OSCBYPASS_A {
350 match self.bits {
351 false => OSCBYPASS_A::NO_EFFECT,
352 true => OSCBYPASS_A::BYPASS,
353 }
354 }
355 #[doc = "Checks if the value of the field is `NO_EFFECT`"]
356 #[inline(always)]
357 pub fn is_no_effect(&self) -> bool {
358 **self == OSCBYPASS_A::NO_EFFECT
359 }
360 #[doc = "Checks if the value of the field is `BYPASS`"]
361 #[inline(always)]
362 pub fn is_bypass(&self) -> bool {
363 **self == OSCBYPASS_A::BYPASS
364 }
365}
366impl core::ops::Deref for OSCBYPASS_R {
367 type Target = crate::FieldReader<bool, OSCBYPASS_A>;
368 #[inline(always)]
369 fn deref(&self) -> &Self::Target {
370 &self.0
371 }
372}
373#[doc = "Field `OSCBYPASS` writer - Oscillator Bypass"]
374pub struct OSCBYPASS_W<'a> {
375 w: &'a mut W,
376}
377impl<'a> OSCBYPASS_W<'a> {
378 #[doc = r"Writes `variant` to the field"]
379 #[inline(always)]
380 pub fn variant(self, variant: OSCBYPASS_A) -> &'a mut W {
381 self.bit(variant.into())
382 }
383 #[doc = "No effect. Clock selection depends on the value of XTALSEL (SUPC_CR)."]
384 #[inline(always)]
385 pub fn no_effect(self) -> &'a mut W {
386 self.variant(OSCBYPASS_A::NO_EFFECT)
387 }
388 #[doc = "The 32 kHz crystal oscillator is bypassed if XTALSEL (SUPC_CR) is set. OSCBYPASS must be set prior to setting XTALSEL."]
389 #[inline(always)]
390 pub fn bypass(self) -> &'a mut W {
391 self.variant(OSCBYPASS_A::BYPASS)
392 }
393 #[doc = r"Sets the field bit"]
394 #[inline(always)]
395 pub fn set_bit(self) -> &'a mut W {
396 self.bit(true)
397 }
398 #[doc = r"Clears the field bit"]
399 #[inline(always)]
400 pub fn clear_bit(self) -> &'a mut W {
401 self.bit(false)
402 }
403 #[doc = r"Writes raw bits to the field"]
404 #[inline(always)]
405 pub fn bit(self, value: bool) -> &'a mut W {
406 self.w.bits = (self.w.bits & !(0x01 << 20)) | ((value as u32 & 0x01) << 20);
407 self.w
408 }
409}
410#[doc = "Password Key\n\nValue on reset: 0"]
411#[derive(Clone, Copy, Debug, PartialEq)]
412#[repr(u8)]
413pub enum KEY_A {
414 #[doc = "165: Writing any other value in this field aborts the write operation."]
415 PASSWD = 165,
416}
417impl From<KEY_A> for u8 {
418 #[inline(always)]
419 fn from(variant: KEY_A) -> Self {
420 variant as _
421 }
422}
423#[doc = "Field `KEY` reader - Password Key"]
424pub struct KEY_R(crate::FieldReader<u8, KEY_A>);
425impl KEY_R {
426 #[inline(always)]
427 pub(crate) fn new(bits: u8) -> Self {
428 KEY_R(crate::FieldReader::new(bits))
429 }
430 #[doc = r"Get enumerated values variant"]
431 #[inline(always)]
432 pub fn variant(&self) -> Option<KEY_A> {
433 match self.bits {
434 165 => Some(KEY_A::PASSWD),
435 _ => None,
436 }
437 }
438 #[doc = "Checks if the value of the field is `PASSWD`"]
439 #[inline(always)]
440 pub fn is_passwd(&self) -> bool {
441 **self == KEY_A::PASSWD
442 }
443}
444impl core::ops::Deref for KEY_R {
445 type Target = crate::FieldReader<u8, KEY_A>;
446 #[inline(always)]
447 fn deref(&self) -> &Self::Target {
448 &self.0
449 }
450}
451#[doc = "Field `KEY` writer - Password Key"]
452pub struct KEY_W<'a> {
453 w: &'a mut W,
454}
455impl<'a> KEY_W<'a> {
456 #[doc = r"Writes `variant` to the field"]
457 #[inline(always)]
458 pub fn variant(self, variant: KEY_A) -> &'a mut W {
459 unsafe { self.bits(variant.into()) }
460 }
461 #[doc = "Writing any other value in this field aborts the write operation."]
462 #[inline(always)]
463 pub fn passwd(self) -> &'a mut W {
464 self.variant(KEY_A::PASSWD)
465 }
466 #[doc = r"Writes raw bits to the field"]
467 #[inline(always)]
468 pub unsafe fn bits(self, value: u8) -> &'a mut W {
469 self.w.bits = (self.w.bits & !(0xff << 24)) | ((value as u32 & 0xff) << 24);
470 self.w
471 }
472}
473impl R {
474 #[doc = "Bit 12 - Brownout Detector Reset Enable"]
475 #[inline(always)]
476 pub fn bodrsten(&self) -> BODRSTEN_R {
477 BODRSTEN_R::new(((self.bits >> 12) & 0x01) != 0)
478 }
479 #[doc = "Bit 13 - Brownout Detector Disable"]
480 #[inline(always)]
481 pub fn boddis(&self) -> BODDIS_R {
482 BODDIS_R::new(((self.bits >> 13) & 0x01) != 0)
483 }
484 #[doc = "Bit 14 - Voltage Regulator Enable"]
485 #[inline(always)]
486 pub fn onreg(&self) -> ONREG_R {
487 ONREG_R::new(((self.bits >> 14) & 0x01) != 0)
488 }
489 #[doc = "Bit 17 - SRAM On In Backup Mode"]
490 #[inline(always)]
491 pub fn bkupreton(&self) -> BKUPRETON_R {
492 BKUPRETON_R::new(((self.bits >> 17) & 0x01) != 0)
493 }
494 #[doc = "Bit 20 - Oscillator Bypass"]
495 #[inline(always)]
496 pub fn oscbypass(&self) -> OSCBYPASS_R {
497 OSCBYPASS_R::new(((self.bits >> 20) & 0x01) != 0)
498 }
499 #[doc = "Bits 24:31 - Password Key"]
500 #[inline(always)]
501 pub fn key(&self) -> KEY_R {
502 KEY_R::new(((self.bits >> 24) & 0xff) as u8)
503 }
504}
505impl W {
506 #[doc = "Bit 12 - Brownout Detector Reset Enable"]
507 #[inline(always)]
508 pub fn bodrsten(&mut self) -> BODRSTEN_W {
509 BODRSTEN_W { w: self }
510 }
511 #[doc = "Bit 13 - Brownout Detector Disable"]
512 #[inline(always)]
513 pub fn boddis(&mut self) -> BODDIS_W {
514 BODDIS_W { w: self }
515 }
516 #[doc = "Bit 14 - Voltage Regulator Enable"]
517 #[inline(always)]
518 pub fn onreg(&mut self) -> ONREG_W {
519 ONREG_W { w: self }
520 }
521 #[doc = "Bit 17 - SRAM On In Backup Mode"]
522 #[inline(always)]
523 pub fn bkupreton(&mut self) -> BKUPRETON_W {
524 BKUPRETON_W { w: self }
525 }
526 #[doc = "Bit 20 - Oscillator Bypass"]
527 #[inline(always)]
528 pub fn oscbypass(&mut self) -> OSCBYPASS_W {
529 OSCBYPASS_W { w: self }
530 }
531 #[doc = "Bits 24:31 - Password Key"]
532 #[inline(always)]
533 pub fn key(&mut self) -> KEY_W {
534 KEY_W { w: self }
535 }
536 #[doc = "Writes raw bits to the register."]
537 #[inline(always)]
538 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
539 self.0.bits(bits);
540 self
541 }
542}
543#[doc = "Supply Controller Mode 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 [supc_mr](index.html) module"]
544pub struct SUPC_MR_SPEC;
545impl crate::RegisterSpec for SUPC_MR_SPEC {
546 type Ux = u32;
547}
548#[doc = "`read()` method returns [supc_mr::R](R) reader structure"]
549impl crate::Readable for SUPC_MR_SPEC {
550 type Reader = R;
551}
552#[doc = "`write(|w| ..)` method takes [supc_mr::W](W) writer structure"]
553impl crate::Writable for SUPC_MR_SPEC {
554 type Writer = W;
555}
556#[doc = "`reset()` method sets SUPC_MR to value 0"]
557impl crate::Resettable for SUPC_MR_SPEC {
558 #[inline(always)]
559 fn reset_value() -> Self::Ux {
560 0
561 }
562}