lpc82x_pac/syscon/
pdsleepcfg.rs

1#[doc = "Register `PDSLEEPCFG` reader"]
2pub struct R(crate::R<PDSLEEPCFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PDSLEEPCFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PDSLEEPCFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PDSLEEPCFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PDSLEEPCFG` writer"]
17pub struct W(crate::W<PDSLEEPCFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PDSLEEPCFG_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<PDSLEEPCFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PDSLEEPCFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "BOD power-down control for Deep-sleep and Power-down mode\n\nValue on reset: 1"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum BOD_PD_A {
40    #[doc = "0: powered"]
41    POWERED = 0,
42    #[doc = "1: powered down"]
43    POWERED_DOWN = 1,
44}
45impl From<BOD_PD_A> for bool {
46    #[inline(always)]
47    fn from(variant: BOD_PD_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `BOD_PD` reader - BOD power-down control for Deep-sleep and Power-down mode"]
52pub struct BOD_PD_R(crate::FieldReader<bool, BOD_PD_A>);
53impl BOD_PD_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        BOD_PD_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> BOD_PD_A {
60        match self.bits {
61            false => BOD_PD_A::POWERED,
62            true => BOD_PD_A::POWERED_DOWN,
63        }
64    }
65    #[doc = "Checks if the value of the field is `POWERED`"]
66    #[inline(always)]
67    pub fn is_powered(&self) -> bool {
68        **self == BOD_PD_A::POWERED
69    }
70    #[doc = "Checks if the value of the field is `POWERED_DOWN`"]
71    #[inline(always)]
72    pub fn is_powered_down(&self) -> bool {
73        **self == BOD_PD_A::POWERED_DOWN
74    }
75}
76impl core::ops::Deref for BOD_PD_R {
77    type Target = crate::FieldReader<bool, BOD_PD_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `BOD_PD` writer - BOD power-down control for Deep-sleep and Power-down mode"]
84pub struct BOD_PD_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> BOD_PD_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: BOD_PD_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "powered"]
94    #[inline(always)]
95    pub fn powered(self) -> &'a mut W {
96        self.variant(BOD_PD_A::POWERED)
97    }
98    #[doc = "powered down"]
99    #[inline(always)]
100    pub fn powered_down(self) -> &'a mut W {
101        self.variant(BOD_PD_A::POWERED_DOWN)
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 << 3)) | ((value as u32 & 0x01) << 3);
117        self.w
118    }
119}
120#[doc = "Watchdog oscillator power-down control for Deep-sleep and Power-down mode. Changing this bit to powered-down has no effect when the LOCK bit in the WWDT MOD register is set. In this case, the watchdog oscillator is always running.\n\nValue on reset: 1"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum WDTOSC_PD_A {
123    #[doc = "0: Disabled"]
124    DISABLED = 0,
125    #[doc = "1: Enabled"]
126    ENABLED = 1,
127}
128impl From<WDTOSC_PD_A> for bool {
129    #[inline(always)]
130    fn from(variant: WDTOSC_PD_A) -> Self {
131        variant as u8 != 0
132    }
133}
134#[doc = "Field `WDTOSC_PD` reader - Watchdog oscillator power-down control for Deep-sleep and Power-down mode. Changing this bit to powered-down has no effect when the LOCK bit in the WWDT MOD register is set. In this case, the watchdog oscillator is always running."]
135pub struct WDTOSC_PD_R(crate::FieldReader<bool, WDTOSC_PD_A>);
136impl WDTOSC_PD_R {
137    pub(crate) fn new(bits: bool) -> Self {
138        WDTOSC_PD_R(crate::FieldReader::new(bits))
139    }
140    #[doc = r"Get enumerated values variant"]
141    #[inline(always)]
142    pub fn variant(&self) -> WDTOSC_PD_A {
143        match self.bits {
144            false => WDTOSC_PD_A::DISABLED,
145            true => WDTOSC_PD_A::ENABLED,
146        }
147    }
148    #[doc = "Checks if the value of the field is `DISABLED`"]
149    #[inline(always)]
150    pub fn is_disabled(&self) -> bool {
151        **self == WDTOSC_PD_A::DISABLED
152    }
153    #[doc = "Checks if the value of the field is `ENABLED`"]
154    #[inline(always)]
155    pub fn is_enabled(&self) -> bool {
156        **self == WDTOSC_PD_A::ENABLED
157    }
158}
159impl core::ops::Deref for WDTOSC_PD_R {
160    type Target = crate::FieldReader<bool, WDTOSC_PD_A>;
161    #[inline(always)]
162    fn deref(&self) -> &Self::Target {
163        &self.0
164    }
165}
166#[doc = "Field `WDTOSC_PD` writer - Watchdog oscillator power-down control for Deep-sleep and Power-down mode. Changing this bit to powered-down has no effect when the LOCK bit in the WWDT MOD register is set. In this case, the watchdog oscillator is always running."]
167pub struct WDTOSC_PD_W<'a> {
168    w: &'a mut W,
169}
170impl<'a> WDTOSC_PD_W<'a> {
171    #[doc = r"Writes `variant` to the field"]
172    #[inline(always)]
173    pub fn variant(self, variant: WDTOSC_PD_A) -> &'a mut W {
174        self.bit(variant.into())
175    }
176    #[doc = "Disabled"]
177    #[inline(always)]
178    pub fn disabled(self) -> &'a mut W {
179        self.variant(WDTOSC_PD_A::DISABLED)
180    }
181    #[doc = "Enabled"]
182    #[inline(always)]
183    pub fn enabled(self) -> &'a mut W {
184        self.variant(WDTOSC_PD_A::ENABLED)
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 << 6)) | ((value as u32 & 0x01) << 6);
200        self.w
201    }
202}
203impl R {
204    #[doc = "Bit 3 - BOD power-down control for Deep-sleep and Power-down mode"]
205    #[inline(always)]
206    pub fn bod_pd(&self) -> BOD_PD_R {
207        BOD_PD_R::new(((self.bits >> 3) & 0x01) != 0)
208    }
209    #[doc = "Bit 6 - Watchdog oscillator power-down control for Deep-sleep and Power-down mode. Changing this bit to powered-down has no effect when the LOCK bit in the WWDT MOD register is set. In this case, the watchdog oscillator is always running."]
210    #[inline(always)]
211    pub fn wdtosc_pd(&self) -> WDTOSC_PD_R {
212        WDTOSC_PD_R::new(((self.bits >> 6) & 0x01) != 0)
213    }
214}
215impl W {
216    #[doc = "Bit 3 - BOD power-down control for Deep-sleep and Power-down mode"]
217    #[inline(always)]
218    pub fn bod_pd(&mut self) -> BOD_PD_W {
219        BOD_PD_W { w: self }
220    }
221    #[doc = "Bit 6 - Watchdog oscillator power-down control for Deep-sleep and Power-down mode. Changing this bit to powered-down has no effect when the LOCK bit in the WWDT MOD register is set. In this case, the watchdog oscillator is always running."]
222    #[inline(always)]
223    pub fn wdtosc_pd(&mut self) -> WDTOSC_PD_W {
224        WDTOSC_PD_W { w: self }
225    }
226    #[doc = "Writes raw bits to the register."]
227    #[inline(always)]
228    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
229        self.0.bits(bits);
230        self
231    }
232}
233#[doc = "Deep-sleep configuration 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 [pdsleepcfg](index.html) module"]
234pub struct PDSLEEPCFG_SPEC;
235impl crate::RegisterSpec for PDSLEEPCFG_SPEC {
236    type Ux = u32;
237}
238#[doc = "`read()` method returns [pdsleepcfg::R](R) reader structure"]
239impl crate::Readable for PDSLEEPCFG_SPEC {
240    type Reader = R;
241}
242#[doc = "`write(|w| ..)` method takes [pdsleepcfg::W](W) writer structure"]
243impl crate::Writable for PDSLEEPCFG_SPEC {
244    type Writer = W;
245}
246#[doc = "`reset()` method sets PDSLEEPCFG to value 0xffff"]
247impl crate::Resettable for PDSLEEPCFG_SPEC {
248    #[inline(always)]
249    fn reset_value() -> Self::Ux {
250        0xffff
251    }
252}