nrf52832_pac/power/
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 failure comparator"]
38pub type POF_R = crate::BitReader<POF_A>;
39#[doc = "Enable or disable power failure 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 failure 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 failure comparator threshold setting"]
88pub type THRESHOLD_R = crate::FieldReader<u8, THRESHOLD_A>;
89#[doc = "Power failure comparator threshold setting\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91#[repr(u8)]
92pub enum THRESHOLD_A {
93    #[doc = "4: Set threshold to 1.7 V"]
94    V17 = 4,
95    #[doc = "5: Set threshold to 1.8 V"]
96    V18 = 5,
97    #[doc = "6: Set threshold to 1.9 V"]
98    V19 = 6,
99    #[doc = "7: Set threshold to 2.0 V"]
100    V20 = 7,
101    #[doc = "8: Set threshold to 2.1 V"]
102    V21 = 8,
103    #[doc = "9: Set threshold to 2.2 V"]
104    V22 = 9,
105    #[doc = "10: Set threshold to 2.3 V"]
106    V23 = 10,
107    #[doc = "11: Set threshold to 2.4 V"]
108    V24 = 11,
109    #[doc = "12: Set threshold to 2.5 V"]
110    V25 = 12,
111    #[doc = "13: Set threshold to 2.6 V"]
112    V26 = 13,
113    #[doc = "14: Set threshold to 2.7 V"]
114    V27 = 14,
115    #[doc = "15: Set threshold to 2.8 V"]
116    V28 = 15,
117}
118impl From<THRESHOLD_A> for u8 {
119    #[inline(always)]
120    fn from(variant: THRESHOLD_A) -> Self {
121        variant as _
122    }
123}
124impl THRESHOLD_R {
125    #[doc = "Get enumerated values variant"]
126    #[inline(always)]
127    pub fn variant(&self) -> Option<THRESHOLD_A> {
128        match self.bits {
129            4 => Some(THRESHOLD_A::V17),
130            5 => Some(THRESHOLD_A::V18),
131            6 => Some(THRESHOLD_A::V19),
132            7 => Some(THRESHOLD_A::V20),
133            8 => Some(THRESHOLD_A::V21),
134            9 => Some(THRESHOLD_A::V22),
135            10 => Some(THRESHOLD_A::V23),
136            11 => Some(THRESHOLD_A::V24),
137            12 => Some(THRESHOLD_A::V25),
138            13 => Some(THRESHOLD_A::V26),
139            14 => Some(THRESHOLD_A::V27),
140            15 => Some(THRESHOLD_A::V28),
141            _ => None,
142        }
143    }
144    #[doc = "Checks if the value of the field is `V17`"]
145    #[inline(always)]
146    pub fn is_v17(&self) -> bool {
147        *self == THRESHOLD_A::V17
148    }
149    #[doc = "Checks if the value of the field is `V18`"]
150    #[inline(always)]
151    pub fn is_v18(&self) -> bool {
152        *self == THRESHOLD_A::V18
153    }
154    #[doc = "Checks if the value of the field is `V19`"]
155    #[inline(always)]
156    pub fn is_v19(&self) -> bool {
157        *self == THRESHOLD_A::V19
158    }
159    #[doc = "Checks if the value of the field is `V20`"]
160    #[inline(always)]
161    pub fn is_v20(&self) -> bool {
162        *self == THRESHOLD_A::V20
163    }
164    #[doc = "Checks if the value of the field is `V21`"]
165    #[inline(always)]
166    pub fn is_v21(&self) -> bool {
167        *self == THRESHOLD_A::V21
168    }
169    #[doc = "Checks if the value of the field is `V22`"]
170    #[inline(always)]
171    pub fn is_v22(&self) -> bool {
172        *self == THRESHOLD_A::V22
173    }
174    #[doc = "Checks if the value of the field is `V23`"]
175    #[inline(always)]
176    pub fn is_v23(&self) -> bool {
177        *self == THRESHOLD_A::V23
178    }
179    #[doc = "Checks if the value of the field is `V24`"]
180    #[inline(always)]
181    pub fn is_v24(&self) -> bool {
182        *self == THRESHOLD_A::V24
183    }
184    #[doc = "Checks if the value of the field is `V25`"]
185    #[inline(always)]
186    pub fn is_v25(&self) -> bool {
187        *self == THRESHOLD_A::V25
188    }
189    #[doc = "Checks if the value of the field is `V26`"]
190    #[inline(always)]
191    pub fn is_v26(&self) -> bool {
192        *self == THRESHOLD_A::V26
193    }
194    #[doc = "Checks if the value of the field is `V27`"]
195    #[inline(always)]
196    pub fn is_v27(&self) -> bool {
197        *self == THRESHOLD_A::V27
198    }
199    #[doc = "Checks if the value of the field is `V28`"]
200    #[inline(always)]
201    pub fn is_v28(&self) -> bool {
202        *self == THRESHOLD_A::V28
203    }
204}
205#[doc = "Field `THRESHOLD` writer - Power failure comparator threshold setting"]
206pub type THRESHOLD_W<'a, const O: u8> =
207    crate::FieldWriter<'a, u32, POFCON_SPEC, u8, THRESHOLD_A, 4, O>;
208impl<'a, const O: u8> THRESHOLD_W<'a, O> {
209    #[doc = "Set threshold to 1.7 V"]
210    #[inline(always)]
211    pub fn v17(self) -> &'a mut W {
212        self.variant(THRESHOLD_A::V17)
213    }
214    #[doc = "Set threshold to 1.8 V"]
215    #[inline(always)]
216    pub fn v18(self) -> &'a mut W {
217        self.variant(THRESHOLD_A::V18)
218    }
219    #[doc = "Set threshold to 1.9 V"]
220    #[inline(always)]
221    pub fn v19(self) -> &'a mut W {
222        self.variant(THRESHOLD_A::V19)
223    }
224    #[doc = "Set threshold to 2.0 V"]
225    #[inline(always)]
226    pub fn v20(self) -> &'a mut W {
227        self.variant(THRESHOLD_A::V20)
228    }
229    #[doc = "Set threshold to 2.1 V"]
230    #[inline(always)]
231    pub fn v21(self) -> &'a mut W {
232        self.variant(THRESHOLD_A::V21)
233    }
234    #[doc = "Set threshold to 2.2 V"]
235    #[inline(always)]
236    pub fn v22(self) -> &'a mut W {
237        self.variant(THRESHOLD_A::V22)
238    }
239    #[doc = "Set threshold to 2.3 V"]
240    #[inline(always)]
241    pub fn v23(self) -> &'a mut W {
242        self.variant(THRESHOLD_A::V23)
243    }
244    #[doc = "Set threshold to 2.4 V"]
245    #[inline(always)]
246    pub fn v24(self) -> &'a mut W {
247        self.variant(THRESHOLD_A::V24)
248    }
249    #[doc = "Set threshold to 2.5 V"]
250    #[inline(always)]
251    pub fn v25(self) -> &'a mut W {
252        self.variant(THRESHOLD_A::V25)
253    }
254    #[doc = "Set threshold to 2.6 V"]
255    #[inline(always)]
256    pub fn v26(self) -> &'a mut W {
257        self.variant(THRESHOLD_A::V26)
258    }
259    #[doc = "Set threshold to 2.7 V"]
260    #[inline(always)]
261    pub fn v27(self) -> &'a mut W {
262        self.variant(THRESHOLD_A::V27)
263    }
264    #[doc = "Set threshold to 2.8 V"]
265    #[inline(always)]
266    pub fn v28(self) -> &'a mut W {
267        self.variant(THRESHOLD_A::V28)
268    }
269}
270impl R {
271    #[doc = "Bit 0 - Enable or disable power failure comparator"]
272    #[inline(always)]
273    pub fn pof(&self) -> POF_R {
274        POF_R::new((self.bits & 1) != 0)
275    }
276    #[doc = "Bits 1:4 - Power failure comparator threshold setting"]
277    #[inline(always)]
278    pub fn threshold(&self) -> THRESHOLD_R {
279        THRESHOLD_R::new(((self.bits >> 1) & 0x0f) as u8)
280    }
281}
282impl W {
283    #[doc = "Bit 0 - Enable or disable power failure comparator"]
284    #[inline(always)]
285    pub fn pof(&mut self) -> POF_W<0> {
286        POF_W::new(self)
287    }
288    #[doc = "Bits 1:4 - Power failure comparator threshold setting"]
289    #[inline(always)]
290    pub fn threshold(&mut self) -> THRESHOLD_W<1> {
291        THRESHOLD_W::new(self)
292    }
293    #[doc = "Writes raw bits to the register."]
294    #[inline(always)]
295    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
296        self.0.bits(bits);
297        self
298    }
299}
300#[doc = "Power failure 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"]
301pub struct POFCON_SPEC;
302impl crate::RegisterSpec for POFCON_SPEC {
303    type Ux = u32;
304}
305#[doc = "`read()` method returns [pofcon::R](R) reader structure"]
306impl crate::Readable for POFCON_SPEC {
307    type Reader = R;
308}
309#[doc = "`write(|w| ..)` method takes [pofcon::W](W) writer structure"]
310impl crate::Writable for POFCON_SPEC {
311    type Writer = W;
312}
313#[doc = "`reset()` method sets POFCON to value 0"]
314impl crate::Resettable for POFCON_SPEC {
315    #[inline(always)]
316    fn reset_value() -> Self::Ux {
317        0
318    }
319}