stm32f103xx/pwr/cr/
mod.rs1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::CR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct LPDSR {
47    bits: bool,
48}
49impl LPDSR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bit(&self) -> bool {
53        self.bits
54    }
55    #[doc = r" Returns `true` if the bit is clear (0)"]
56    #[inline]
57    pub fn bit_is_clear(&self) -> bool {
58        !self.bit()
59    }
60    #[doc = r" Returns `true` if the bit is set (1)"]
61    #[inline]
62    pub fn bit_is_set(&self) -> bool {
63        self.bit()
64    }
65}
66#[doc = r" Value of the field"]
67pub struct PDDSR {
68    bits: bool,
69}
70impl PDDSR {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bit(&self) -> bool {
74        self.bits
75    }
76    #[doc = r" Returns `true` if the bit is clear (0)"]
77    #[inline]
78    pub fn bit_is_clear(&self) -> bool {
79        !self.bit()
80    }
81    #[doc = r" Returns `true` if the bit is set (1)"]
82    #[inline]
83    pub fn bit_is_set(&self) -> bool {
84        self.bit()
85    }
86}
87#[doc = r" Value of the field"]
88pub struct CWUFR {
89    bits: bool,
90}
91impl CWUFR {
92    #[doc = r" Value of the field as raw bits"]
93    #[inline]
94    pub fn bit(&self) -> bool {
95        self.bits
96    }
97    #[doc = r" Returns `true` if the bit is clear (0)"]
98    #[inline]
99    pub fn bit_is_clear(&self) -> bool {
100        !self.bit()
101    }
102    #[doc = r" Returns `true` if the bit is set (1)"]
103    #[inline]
104    pub fn bit_is_set(&self) -> bool {
105        self.bit()
106    }
107}
108#[doc = r" Value of the field"]
109pub struct CSBFR {
110    bits: bool,
111}
112impl CSBFR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bit(&self) -> bool {
116        self.bits
117    }
118    #[doc = r" Returns `true` if the bit is clear (0)"]
119    #[inline]
120    pub fn bit_is_clear(&self) -> bool {
121        !self.bit()
122    }
123    #[doc = r" Returns `true` if the bit is set (1)"]
124    #[inline]
125    pub fn bit_is_set(&self) -> bool {
126        self.bit()
127    }
128}
129#[doc = r" Value of the field"]
130pub struct PVDER {
131    bits: bool,
132}
133impl PVDER {
134    #[doc = r" Value of the field as raw bits"]
135    #[inline]
136    pub fn bit(&self) -> bool {
137        self.bits
138    }
139    #[doc = r" Returns `true` if the bit is clear (0)"]
140    #[inline]
141    pub fn bit_is_clear(&self) -> bool {
142        !self.bit()
143    }
144    #[doc = r" Returns `true` if the bit is set (1)"]
145    #[inline]
146    pub fn bit_is_set(&self) -> bool {
147        self.bit()
148    }
149}
150#[doc = r" Value of the field"]
151pub struct PLSR {
152    bits: u8,
153}
154impl PLSR {
155    #[doc = r" Value of the field as raw bits"]
156    #[inline]
157    pub fn bits(&self) -> u8 {
158        self.bits
159    }
160}
161#[doc = r" Value of the field"]
162pub struct DBPR {
163    bits: bool,
164}
165impl DBPR {
166    #[doc = r" Value of the field as raw bits"]
167    #[inline]
168    pub fn bit(&self) -> bool {
169        self.bits
170    }
171    #[doc = r" Returns `true` if the bit is clear (0)"]
172    #[inline]
173    pub fn bit_is_clear(&self) -> bool {
174        !self.bit()
175    }
176    #[doc = r" Returns `true` if the bit is set (1)"]
177    #[inline]
178    pub fn bit_is_set(&self) -> bool {
179        self.bit()
180    }
181}
182#[doc = r" Proxy"]
183pub struct _LPDSW<'a> {
184    w: &'a mut W,
185}
186impl<'a> _LPDSW<'a> {
187    #[doc = r" Sets the field bit"]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r" Clears the field bit"]
192    pub fn clear_bit(self) -> &'a mut W {
193        self.bit(false)
194    }
195    #[doc = r" Writes raw bits to the field"]
196    #[inline]
197    pub fn bit(self, value: bool) -> &'a mut W {
198        const MASK: bool = true;
199        const OFFSET: u8 = 0;
200        self.w.bits &= !((MASK as u32) << OFFSET);
201        self.w.bits |= ((value & MASK) as u32) << OFFSET;
202        self.w
203    }
204}
205#[doc = r" Proxy"]
206pub struct _PDDSW<'a> {
207    w: &'a mut W,
208}
209impl<'a> _PDDSW<'a> {
210    #[doc = r" Sets the field bit"]
211    pub fn set_bit(self) -> &'a mut W {
212        self.bit(true)
213    }
214    #[doc = r" Clears the field bit"]
215    pub fn clear_bit(self) -> &'a mut W {
216        self.bit(false)
217    }
218    #[doc = r" Writes raw bits to the field"]
219    #[inline]
220    pub fn bit(self, value: bool) -> &'a mut W {
221        const MASK: bool = true;
222        const OFFSET: u8 = 1;
223        self.w.bits &= !((MASK as u32) << OFFSET);
224        self.w.bits |= ((value & MASK) as u32) << OFFSET;
225        self.w
226    }
227}
228#[doc = r" Proxy"]
229pub struct _CWUFW<'a> {
230    w: &'a mut W,
231}
232impl<'a> _CWUFW<'a> {
233    #[doc = r" Sets the field bit"]
234    pub fn set_bit(self) -> &'a mut W {
235        self.bit(true)
236    }
237    #[doc = r" Clears the field bit"]
238    pub fn clear_bit(self) -> &'a mut W {
239        self.bit(false)
240    }
241    #[doc = r" Writes raw bits to the field"]
242    #[inline]
243    pub fn bit(self, value: bool) -> &'a mut W {
244        const MASK: bool = true;
245        const OFFSET: u8 = 2;
246        self.w.bits &= !((MASK as u32) << OFFSET);
247        self.w.bits |= ((value & MASK) as u32) << OFFSET;
248        self.w
249    }
250}
251#[doc = r" Proxy"]
252pub struct _CSBFW<'a> {
253    w: &'a mut W,
254}
255impl<'a> _CSBFW<'a> {
256    #[doc = r" Sets the field bit"]
257    pub fn set_bit(self) -> &'a mut W {
258        self.bit(true)
259    }
260    #[doc = r" Clears the field bit"]
261    pub fn clear_bit(self) -> &'a mut W {
262        self.bit(false)
263    }
264    #[doc = r" Writes raw bits to the field"]
265    #[inline]
266    pub fn bit(self, value: bool) -> &'a mut W {
267        const MASK: bool = true;
268        const OFFSET: u8 = 3;
269        self.w.bits &= !((MASK as u32) << OFFSET);
270        self.w.bits |= ((value & MASK) as u32) << OFFSET;
271        self.w
272    }
273}
274#[doc = r" Proxy"]
275pub struct _PVDEW<'a> {
276    w: &'a mut W,
277}
278impl<'a> _PVDEW<'a> {
279    #[doc = r" Sets the field bit"]
280    pub fn set_bit(self) -> &'a mut W {
281        self.bit(true)
282    }
283    #[doc = r" Clears the field bit"]
284    pub fn clear_bit(self) -> &'a mut W {
285        self.bit(false)
286    }
287    #[doc = r" Writes raw bits to the field"]
288    #[inline]
289    pub fn bit(self, value: bool) -> &'a mut W {
290        const MASK: bool = true;
291        const OFFSET: u8 = 4;
292        self.w.bits &= !((MASK as u32) << OFFSET);
293        self.w.bits |= ((value & MASK) as u32) << OFFSET;
294        self.w
295    }
296}
297#[doc = r" Proxy"]
298pub struct _PLSW<'a> {
299    w: &'a mut W,
300}
301impl<'a> _PLSW<'a> {
302    #[doc = r" Writes raw bits to the field"]
303    #[inline]
304    pub unsafe fn bits(self, value: u8) -> &'a mut W {
305        const MASK: u8 = 7;
306        const OFFSET: u8 = 5;
307        self.w.bits &= !((MASK as u32) << OFFSET);
308        self.w.bits |= ((value & MASK) as u32) << OFFSET;
309        self.w
310    }
311}
312#[doc = r" Proxy"]
313pub struct _DBPW<'a> {
314    w: &'a mut W,
315}
316impl<'a> _DBPW<'a> {
317    #[doc = r" Sets the field bit"]
318    pub fn set_bit(self) -> &'a mut W {
319        self.bit(true)
320    }
321    #[doc = r" Clears the field bit"]
322    pub fn clear_bit(self) -> &'a mut W {
323        self.bit(false)
324    }
325    #[doc = r" Writes raw bits to the field"]
326    #[inline]
327    pub fn bit(self, value: bool) -> &'a mut W {
328        const MASK: bool = true;
329        const OFFSET: u8 = 8;
330        self.w.bits &= !((MASK as u32) << OFFSET);
331        self.w.bits |= ((value & MASK) as u32) << OFFSET;
332        self.w
333    }
334}
335impl R {
336    #[doc = r" Value of the register as raw bits"]
337    #[inline]
338    pub fn bits(&self) -> u32 {
339        self.bits
340    }
341    #[doc = "Bit 0 - Low Power Deep Sleep"]
342    #[inline]
343    pub fn lpds(&self) -> LPDSR {
344        let bits = {
345            const MASK: bool = true;
346            const OFFSET: u8 = 0;
347            ((self.bits >> OFFSET) & MASK as u32) != 0
348        };
349        LPDSR { bits }
350    }
351    #[doc = "Bit 1 - Power Down Deep Sleep"]
352    #[inline]
353    pub fn pdds(&self) -> PDDSR {
354        let bits = {
355            const MASK: bool = true;
356            const OFFSET: u8 = 1;
357            ((self.bits >> OFFSET) & MASK as u32) != 0
358        };
359        PDDSR { bits }
360    }
361    #[doc = "Bit 2 - Clear Wake-up Flag"]
362    #[inline]
363    pub fn cwuf(&self) -> CWUFR {
364        let bits = {
365            const MASK: bool = true;
366            const OFFSET: u8 = 2;
367            ((self.bits >> OFFSET) & MASK as u32) != 0
368        };
369        CWUFR { bits }
370    }
371    #[doc = "Bit 3 - Clear STANDBY Flag"]
372    #[inline]
373    pub fn csbf(&self) -> CSBFR {
374        let bits = {
375            const MASK: bool = true;
376            const OFFSET: u8 = 3;
377            ((self.bits >> OFFSET) & MASK as u32) != 0
378        };
379        CSBFR { bits }
380    }
381    #[doc = "Bit 4 - Power Voltage Detector Enable"]
382    #[inline]
383    pub fn pvde(&self) -> PVDER {
384        let bits = {
385            const MASK: bool = true;
386            const OFFSET: u8 = 4;
387            ((self.bits >> OFFSET) & MASK as u32) != 0
388        };
389        PVDER { bits }
390    }
391    #[doc = "Bits 5:7 - PVD Level Selection"]
392    #[inline]
393    pub fn pls(&self) -> PLSR {
394        let bits = {
395            const MASK: u8 = 7;
396            const OFFSET: u8 = 5;
397            ((self.bits >> OFFSET) & MASK as u32) as u8
398        };
399        PLSR { bits }
400    }
401    #[doc = "Bit 8 - Disable Backup Domain write protection"]
402    #[inline]
403    pub fn dbp(&self) -> DBPR {
404        let bits = {
405            const MASK: bool = true;
406            const OFFSET: u8 = 8;
407            ((self.bits >> OFFSET) & MASK as u32) != 0
408        };
409        DBPR { bits }
410    }
411}
412impl W {
413    #[doc = r" Reset value of the register"]
414    #[inline]
415    pub fn reset_value() -> W {
416        W { bits: 0 }
417    }
418    #[doc = r" Writes raw bits to the register"]
419    #[inline]
420    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
421        self.bits = bits;
422        self
423    }
424    #[doc = "Bit 0 - Low Power Deep Sleep"]
425    #[inline]
426    pub fn lpds(&mut self) -> _LPDSW {
427        _LPDSW { w: self }
428    }
429    #[doc = "Bit 1 - Power Down Deep Sleep"]
430    #[inline]
431    pub fn pdds(&mut self) -> _PDDSW {
432        _PDDSW { w: self }
433    }
434    #[doc = "Bit 2 - Clear Wake-up Flag"]
435    #[inline]
436    pub fn cwuf(&mut self) -> _CWUFW {
437        _CWUFW { w: self }
438    }
439    #[doc = "Bit 3 - Clear STANDBY Flag"]
440    #[inline]
441    pub fn csbf(&mut self) -> _CSBFW {
442        _CSBFW { w: self }
443    }
444    #[doc = "Bit 4 - Power Voltage Detector Enable"]
445    #[inline]
446    pub fn pvde(&mut self) -> _PVDEW {
447        _PVDEW { w: self }
448    }
449    #[doc = "Bits 5:7 - PVD Level Selection"]
450    #[inline]
451    pub fn pls(&mut self) -> _PLSW {
452        _PLSW { w: self }
453    }
454    #[doc = "Bit 8 - Disable Backup Domain write protection"]
455    #[inline]
456    pub fn dbp(&mut self) -> _DBPW {
457        _DBPW { w: self }
458    }
459}