stm32wb_pac/pwr/
cr1.rs

1#[doc = "Reader of register CR1"]
2pub type R = crate::R<u32, super::CR1>;
3#[doc = "Writer for register CR1"]
4pub type W = crate::W<u32, super::CR1>;
5#[doc = "Register CR1 `reset()`'s with value 0x0200"]
6impl crate::ResetValue for super::CR1 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x0200
11    }
12}
13#[doc = "Reader of field `LPR`"]
14pub type LPR_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `LPR`"]
16pub struct LPR_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> LPR_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14);
34        self.w
35    }
36}
37#[doc = "Reader of field `VOS`"]
38pub type VOS_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `VOS`"]
40pub struct VOS_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> VOS_W<'a> {
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub unsafe fn bits(self, value: u8) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x03 << 9)) | (((value as u32) & 0x03) << 9);
48        self.w
49    }
50}
51#[doc = "Reader of field `DBP`"]
52pub type DBP_R = crate::R<bool, bool>;
53#[doc = "Write proxy for field `DBP`"]
54pub struct DBP_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> DBP_W<'a> {
58    #[doc = r"Sets the field bit"]
59    #[inline(always)]
60    pub fn set_bit(self) -> &'a mut W {
61        self.bit(true)
62    }
63    #[doc = r"Clears the field bit"]
64    #[inline(always)]
65    pub fn clear_bit(self) -> &'a mut W {
66        self.bit(false)
67    }
68    #[doc = r"Writes raw bits to the field"]
69    #[inline(always)]
70    pub fn bit(self, value: bool) -> &'a mut W {
71        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
72        self.w
73    }
74}
75#[doc = "Reader of field `FPDS`"]
76pub type FPDS_R = crate::R<bool, bool>;
77#[doc = "Write proxy for field `FPDS`"]
78pub struct FPDS_W<'a> {
79    w: &'a mut W,
80}
81impl<'a> FPDS_W<'a> {
82    #[doc = r"Sets the field bit"]
83    #[inline(always)]
84    pub fn set_bit(self) -> &'a mut W {
85        self.bit(true)
86    }
87    #[doc = r"Clears the field bit"]
88    #[inline(always)]
89    pub fn clear_bit(self) -> &'a mut W {
90        self.bit(false)
91    }
92    #[doc = r"Writes raw bits to the field"]
93    #[inline(always)]
94    pub fn bit(self, value: bool) -> &'a mut W {
95        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
96        self.w
97    }
98}
99#[doc = "Reader of field `FPDR`"]
100pub type FPDR_R = crate::R<bool, bool>;
101#[doc = "Write proxy for field `FPDR`"]
102pub struct FPDR_W<'a> {
103    w: &'a mut W,
104}
105impl<'a> FPDR_W<'a> {
106    #[doc = r"Sets the field bit"]
107    #[inline(always)]
108    pub fn set_bit(self) -> &'a mut W {
109        self.bit(true)
110    }
111    #[doc = r"Clears the field bit"]
112    #[inline(always)]
113    pub fn clear_bit(self) -> &'a mut W {
114        self.bit(false)
115    }
116    #[doc = r"Writes raw bits to the field"]
117    #[inline(always)]
118    pub fn bit(self, value: bool) -> &'a mut W {
119        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
120        self.w
121    }
122}
123#[doc = "Reader of field `LPMS`"]
124pub type LPMS_R = crate::R<u8, u8>;
125#[doc = "Write proxy for field `LPMS`"]
126pub struct LPMS_W<'a> {
127    w: &'a mut W,
128}
129impl<'a> LPMS_W<'a> {
130    #[doc = r"Writes raw bits to the field"]
131    #[inline(always)]
132    pub unsafe fn bits(self, value: u8) -> &'a mut W {
133        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
134        self.w
135    }
136}
137impl R {
138    #[doc = "Bit 14 - Low-power run"]
139    #[inline(always)]
140    pub fn lpr(&self) -> LPR_R {
141        LPR_R::new(((self.bits >> 14) & 0x01) != 0)
142    }
143    #[doc = "Bits 9:10 - Voltage scaling range selection"]
144    #[inline(always)]
145    pub fn vos(&self) -> VOS_R {
146        VOS_R::new(((self.bits >> 9) & 0x03) as u8)
147    }
148    #[doc = "Bit 8 - Disable backup domain write protection"]
149    #[inline(always)]
150    pub fn dbp(&self) -> DBP_R {
151        DBP_R::new(((self.bits >> 8) & 0x01) != 0)
152    }
153    #[doc = "Bit 5 - Flash power down mode during LPsSleep for CPU1"]
154    #[inline(always)]
155    pub fn fpds(&self) -> FPDS_R {
156        FPDS_R::new(((self.bits >> 5) & 0x01) != 0)
157    }
158    #[doc = "Bit 4 - Flash power down mode during LPRun for CPU1"]
159    #[inline(always)]
160    pub fn fpdr(&self) -> FPDR_R {
161        FPDR_R::new(((self.bits >> 4) & 0x01) != 0)
162    }
163    #[doc = "Bits 0:2 - Low-power mode selection for CPU1"]
164    #[inline(always)]
165    pub fn lpms(&self) -> LPMS_R {
166        LPMS_R::new((self.bits & 0x07) as u8)
167    }
168}
169impl W {
170    #[doc = "Bit 14 - Low-power run"]
171    #[inline(always)]
172    pub fn lpr(&mut self) -> LPR_W {
173        LPR_W { w: self }
174    }
175    #[doc = "Bits 9:10 - Voltage scaling range selection"]
176    #[inline(always)]
177    pub fn vos(&mut self) -> VOS_W {
178        VOS_W { w: self }
179    }
180    #[doc = "Bit 8 - Disable backup domain write protection"]
181    #[inline(always)]
182    pub fn dbp(&mut self) -> DBP_W {
183        DBP_W { w: self }
184    }
185    #[doc = "Bit 5 - Flash power down mode during LPsSleep for CPU1"]
186    #[inline(always)]
187    pub fn fpds(&mut self) -> FPDS_W {
188        FPDS_W { w: self }
189    }
190    #[doc = "Bit 4 - Flash power down mode during LPRun for CPU1"]
191    #[inline(always)]
192    pub fn fpdr(&mut self) -> FPDR_W {
193        FPDR_W { w: self }
194    }
195    #[doc = "Bits 0:2 - Low-power mode selection for CPU1"]
196    #[inline(always)]
197    pub fn lpms(&mut self) -> LPMS_W {
198        LPMS_W { w: self }
199    }
200}