nrf5340_app_pac/regulators_ns/
pofcon.rs

1#[doc = "Register `POFCON` reader"]
2pub struct R(crate::R<POFCON_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<POFCON_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<POFCON_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<POFCON_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `POFCON` writer"]
17pub struct W(crate::W<POFCON_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<POFCON_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<POFCON_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<POFCON_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `POF` reader - Enable or disable power-fail comparator"]
38pub type POF_R = crate::BitReader<POF_A>;
39#[doc = "Enable or disable power-fail comparator\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum POF_A {
42    #[doc = "0: Disable"]
43    DISABLED = 0,
44    #[doc = "1: Enable"]
45    ENABLED = 1,
46}
47impl From<POF_A> for bool {
48    #[inline(always)]
49    fn from(variant: POF_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl POF_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> POF_A {
57        match self.bits {
58            false => POF_A::DISABLED,
59            true => POF_A::ENABLED,
60        }
61    }
62    #[doc = "Checks if the value of the field is `DISABLED`"]
63    #[inline(always)]
64    pub fn is_disabled(&self) -> bool {
65        *self == POF_A::DISABLED
66    }
67    #[doc = "Checks if the value of the field is `ENABLED`"]
68    #[inline(always)]
69    pub fn is_enabled(&self) -> bool {
70        *self == POF_A::ENABLED
71    }
72}
73#[doc = "Field `POF` writer - Enable or disable power-fail comparator"]
74pub type POF_W<'a, const O: u8> = crate::BitWriter<'a, u32, POFCON_SPEC, POF_A, O>;
75impl<'a, const O: u8> POF_W<'a, O> {
76    #[doc = "Disable"]
77    #[inline(always)]
78    pub fn disabled(self) -> &'a mut W {
79        self.variant(POF_A::DISABLED)
80    }
81    #[doc = "Enable"]
82    #[inline(always)]
83    pub fn enabled(self) -> &'a mut W {
84        self.variant(POF_A::ENABLED)
85    }
86}
87#[doc = "Field `THRESHOLD` reader - Power-fail comparator threshold setting"]
88pub type THRESHOLD_R = crate::FieldReader<u8, THRESHOLD_A>;
89#[doc = "Power-fail comparator threshold setting\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91#[repr(u8)]
92pub enum THRESHOLD_A {
93    #[doc = "6: Set threshold to 1.9 V"]
94    V19 = 6,
95    #[doc = "7: Set threshold to 2.0 V"]
96    V20 = 7,
97    #[doc = "8: Set threshold to 2.1 V"]
98    V21 = 8,
99    #[doc = "9: Set threshold to 2.2 V"]
100    V22 = 9,
101    #[doc = "10: Set threshold to 2.3 V"]
102    V23 = 10,
103    #[doc = "11: Set threshold to 2.4 V"]
104    V24 = 11,
105    #[doc = "12: Set threshold to 2.5 V"]
106    V25 = 12,
107    #[doc = "13: Set threshold to 2.6 V"]
108    V26 = 13,
109    #[doc = "14: Set threshold to 2.7 V"]
110    V27 = 14,
111    #[doc = "15: Set threshold to 2.8 V"]
112    V28 = 15,
113}
114impl From<THRESHOLD_A> for u8 {
115    #[inline(always)]
116    fn from(variant: THRESHOLD_A) -> Self {
117        variant as _
118    }
119}
120impl THRESHOLD_R {
121    #[doc = "Get enumerated values variant"]
122    #[inline(always)]
123    pub fn variant(&self) -> Option<THRESHOLD_A> {
124        match self.bits {
125            6 => Some(THRESHOLD_A::V19),
126            7 => Some(THRESHOLD_A::V20),
127            8 => Some(THRESHOLD_A::V21),
128            9 => Some(THRESHOLD_A::V22),
129            10 => Some(THRESHOLD_A::V23),
130            11 => Some(THRESHOLD_A::V24),
131            12 => Some(THRESHOLD_A::V25),
132            13 => Some(THRESHOLD_A::V26),
133            14 => Some(THRESHOLD_A::V27),
134            15 => Some(THRESHOLD_A::V28),
135            _ => None,
136        }
137    }
138    #[doc = "Checks if the value of the field is `V19`"]
139    #[inline(always)]
140    pub fn is_v19(&self) -> bool {
141        *self == THRESHOLD_A::V19
142    }
143    #[doc = "Checks if the value of the field is `V20`"]
144    #[inline(always)]
145    pub fn is_v20(&self) -> bool {
146        *self == THRESHOLD_A::V20
147    }
148    #[doc = "Checks if the value of the field is `V21`"]
149    #[inline(always)]
150    pub fn is_v21(&self) -> bool {
151        *self == THRESHOLD_A::V21
152    }
153    #[doc = "Checks if the value of the field is `V22`"]
154    #[inline(always)]
155    pub fn is_v22(&self) -> bool {
156        *self == THRESHOLD_A::V22
157    }
158    #[doc = "Checks if the value of the field is `V23`"]
159    #[inline(always)]
160    pub fn is_v23(&self) -> bool {
161        *self == THRESHOLD_A::V23
162    }
163    #[doc = "Checks if the value of the field is `V24`"]
164    #[inline(always)]
165    pub fn is_v24(&self) -> bool {
166        *self == THRESHOLD_A::V24
167    }
168    #[doc = "Checks if the value of the field is `V25`"]
169    #[inline(always)]
170    pub fn is_v25(&self) -> bool {
171        *self == THRESHOLD_A::V25
172    }
173    #[doc = "Checks if the value of the field is `V26`"]
174    #[inline(always)]
175    pub fn is_v26(&self) -> bool {
176        *self == THRESHOLD_A::V26
177    }
178    #[doc = "Checks if the value of the field is `V27`"]
179    #[inline(always)]
180    pub fn is_v27(&self) -> bool {
181        *self == THRESHOLD_A::V27
182    }
183    #[doc = "Checks if the value of the field is `V28`"]
184    #[inline(always)]
185    pub fn is_v28(&self) -> bool {
186        *self == THRESHOLD_A::V28
187    }
188}
189#[doc = "Field `THRESHOLD` writer - Power-fail comparator threshold setting"]
190pub type THRESHOLD_W<'a, const O: u8> =
191    crate::FieldWriter<'a, u32, POFCON_SPEC, u8, THRESHOLD_A, 4, O>;
192impl<'a, const O: u8> THRESHOLD_W<'a, O> {
193    #[doc = "Set threshold to 1.9 V"]
194    #[inline(always)]
195    pub fn v19(self) -> &'a mut W {
196        self.variant(THRESHOLD_A::V19)
197    }
198    #[doc = "Set threshold to 2.0 V"]
199    #[inline(always)]
200    pub fn v20(self) -> &'a mut W {
201        self.variant(THRESHOLD_A::V20)
202    }
203    #[doc = "Set threshold to 2.1 V"]
204    #[inline(always)]
205    pub fn v21(self) -> &'a mut W {
206        self.variant(THRESHOLD_A::V21)
207    }
208    #[doc = "Set threshold to 2.2 V"]
209    #[inline(always)]
210    pub fn v22(self) -> &'a mut W {
211        self.variant(THRESHOLD_A::V22)
212    }
213    #[doc = "Set threshold to 2.3 V"]
214    #[inline(always)]
215    pub fn v23(self) -> &'a mut W {
216        self.variant(THRESHOLD_A::V23)
217    }
218    #[doc = "Set threshold to 2.4 V"]
219    #[inline(always)]
220    pub fn v24(self) -> &'a mut W {
221        self.variant(THRESHOLD_A::V24)
222    }
223    #[doc = "Set threshold to 2.5 V"]
224    #[inline(always)]
225    pub fn v25(self) -> &'a mut W {
226        self.variant(THRESHOLD_A::V25)
227    }
228    #[doc = "Set threshold to 2.6 V"]
229    #[inline(always)]
230    pub fn v26(self) -> &'a mut W {
231        self.variant(THRESHOLD_A::V26)
232    }
233    #[doc = "Set threshold to 2.7 V"]
234    #[inline(always)]
235    pub fn v27(self) -> &'a mut W {
236        self.variant(THRESHOLD_A::V27)
237    }
238    #[doc = "Set threshold to 2.8 V"]
239    #[inline(always)]
240    pub fn v28(self) -> &'a mut W {
241        self.variant(THRESHOLD_A::V28)
242    }
243}
244#[doc = "Field `THRESHOLDVDDH` reader - Power-fail comparator threshold setting for voltage supply on VDDH"]
245pub type THRESHOLDVDDH_R = crate::FieldReader<u8, THRESHOLDVDDH_A>;
246#[doc = "Power-fail comparator threshold setting for voltage supply on VDDH\n\nValue on reset: 0"]
247#[derive(Clone, Copy, Debug, PartialEq)]
248#[repr(u8)]
249pub enum THRESHOLDVDDH_A {
250    #[doc = "0: Set threshold to 2.7 V"]
251    V27 = 0,
252    #[doc = "1: Set threshold to 2.8 V"]
253    V28 = 1,
254    #[doc = "2: Set threshold to 2.9 V"]
255    V29 = 2,
256    #[doc = "3: Set threshold to 3.0 V"]
257    V30 = 3,
258    #[doc = "4: Set threshold to 3.1 V"]
259    V31 = 4,
260    #[doc = "5: Set threshold to 3.2 V"]
261    V32 = 5,
262    #[doc = "6: Set threshold to 3.3 V"]
263    V33 = 6,
264    #[doc = "7: Set threshold to 3.4 V"]
265    V34 = 7,
266    #[doc = "8: Set threshold to 3.5 V"]
267    V35 = 8,
268    #[doc = "9: Set threshold to 3.6 V"]
269    V36 = 9,
270    #[doc = "10: Set threshold to 3.7 V"]
271    V37 = 10,
272    #[doc = "11: Set threshold to 3.8 V"]
273    V38 = 11,
274    #[doc = "12: Set threshold to 3.9 V"]
275    V39 = 12,
276    #[doc = "13: Set threshold to 4.0 V"]
277    V40 = 13,
278    #[doc = "14: Set threshold to 4.1 V"]
279    V41 = 14,
280    #[doc = "15: Set threshold to 4.2 V"]
281    V42 = 15,
282}
283impl From<THRESHOLDVDDH_A> for u8 {
284    #[inline(always)]
285    fn from(variant: THRESHOLDVDDH_A) -> Self {
286        variant as _
287    }
288}
289impl THRESHOLDVDDH_R {
290    #[doc = "Get enumerated values variant"]
291    #[inline(always)]
292    pub fn variant(&self) -> THRESHOLDVDDH_A {
293        match self.bits {
294            0 => THRESHOLDVDDH_A::V27,
295            1 => THRESHOLDVDDH_A::V28,
296            2 => THRESHOLDVDDH_A::V29,
297            3 => THRESHOLDVDDH_A::V30,
298            4 => THRESHOLDVDDH_A::V31,
299            5 => THRESHOLDVDDH_A::V32,
300            6 => THRESHOLDVDDH_A::V33,
301            7 => THRESHOLDVDDH_A::V34,
302            8 => THRESHOLDVDDH_A::V35,
303            9 => THRESHOLDVDDH_A::V36,
304            10 => THRESHOLDVDDH_A::V37,
305            11 => THRESHOLDVDDH_A::V38,
306            12 => THRESHOLDVDDH_A::V39,
307            13 => THRESHOLDVDDH_A::V40,
308            14 => THRESHOLDVDDH_A::V41,
309            15 => THRESHOLDVDDH_A::V42,
310            _ => unreachable!(),
311        }
312    }
313    #[doc = "Checks if the value of the field is `V27`"]
314    #[inline(always)]
315    pub fn is_v27(&self) -> bool {
316        *self == THRESHOLDVDDH_A::V27
317    }
318    #[doc = "Checks if the value of the field is `V28`"]
319    #[inline(always)]
320    pub fn is_v28(&self) -> bool {
321        *self == THRESHOLDVDDH_A::V28
322    }
323    #[doc = "Checks if the value of the field is `V29`"]
324    #[inline(always)]
325    pub fn is_v29(&self) -> bool {
326        *self == THRESHOLDVDDH_A::V29
327    }
328    #[doc = "Checks if the value of the field is `V30`"]
329    #[inline(always)]
330    pub fn is_v30(&self) -> bool {
331        *self == THRESHOLDVDDH_A::V30
332    }
333    #[doc = "Checks if the value of the field is `V31`"]
334    #[inline(always)]
335    pub fn is_v31(&self) -> bool {
336        *self == THRESHOLDVDDH_A::V31
337    }
338    #[doc = "Checks if the value of the field is `V32`"]
339    #[inline(always)]
340    pub fn is_v32(&self) -> bool {
341        *self == THRESHOLDVDDH_A::V32
342    }
343    #[doc = "Checks if the value of the field is `V33`"]
344    #[inline(always)]
345    pub fn is_v33(&self) -> bool {
346        *self == THRESHOLDVDDH_A::V33
347    }
348    #[doc = "Checks if the value of the field is `V34`"]
349    #[inline(always)]
350    pub fn is_v34(&self) -> bool {
351        *self == THRESHOLDVDDH_A::V34
352    }
353    #[doc = "Checks if the value of the field is `V35`"]
354    #[inline(always)]
355    pub fn is_v35(&self) -> bool {
356        *self == THRESHOLDVDDH_A::V35
357    }
358    #[doc = "Checks if the value of the field is `V36`"]
359    #[inline(always)]
360    pub fn is_v36(&self) -> bool {
361        *self == THRESHOLDVDDH_A::V36
362    }
363    #[doc = "Checks if the value of the field is `V37`"]
364    #[inline(always)]
365    pub fn is_v37(&self) -> bool {
366        *self == THRESHOLDVDDH_A::V37
367    }
368    #[doc = "Checks if the value of the field is `V38`"]
369    #[inline(always)]
370    pub fn is_v38(&self) -> bool {
371        *self == THRESHOLDVDDH_A::V38
372    }
373    #[doc = "Checks if the value of the field is `V39`"]
374    #[inline(always)]
375    pub fn is_v39(&self) -> bool {
376        *self == THRESHOLDVDDH_A::V39
377    }
378    #[doc = "Checks if the value of the field is `V40`"]
379    #[inline(always)]
380    pub fn is_v40(&self) -> bool {
381        *self == THRESHOLDVDDH_A::V40
382    }
383    #[doc = "Checks if the value of the field is `V41`"]
384    #[inline(always)]
385    pub fn is_v41(&self) -> bool {
386        *self == THRESHOLDVDDH_A::V41
387    }
388    #[doc = "Checks if the value of the field is `V42`"]
389    #[inline(always)]
390    pub fn is_v42(&self) -> bool {
391        *self == THRESHOLDVDDH_A::V42
392    }
393}
394#[doc = "Field `THRESHOLDVDDH` writer - Power-fail comparator threshold setting for voltage supply on VDDH"]
395pub type THRESHOLDVDDH_W<'a, const O: u8> =
396    crate::FieldWriterSafe<'a, u32, POFCON_SPEC, u8, THRESHOLDVDDH_A, 4, O>;
397impl<'a, const O: u8> THRESHOLDVDDH_W<'a, O> {
398    #[doc = "Set threshold to 2.7 V"]
399    #[inline(always)]
400    pub fn v27(self) -> &'a mut W {
401        self.variant(THRESHOLDVDDH_A::V27)
402    }
403    #[doc = "Set threshold to 2.8 V"]
404    #[inline(always)]
405    pub fn v28(self) -> &'a mut W {
406        self.variant(THRESHOLDVDDH_A::V28)
407    }
408    #[doc = "Set threshold to 2.9 V"]
409    #[inline(always)]
410    pub fn v29(self) -> &'a mut W {
411        self.variant(THRESHOLDVDDH_A::V29)
412    }
413    #[doc = "Set threshold to 3.0 V"]
414    #[inline(always)]
415    pub fn v30(self) -> &'a mut W {
416        self.variant(THRESHOLDVDDH_A::V30)
417    }
418    #[doc = "Set threshold to 3.1 V"]
419    #[inline(always)]
420    pub fn v31(self) -> &'a mut W {
421        self.variant(THRESHOLDVDDH_A::V31)
422    }
423    #[doc = "Set threshold to 3.2 V"]
424    #[inline(always)]
425    pub fn v32(self) -> &'a mut W {
426        self.variant(THRESHOLDVDDH_A::V32)
427    }
428    #[doc = "Set threshold to 3.3 V"]
429    #[inline(always)]
430    pub fn v33(self) -> &'a mut W {
431        self.variant(THRESHOLDVDDH_A::V33)
432    }
433    #[doc = "Set threshold to 3.4 V"]
434    #[inline(always)]
435    pub fn v34(self) -> &'a mut W {
436        self.variant(THRESHOLDVDDH_A::V34)
437    }
438    #[doc = "Set threshold to 3.5 V"]
439    #[inline(always)]
440    pub fn v35(self) -> &'a mut W {
441        self.variant(THRESHOLDVDDH_A::V35)
442    }
443    #[doc = "Set threshold to 3.6 V"]
444    #[inline(always)]
445    pub fn v36(self) -> &'a mut W {
446        self.variant(THRESHOLDVDDH_A::V36)
447    }
448    #[doc = "Set threshold to 3.7 V"]
449    #[inline(always)]
450    pub fn v37(self) -> &'a mut W {
451        self.variant(THRESHOLDVDDH_A::V37)
452    }
453    #[doc = "Set threshold to 3.8 V"]
454    #[inline(always)]
455    pub fn v38(self) -> &'a mut W {
456        self.variant(THRESHOLDVDDH_A::V38)
457    }
458    #[doc = "Set threshold to 3.9 V"]
459    #[inline(always)]
460    pub fn v39(self) -> &'a mut W {
461        self.variant(THRESHOLDVDDH_A::V39)
462    }
463    #[doc = "Set threshold to 4.0 V"]
464    #[inline(always)]
465    pub fn v40(self) -> &'a mut W {
466        self.variant(THRESHOLDVDDH_A::V40)
467    }
468    #[doc = "Set threshold to 4.1 V"]
469    #[inline(always)]
470    pub fn v41(self) -> &'a mut W {
471        self.variant(THRESHOLDVDDH_A::V41)
472    }
473    #[doc = "Set threshold to 4.2 V"]
474    #[inline(always)]
475    pub fn v42(self) -> &'a mut W {
476        self.variant(THRESHOLDVDDH_A::V42)
477    }
478}
479impl R {
480    #[doc = "Bit 0 - Enable or disable power-fail comparator"]
481    #[inline(always)]
482    pub fn pof(&self) -> POF_R {
483        POF_R::new((self.bits & 1) != 0)
484    }
485    #[doc = "Bits 1:4 - Power-fail comparator threshold setting"]
486    #[inline(always)]
487    pub fn threshold(&self) -> THRESHOLD_R {
488        THRESHOLD_R::new(((self.bits >> 1) & 0x0f) as u8)
489    }
490    #[doc = "Bits 8:11 - Power-fail comparator threshold setting for voltage supply on VDDH"]
491    #[inline(always)]
492    pub fn thresholdvddh(&self) -> THRESHOLDVDDH_R {
493        THRESHOLDVDDH_R::new(((self.bits >> 8) & 0x0f) as u8)
494    }
495}
496impl W {
497    #[doc = "Bit 0 - Enable or disable power-fail comparator"]
498    #[inline(always)]
499    pub fn pof(&mut self) -> POF_W<0> {
500        POF_W::new(self)
501    }
502    #[doc = "Bits 1:4 - Power-fail comparator threshold setting"]
503    #[inline(always)]
504    pub fn threshold(&mut self) -> THRESHOLD_W<1> {
505        THRESHOLD_W::new(self)
506    }
507    #[doc = "Bits 8:11 - Power-fail comparator threshold setting for voltage supply on VDDH"]
508    #[inline(always)]
509    pub fn thresholdvddh(&mut self) -> THRESHOLDVDDH_W<8> {
510        THRESHOLDVDDH_W::new(self)
511    }
512    #[doc = "Writes raw bits to the register."]
513    #[inline(always)]
514    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
515        self.0.bits(bits);
516        self
517    }
518}
519#[doc = "Power-fail comparator configuration\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 [pofcon](index.html) module"]
520pub struct POFCON_SPEC;
521impl crate::RegisterSpec for POFCON_SPEC {
522    type Ux = u32;
523}
524#[doc = "`read()` method returns [pofcon::R](R) reader structure"]
525impl crate::Readable for POFCON_SPEC {
526    type Reader = R;
527}
528#[doc = "`write(|w| ..)` method takes [pofcon::W](W) writer structure"]
529impl crate::Writable for POFCON_SPEC {
530    type Writer = W;
531}
532#[doc = "`reset()` method sets POFCON to value 0"]
533impl crate::Resettable for POFCON_SPEC {
534    #[inline(always)]
535    fn reset_value() -> Self::Ux {
536        0
537    }
538}