1#[doc = "Register `PCON` reader"]
2pub struct R(crate::R<PCON_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PCON_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PCON_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PCON_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PCON` writer"]
17pub struct W(crate::W<PCON_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PCON_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<PCON_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PCON_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Power mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum PM_A {
41 #[doc = "0: Default. The part is in active or sleep mode."]
42 DEFAULT = 0,
43 #[doc = "1: Deep-sleep mode. ARM WFI will enter Deep-sleep mode."]
44 DEEP_SLEEP_MODE = 1,
45 #[doc = "2: Power-down mode. ARM WFI will enter Power-down mode."]
46 POWER_DOWN_MODE = 2,
47 #[doc = "3: Deep power-down mode. ARM WFI will enter Deep-power down mode (ARM Cortex-M0+ core powered-down)."]
48 DEEP_POWER_DOWN_MODE = 3,
49}
50impl From<PM_A> for u8 {
51 #[inline(always)]
52 fn from(variant: PM_A) -> Self {
53 variant as _
54 }
55}
56#[doc = "Field `PM` reader - Power mode"]
57pub struct PM_R(crate::FieldReader<u8, PM_A>);
58impl PM_R {
59 pub(crate) fn new(bits: u8) -> Self {
60 PM_R(crate::FieldReader::new(bits))
61 }
62 #[doc = r"Get enumerated values variant"]
63 #[inline(always)]
64 pub fn variant(&self) -> Option<PM_A> {
65 match self.bits {
66 0 => Some(PM_A::DEFAULT),
67 1 => Some(PM_A::DEEP_SLEEP_MODE),
68 2 => Some(PM_A::POWER_DOWN_MODE),
69 3 => Some(PM_A::DEEP_POWER_DOWN_MODE),
70 _ => None,
71 }
72 }
73 #[doc = "Checks if the value of the field is `DEFAULT`"]
74 #[inline(always)]
75 pub fn is_default(&self) -> bool {
76 **self == PM_A::DEFAULT
77 }
78 #[doc = "Checks if the value of the field is `DEEP_SLEEP_MODE`"]
79 #[inline(always)]
80 pub fn is_deep_sleep_mode(&self) -> bool {
81 **self == PM_A::DEEP_SLEEP_MODE
82 }
83 #[doc = "Checks if the value of the field is `POWER_DOWN_MODE`"]
84 #[inline(always)]
85 pub fn is_power_down_mode(&self) -> bool {
86 **self == PM_A::POWER_DOWN_MODE
87 }
88 #[doc = "Checks if the value of the field is `DEEP_POWER_DOWN_MODE`"]
89 #[inline(always)]
90 pub fn is_deep_power_down_mode(&self) -> bool {
91 **self == PM_A::DEEP_POWER_DOWN_MODE
92 }
93}
94impl core::ops::Deref for PM_R {
95 type Target = crate::FieldReader<u8, PM_A>;
96 #[inline(always)]
97 fn deref(&self) -> &Self::Target {
98 &self.0
99 }
100}
101#[doc = "Field `PM` writer - Power mode"]
102pub struct PM_W<'a> {
103 w: &'a mut W,
104}
105impl<'a> PM_W<'a> {
106 #[doc = r"Writes `variant` to the field"]
107 #[inline(always)]
108 pub fn variant(self, variant: PM_A) -> &'a mut W {
109 unsafe { self.bits(variant.into()) }
110 }
111 #[doc = "Default. The part is in active or sleep mode."]
112 #[inline(always)]
113 pub fn default(self) -> &'a mut W {
114 self.variant(PM_A::DEFAULT)
115 }
116 #[doc = "Deep-sleep mode. ARM WFI will enter Deep-sleep mode."]
117 #[inline(always)]
118 pub fn deep_sleep_mode(self) -> &'a mut W {
119 self.variant(PM_A::DEEP_SLEEP_MODE)
120 }
121 #[doc = "Power-down mode. ARM WFI will enter Power-down mode."]
122 #[inline(always)]
123 pub fn power_down_mode(self) -> &'a mut W {
124 self.variant(PM_A::POWER_DOWN_MODE)
125 }
126 #[doc = "Deep power-down mode. ARM WFI will enter Deep-power down mode (ARM Cortex-M0+ core powered-down)."]
127 #[inline(always)]
128 pub fn deep_power_down_mode(self) -> &'a mut W {
129 self.variant(PM_A::DEEP_POWER_DOWN_MODE)
130 }
131 #[doc = r"Writes raw bits to the field"]
132 #[inline(always)]
133 pub unsafe fn bits(self, value: u8) -> &'a mut W {
134 self.w.bits = (self.w.bits & !0x07) | (value as u32 & 0x07);
135 self.w
136 }
137}
138#[doc = "Field `NODPD` reader - A 1 in this bit prevents entry to Deep power-down mode when 0x3 is written to the PM field above, the SLEEPDEEP bit is set, and a WFI is executed. This bit is cleared only by power-on reset, so writing a one to this bit locks the part in a mode in which Deep power-down mode is blocked."]
139pub struct NODPD_R(crate::FieldReader<bool, bool>);
140impl NODPD_R {
141 pub(crate) fn new(bits: bool) -> Self {
142 NODPD_R(crate::FieldReader::new(bits))
143 }
144}
145impl core::ops::Deref for NODPD_R {
146 type Target = crate::FieldReader<bool, bool>;
147 #[inline(always)]
148 fn deref(&self) -> &Self::Target {
149 &self.0
150 }
151}
152#[doc = "Field `NODPD` writer - A 1 in this bit prevents entry to Deep power-down mode when 0x3 is written to the PM field above, the SLEEPDEEP bit is set, and a WFI is executed. This bit is cleared only by power-on reset, so writing a one to this bit locks the part in a mode in which Deep power-down mode is blocked."]
153pub struct NODPD_W<'a> {
154 w: &'a mut W,
155}
156impl<'a> NODPD_W<'a> {
157 #[doc = r"Sets the field bit"]
158 #[inline(always)]
159 pub fn set_bit(self) -> &'a mut W {
160 self.bit(true)
161 }
162 #[doc = r"Clears the field bit"]
163 #[inline(always)]
164 pub fn clear_bit(self) -> &'a mut W {
165 self.bit(false)
166 }
167 #[doc = r"Writes raw bits to the field"]
168 #[inline(always)]
169 pub fn bit(self, value: bool) -> &'a mut W {
170 self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
171 self.w
172 }
173}
174#[doc = "Sleep mode flag\n\nValue on reset: 0"]
175#[derive(Clone, Copy, Debug, PartialEq)]
176pub enum SLEEPFLAG_A {
177 #[doc = "0: Active mode. Read: No power-down mode entered. Part is in Active mode. Write: No effect."]
178 ACTIVE_MODE = 0,
179 #[doc = "1: Low power mode. Read: Sleep, Deep-sleep or Power-down mode entered. Write: Writing a 1 clears the SLEEPFLAG bit to 0."]
180 LOW_POWER_MODE = 1,
181}
182impl From<SLEEPFLAG_A> for bool {
183 #[inline(always)]
184 fn from(variant: SLEEPFLAG_A) -> Self {
185 variant as u8 != 0
186 }
187}
188#[doc = "Field `SLEEPFLAG` reader - Sleep mode flag"]
189pub struct SLEEPFLAG_R(crate::FieldReader<bool, SLEEPFLAG_A>);
190impl SLEEPFLAG_R {
191 pub(crate) fn new(bits: bool) -> Self {
192 SLEEPFLAG_R(crate::FieldReader::new(bits))
193 }
194 #[doc = r"Get enumerated values variant"]
195 #[inline(always)]
196 pub fn variant(&self) -> SLEEPFLAG_A {
197 match self.bits {
198 false => SLEEPFLAG_A::ACTIVE_MODE,
199 true => SLEEPFLAG_A::LOW_POWER_MODE,
200 }
201 }
202 #[doc = "Checks if the value of the field is `ACTIVE_MODE`"]
203 #[inline(always)]
204 pub fn is_active_mode(&self) -> bool {
205 **self == SLEEPFLAG_A::ACTIVE_MODE
206 }
207 #[doc = "Checks if the value of the field is `LOW_POWER_MODE`"]
208 #[inline(always)]
209 pub fn is_low_power_mode(&self) -> bool {
210 **self == SLEEPFLAG_A::LOW_POWER_MODE
211 }
212}
213impl core::ops::Deref for SLEEPFLAG_R {
214 type Target = crate::FieldReader<bool, SLEEPFLAG_A>;
215 #[inline(always)]
216 fn deref(&self) -> &Self::Target {
217 &self.0
218 }
219}
220#[doc = "Field `SLEEPFLAG` writer - Sleep mode flag"]
221pub struct SLEEPFLAG_W<'a> {
222 w: &'a mut W,
223}
224impl<'a> SLEEPFLAG_W<'a> {
225 #[doc = r"Writes `variant` to the field"]
226 #[inline(always)]
227 pub fn variant(self, variant: SLEEPFLAG_A) -> &'a mut W {
228 self.bit(variant.into())
229 }
230 #[doc = "Active mode. Read: No power-down mode entered. Part is in Active mode. Write: No effect."]
231 #[inline(always)]
232 pub fn active_mode(self) -> &'a mut W {
233 self.variant(SLEEPFLAG_A::ACTIVE_MODE)
234 }
235 #[doc = "Low power mode. Read: Sleep, Deep-sleep or Power-down mode entered. Write: Writing a 1 clears the SLEEPFLAG bit to 0."]
236 #[inline(always)]
237 pub fn low_power_mode(self) -> &'a mut W {
238 self.variant(SLEEPFLAG_A::LOW_POWER_MODE)
239 }
240 #[doc = r"Sets the field bit"]
241 #[inline(always)]
242 pub fn set_bit(self) -> &'a mut W {
243 self.bit(true)
244 }
245 #[doc = r"Clears the field bit"]
246 #[inline(always)]
247 pub fn clear_bit(self) -> &'a mut W {
248 self.bit(false)
249 }
250 #[doc = r"Writes raw bits to the field"]
251 #[inline(always)]
252 pub fn bit(self, value: bool) -> &'a mut W {
253 self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
254 self.w
255 }
256}
257#[doc = "Deep power-down flag\n\nValue on reset: 0"]
258#[derive(Clone, Copy, Debug, PartialEq)]
259pub enum DPDFLAG_A {
260 #[doc = "0: Not Deep power-down. Read: Deep power-down mode not entered. Write: No effect."]
261 NOT_DEEP_POWER_DOWN = 0,
262 #[doc = "1: Deep power-down. Read: Deep power-down mode entered. Write: Clear the Deep power-down flag."]
263 DEEP_POWER_DOWN = 1,
264}
265impl From<DPDFLAG_A> for bool {
266 #[inline(always)]
267 fn from(variant: DPDFLAG_A) -> Self {
268 variant as u8 != 0
269 }
270}
271#[doc = "Field `DPDFLAG` reader - Deep power-down flag"]
272pub struct DPDFLAG_R(crate::FieldReader<bool, DPDFLAG_A>);
273impl DPDFLAG_R {
274 pub(crate) fn new(bits: bool) -> Self {
275 DPDFLAG_R(crate::FieldReader::new(bits))
276 }
277 #[doc = r"Get enumerated values variant"]
278 #[inline(always)]
279 pub fn variant(&self) -> DPDFLAG_A {
280 match self.bits {
281 false => DPDFLAG_A::NOT_DEEP_POWER_DOWN,
282 true => DPDFLAG_A::DEEP_POWER_DOWN,
283 }
284 }
285 #[doc = "Checks if the value of the field is `NOT_DEEP_POWER_DOWN`"]
286 #[inline(always)]
287 pub fn is_not_deep_power_down(&self) -> bool {
288 **self == DPDFLAG_A::NOT_DEEP_POWER_DOWN
289 }
290 #[doc = "Checks if the value of the field is `DEEP_POWER_DOWN`"]
291 #[inline(always)]
292 pub fn is_deep_power_down(&self) -> bool {
293 **self == DPDFLAG_A::DEEP_POWER_DOWN
294 }
295}
296impl core::ops::Deref for DPDFLAG_R {
297 type Target = crate::FieldReader<bool, DPDFLAG_A>;
298 #[inline(always)]
299 fn deref(&self) -> &Self::Target {
300 &self.0
301 }
302}
303#[doc = "Field `DPDFLAG` writer - Deep power-down flag"]
304pub struct DPDFLAG_W<'a> {
305 w: &'a mut W,
306}
307impl<'a> DPDFLAG_W<'a> {
308 #[doc = r"Writes `variant` to the field"]
309 #[inline(always)]
310 pub fn variant(self, variant: DPDFLAG_A) -> &'a mut W {
311 self.bit(variant.into())
312 }
313 #[doc = "Not Deep power-down. Read: Deep power-down mode not entered. Write: No effect."]
314 #[inline(always)]
315 pub fn not_deep_power_down(self) -> &'a mut W {
316 self.variant(DPDFLAG_A::NOT_DEEP_POWER_DOWN)
317 }
318 #[doc = "Deep power-down. Read: Deep power-down mode entered. Write: Clear the Deep power-down flag."]
319 #[inline(always)]
320 pub fn deep_power_down(self) -> &'a mut W {
321 self.variant(DPDFLAG_A::DEEP_POWER_DOWN)
322 }
323 #[doc = r"Sets the field bit"]
324 #[inline(always)]
325 pub fn set_bit(self) -> &'a mut W {
326 self.bit(true)
327 }
328 #[doc = r"Clears the field bit"]
329 #[inline(always)]
330 pub fn clear_bit(self) -> &'a mut W {
331 self.bit(false)
332 }
333 #[doc = r"Writes raw bits to the field"]
334 #[inline(always)]
335 pub fn bit(self, value: bool) -> &'a mut W {
336 self.w.bits = (self.w.bits & !(0x01 << 11)) | ((value as u32 & 0x01) << 11);
337 self.w
338 }
339}
340impl R {
341 #[doc = "Bits 0:2 - Power mode"]
342 #[inline(always)]
343 pub fn pm(&self) -> PM_R {
344 PM_R::new((self.bits & 0x07) as u8)
345 }
346 #[doc = "Bit 3 - A 1 in this bit prevents entry to Deep power-down mode when 0x3 is written to the PM field above, the SLEEPDEEP bit is set, and a WFI is executed. This bit is cleared only by power-on reset, so writing a one to this bit locks the part in a mode in which Deep power-down mode is blocked."]
347 #[inline(always)]
348 pub fn nodpd(&self) -> NODPD_R {
349 NODPD_R::new(((self.bits >> 3) & 0x01) != 0)
350 }
351 #[doc = "Bit 8 - Sleep mode flag"]
352 #[inline(always)]
353 pub fn sleepflag(&self) -> SLEEPFLAG_R {
354 SLEEPFLAG_R::new(((self.bits >> 8) & 0x01) != 0)
355 }
356 #[doc = "Bit 11 - Deep power-down flag"]
357 #[inline(always)]
358 pub fn dpdflag(&self) -> DPDFLAG_R {
359 DPDFLAG_R::new(((self.bits >> 11) & 0x01) != 0)
360 }
361}
362impl W {
363 #[doc = "Bits 0:2 - Power mode"]
364 #[inline(always)]
365 pub fn pm(&mut self) -> PM_W {
366 PM_W { w: self }
367 }
368 #[doc = "Bit 3 - A 1 in this bit prevents entry to Deep power-down mode when 0x3 is written to the PM field above, the SLEEPDEEP bit is set, and a WFI is executed. This bit is cleared only by power-on reset, so writing a one to this bit locks the part in a mode in which Deep power-down mode is blocked."]
369 #[inline(always)]
370 pub fn nodpd(&mut self) -> NODPD_W {
371 NODPD_W { w: self }
372 }
373 #[doc = "Bit 8 - Sleep mode flag"]
374 #[inline(always)]
375 pub fn sleepflag(&mut self) -> SLEEPFLAG_W {
376 SLEEPFLAG_W { w: self }
377 }
378 #[doc = "Bit 11 - Deep power-down flag"]
379 #[inline(always)]
380 pub fn dpdflag(&mut self) -> DPDFLAG_W {
381 DPDFLAG_W { w: self }
382 }
383 #[doc = "Writes raw bits to the register."]
384 #[inline(always)]
385 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
386 self.0.bits(bits);
387 self
388 }
389}
390#[doc = "Power control 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 [pcon](index.html) module"]
391pub struct PCON_SPEC;
392impl crate::RegisterSpec for PCON_SPEC {
393 type Ux = u32;
394}
395#[doc = "`read()` method returns [pcon::R](R) reader structure"]
396impl crate::Readable for PCON_SPEC {
397 type Reader = R;
398}
399#[doc = "`write(|w| ..)` method takes [pcon::W](W) writer structure"]
400impl crate::Writable for PCON_SPEC {
401 type Writer = W;
402}
403#[doc = "`reset()` method sets PCON to value 0"]
404impl crate::Resettable for PCON_SPEC {
405 #[inline(always)]
406 fn reset_value() -> Self::Ux {
407 0
408 }
409}