lpc82x_pac/syscon/
sysrststat.rs

1#[doc = "Register `SYSRSTSTAT` reader"]
2pub struct R(crate::R<SYSRSTSTAT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SYSRSTSTAT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SYSRSTSTAT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SYSRSTSTAT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SYSRSTSTAT` writer"]
17pub struct W(crate::W<SYSRSTSTAT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SYSRSTSTAT_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<SYSRSTSTAT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SYSRSTSTAT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "POR reset status.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum POR_A {
40    #[doc = "0: No POR detected."]
41    POR_0 = 0,
42    #[doc = "1: POR detected. Writing a one clears this reset."]
43    POR_1 = 1,
44}
45impl From<POR_A> for bool {
46    #[inline(always)]
47    fn from(variant: POR_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `POR` reader - POR reset status."]
52pub struct POR_R(crate::FieldReader<bool, POR_A>);
53impl POR_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        POR_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> POR_A {
60        match self.bits {
61            false => POR_A::POR_0,
62            true => POR_A::POR_1,
63        }
64    }
65    #[doc = "Checks if the value of the field is `POR_0`"]
66    #[inline(always)]
67    pub fn is_por_0(&self) -> bool {
68        **self == POR_A::POR_0
69    }
70    #[doc = "Checks if the value of the field is `POR_1`"]
71    #[inline(always)]
72    pub fn is_por_1(&self) -> bool {
73        **self == POR_A::POR_1
74    }
75}
76impl core::ops::Deref for POR_R {
77    type Target = crate::FieldReader<bool, POR_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `POR` writer - POR reset status."]
84pub struct POR_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> POR_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: POR_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "No POR detected."]
94    #[inline(always)]
95    pub fn por_0(self) -> &'a mut W {
96        self.variant(POR_A::POR_0)
97    }
98    #[doc = "POR detected. Writing a one clears this reset."]
99    #[inline(always)]
100    pub fn por_1(self) -> &'a mut W {
101        self.variant(POR_A::POR_1)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
117        self.w
118    }
119}
120#[doc = "Status of the external RESET pin. External reset status.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum EXTRST_A {
123    #[doc = "0: No reset event detected."]
124    EXTRST_0 = 0,
125    #[doc = "1: Reset detected. Writing a one clears this reset."]
126    EXTRST_1 = 1,
127}
128impl From<EXTRST_A> for bool {
129    #[inline(always)]
130    fn from(variant: EXTRST_A) -> Self {
131        variant as u8 != 0
132    }
133}
134#[doc = "Field `EXTRST` reader - Status of the external RESET pin. External reset status."]
135pub struct EXTRST_R(crate::FieldReader<bool, EXTRST_A>);
136impl EXTRST_R {
137    pub(crate) fn new(bits: bool) -> Self {
138        EXTRST_R(crate::FieldReader::new(bits))
139    }
140    #[doc = r"Get enumerated values variant"]
141    #[inline(always)]
142    pub fn variant(&self) -> EXTRST_A {
143        match self.bits {
144            false => EXTRST_A::EXTRST_0,
145            true => EXTRST_A::EXTRST_1,
146        }
147    }
148    #[doc = "Checks if the value of the field is `EXTRST_0`"]
149    #[inline(always)]
150    pub fn is_extrst_0(&self) -> bool {
151        **self == EXTRST_A::EXTRST_0
152    }
153    #[doc = "Checks if the value of the field is `EXTRST_1`"]
154    #[inline(always)]
155    pub fn is_extrst_1(&self) -> bool {
156        **self == EXTRST_A::EXTRST_1
157    }
158}
159impl core::ops::Deref for EXTRST_R {
160    type Target = crate::FieldReader<bool, EXTRST_A>;
161    #[inline(always)]
162    fn deref(&self) -> &Self::Target {
163        &self.0
164    }
165}
166#[doc = "Field `EXTRST` writer - Status of the external RESET pin. External reset status."]
167pub struct EXTRST_W<'a> {
168    w: &'a mut W,
169}
170impl<'a> EXTRST_W<'a> {
171    #[doc = r"Writes `variant` to the field"]
172    #[inline(always)]
173    pub fn variant(self, variant: EXTRST_A) -> &'a mut W {
174        self.bit(variant.into())
175    }
176    #[doc = "No reset event detected."]
177    #[inline(always)]
178    pub fn extrst_0(self) -> &'a mut W {
179        self.variant(EXTRST_A::EXTRST_0)
180    }
181    #[doc = "Reset detected. Writing a one clears this reset."]
182    #[inline(always)]
183    pub fn extrst_1(self) -> &'a mut W {
184        self.variant(EXTRST_A::EXTRST_1)
185    }
186    #[doc = r"Sets the field bit"]
187    #[inline(always)]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r"Clears the field bit"]
192    #[inline(always)]
193    pub fn clear_bit(self) -> &'a mut W {
194        self.bit(false)
195    }
196    #[doc = r"Writes raw bits to the field"]
197    #[inline(always)]
198    pub fn bit(self, value: bool) -> &'a mut W {
199        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
200        self.w
201    }
202}
203#[doc = "Status of the Watchdog reset.\n\nValue on reset: 0"]
204#[derive(Clone, Copy, Debug, PartialEq)]
205pub enum WDT_A {
206    #[doc = "0: No WDT reset detected."]
207    WDT_0 = 0,
208    #[doc = "1: WDT reset detected. Writing a one clears this reset."]
209    WDT_1 = 1,
210}
211impl From<WDT_A> for bool {
212    #[inline(always)]
213    fn from(variant: WDT_A) -> Self {
214        variant as u8 != 0
215    }
216}
217#[doc = "Field `WDT` reader - Status of the Watchdog reset."]
218pub struct WDT_R(crate::FieldReader<bool, WDT_A>);
219impl WDT_R {
220    pub(crate) fn new(bits: bool) -> Self {
221        WDT_R(crate::FieldReader::new(bits))
222    }
223    #[doc = r"Get enumerated values variant"]
224    #[inline(always)]
225    pub fn variant(&self) -> WDT_A {
226        match self.bits {
227            false => WDT_A::WDT_0,
228            true => WDT_A::WDT_1,
229        }
230    }
231    #[doc = "Checks if the value of the field is `WDT_0`"]
232    #[inline(always)]
233    pub fn is_wdt_0(&self) -> bool {
234        **self == WDT_A::WDT_0
235    }
236    #[doc = "Checks if the value of the field is `WDT_1`"]
237    #[inline(always)]
238    pub fn is_wdt_1(&self) -> bool {
239        **self == WDT_A::WDT_1
240    }
241}
242impl core::ops::Deref for WDT_R {
243    type Target = crate::FieldReader<bool, WDT_A>;
244    #[inline(always)]
245    fn deref(&self) -> &Self::Target {
246        &self.0
247    }
248}
249#[doc = "Field `WDT` writer - Status of the Watchdog reset."]
250pub struct WDT_W<'a> {
251    w: &'a mut W,
252}
253impl<'a> WDT_W<'a> {
254    #[doc = r"Writes `variant` to the field"]
255    #[inline(always)]
256    pub fn variant(self, variant: WDT_A) -> &'a mut W {
257        self.bit(variant.into())
258    }
259    #[doc = "No WDT reset detected."]
260    #[inline(always)]
261    pub fn wdt_0(self) -> &'a mut W {
262        self.variant(WDT_A::WDT_0)
263    }
264    #[doc = "WDT reset detected. Writing a one clears this reset."]
265    #[inline(always)]
266    pub fn wdt_1(self) -> &'a mut W {
267        self.variant(WDT_A::WDT_1)
268    }
269    #[doc = r"Sets the field bit"]
270    #[inline(always)]
271    pub fn set_bit(self) -> &'a mut W {
272        self.bit(true)
273    }
274    #[doc = r"Clears the field bit"]
275    #[inline(always)]
276    pub fn clear_bit(self) -> &'a mut W {
277        self.bit(false)
278    }
279    #[doc = r"Writes raw bits to the field"]
280    #[inline(always)]
281    pub fn bit(self, value: bool) -> &'a mut W {
282        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
283        self.w
284    }
285}
286#[doc = "Status of the Brown-out detect reset.\n\nValue on reset: 0"]
287#[derive(Clone, Copy, Debug, PartialEq)]
288pub enum BOD_A {
289    #[doc = "0: No BOD reset detected."]
290    BOD_0 = 0,
291    #[doc = "1: BOD reset detected. Writing a one clears this reset."]
292    BOD_1 = 1,
293}
294impl From<BOD_A> for bool {
295    #[inline(always)]
296    fn from(variant: BOD_A) -> Self {
297        variant as u8 != 0
298    }
299}
300#[doc = "Field `BOD` reader - Status of the Brown-out detect reset."]
301pub struct BOD_R(crate::FieldReader<bool, BOD_A>);
302impl BOD_R {
303    pub(crate) fn new(bits: bool) -> Self {
304        BOD_R(crate::FieldReader::new(bits))
305    }
306    #[doc = r"Get enumerated values variant"]
307    #[inline(always)]
308    pub fn variant(&self) -> BOD_A {
309        match self.bits {
310            false => BOD_A::BOD_0,
311            true => BOD_A::BOD_1,
312        }
313    }
314    #[doc = "Checks if the value of the field is `BOD_0`"]
315    #[inline(always)]
316    pub fn is_bod_0(&self) -> bool {
317        **self == BOD_A::BOD_0
318    }
319    #[doc = "Checks if the value of the field is `BOD_1`"]
320    #[inline(always)]
321    pub fn is_bod_1(&self) -> bool {
322        **self == BOD_A::BOD_1
323    }
324}
325impl core::ops::Deref for BOD_R {
326    type Target = crate::FieldReader<bool, BOD_A>;
327    #[inline(always)]
328    fn deref(&self) -> &Self::Target {
329        &self.0
330    }
331}
332#[doc = "Field `BOD` writer - Status of the Brown-out detect reset."]
333pub struct BOD_W<'a> {
334    w: &'a mut W,
335}
336impl<'a> BOD_W<'a> {
337    #[doc = r"Writes `variant` to the field"]
338    #[inline(always)]
339    pub fn variant(self, variant: BOD_A) -> &'a mut W {
340        self.bit(variant.into())
341    }
342    #[doc = "No BOD reset detected."]
343    #[inline(always)]
344    pub fn bod_0(self) -> &'a mut W {
345        self.variant(BOD_A::BOD_0)
346    }
347    #[doc = "BOD reset detected. Writing a one clears this reset."]
348    #[inline(always)]
349    pub fn bod_1(self) -> &'a mut W {
350        self.variant(BOD_A::BOD_1)
351    }
352    #[doc = r"Sets the field bit"]
353    #[inline(always)]
354    pub fn set_bit(self) -> &'a mut W {
355        self.bit(true)
356    }
357    #[doc = r"Clears the field bit"]
358    #[inline(always)]
359    pub fn clear_bit(self) -> &'a mut W {
360        self.bit(false)
361    }
362    #[doc = r"Writes raw bits to the field"]
363    #[inline(always)]
364    pub fn bit(self, value: bool) -> &'a mut W {
365        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
366        self.w
367    }
368}
369#[doc = "Status of the software system reset.\n\nValue on reset: 0"]
370#[derive(Clone, Copy, Debug, PartialEq)]
371pub enum SYSRST_A {
372    #[doc = "0: No System reset detected."]
373    SYSRST_0 = 0,
374    #[doc = "1: System reset detected. Writing a one clears this reset."]
375    SYSRST_1 = 1,
376}
377impl From<SYSRST_A> for bool {
378    #[inline(always)]
379    fn from(variant: SYSRST_A) -> Self {
380        variant as u8 != 0
381    }
382}
383#[doc = "Field `SYSRST` reader - Status of the software system reset."]
384pub struct SYSRST_R(crate::FieldReader<bool, SYSRST_A>);
385impl SYSRST_R {
386    pub(crate) fn new(bits: bool) -> Self {
387        SYSRST_R(crate::FieldReader::new(bits))
388    }
389    #[doc = r"Get enumerated values variant"]
390    #[inline(always)]
391    pub fn variant(&self) -> SYSRST_A {
392        match self.bits {
393            false => SYSRST_A::SYSRST_0,
394            true => SYSRST_A::SYSRST_1,
395        }
396    }
397    #[doc = "Checks if the value of the field is `SYSRST_0`"]
398    #[inline(always)]
399    pub fn is_sysrst_0(&self) -> bool {
400        **self == SYSRST_A::SYSRST_0
401    }
402    #[doc = "Checks if the value of the field is `SYSRST_1`"]
403    #[inline(always)]
404    pub fn is_sysrst_1(&self) -> bool {
405        **self == SYSRST_A::SYSRST_1
406    }
407}
408impl core::ops::Deref for SYSRST_R {
409    type Target = crate::FieldReader<bool, SYSRST_A>;
410    #[inline(always)]
411    fn deref(&self) -> &Self::Target {
412        &self.0
413    }
414}
415#[doc = "Field `SYSRST` writer - Status of the software system reset."]
416pub struct SYSRST_W<'a> {
417    w: &'a mut W,
418}
419impl<'a> SYSRST_W<'a> {
420    #[doc = r"Writes `variant` to the field"]
421    #[inline(always)]
422    pub fn variant(self, variant: SYSRST_A) -> &'a mut W {
423        self.bit(variant.into())
424    }
425    #[doc = "No System reset detected."]
426    #[inline(always)]
427    pub fn sysrst_0(self) -> &'a mut W {
428        self.variant(SYSRST_A::SYSRST_0)
429    }
430    #[doc = "System reset detected. Writing a one clears this reset."]
431    #[inline(always)]
432    pub fn sysrst_1(self) -> &'a mut W {
433        self.variant(SYSRST_A::SYSRST_1)
434    }
435    #[doc = r"Sets the field bit"]
436    #[inline(always)]
437    pub fn set_bit(self) -> &'a mut W {
438        self.bit(true)
439    }
440    #[doc = r"Clears the field bit"]
441    #[inline(always)]
442    pub fn clear_bit(self) -> &'a mut W {
443        self.bit(false)
444    }
445    #[doc = r"Writes raw bits to the field"]
446    #[inline(always)]
447    pub fn bit(self, value: bool) -> &'a mut W {
448        self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
449        self.w
450    }
451}
452impl R {
453    #[doc = "Bit 0 - POR reset status."]
454    #[inline(always)]
455    pub fn por(&self) -> POR_R {
456        POR_R::new((self.bits & 0x01) != 0)
457    }
458    #[doc = "Bit 1 - Status of the external RESET pin. External reset status."]
459    #[inline(always)]
460    pub fn extrst(&self) -> EXTRST_R {
461        EXTRST_R::new(((self.bits >> 1) & 0x01) != 0)
462    }
463    #[doc = "Bit 2 - Status of the Watchdog reset."]
464    #[inline(always)]
465    pub fn wdt(&self) -> WDT_R {
466        WDT_R::new(((self.bits >> 2) & 0x01) != 0)
467    }
468    #[doc = "Bit 3 - Status of the Brown-out detect reset."]
469    #[inline(always)]
470    pub fn bod(&self) -> BOD_R {
471        BOD_R::new(((self.bits >> 3) & 0x01) != 0)
472    }
473    #[doc = "Bit 4 - Status of the software system reset."]
474    #[inline(always)]
475    pub fn sysrst(&self) -> SYSRST_R {
476        SYSRST_R::new(((self.bits >> 4) & 0x01) != 0)
477    }
478}
479impl W {
480    #[doc = "Bit 0 - POR reset status."]
481    #[inline(always)]
482    pub fn por(&mut self) -> POR_W {
483        POR_W { w: self }
484    }
485    #[doc = "Bit 1 - Status of the external RESET pin. External reset status."]
486    #[inline(always)]
487    pub fn extrst(&mut self) -> EXTRST_W {
488        EXTRST_W { w: self }
489    }
490    #[doc = "Bit 2 - Status of the Watchdog reset."]
491    #[inline(always)]
492    pub fn wdt(&mut self) -> WDT_W {
493        WDT_W { w: self }
494    }
495    #[doc = "Bit 3 - Status of the Brown-out detect reset."]
496    #[inline(always)]
497    pub fn bod(&mut self) -> BOD_W {
498        BOD_W { w: self }
499    }
500    #[doc = "Bit 4 - Status of the software system reset."]
501    #[inline(always)]
502    pub fn sysrst(&mut self) -> SYSRST_W {
503        SYSRST_W { w: self }
504    }
505    #[doc = "Writes raw bits to the register."]
506    #[inline(always)]
507    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
508        self.0.bits(bits);
509        self
510    }
511}
512#[doc = "System reset status 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 [sysrststat](index.html) module"]
513pub struct SYSRSTSTAT_SPEC;
514impl crate::RegisterSpec for SYSRSTSTAT_SPEC {
515    type Ux = u32;
516}
517#[doc = "`read()` method returns [sysrststat::R](R) reader structure"]
518impl crate::Readable for SYSRSTSTAT_SPEC {
519    type Reader = R;
520}
521#[doc = "`write(|w| ..)` method takes [sysrststat::W](W) writer structure"]
522impl crate::Writable for SYSRSTSTAT_SPEC {
523    type Writer = W;
524}
525#[doc = "`reset()` method sets SYSRSTSTAT to value 0"]
526impl crate::Resettable for SYSRSTSTAT_SPEC {
527    #[inline(always)]
528    fn reset_value() -> Self::Ux {
529        0
530    }
531}