stm32f30x/rcc/bdcr/
mod.rs

1#[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::BDCR {
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 LSEONR {
47    bits: bool,
48}
49impl LSEONR {
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 LSERDYR {
68    bits: bool,
69}
70impl LSERDYR {
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 LSEBYPR {
89    bits: bool,
90}
91impl LSEBYPR {
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 LSEDRVR {
110    bits: u8,
111}
112impl LSEDRVR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bits(&self) -> u8 {
116        self.bits
117    }
118}
119#[doc = r" Value of the field"]
120pub struct RTCSELR {
121    bits: u8,
122}
123impl RTCSELR {
124    #[doc = r" Value of the field as raw bits"]
125    #[inline]
126    pub fn bits(&self) -> u8 {
127        self.bits
128    }
129}
130#[doc = r" Value of the field"]
131pub struct RTCENR {
132    bits: bool,
133}
134impl RTCENR {
135    #[doc = r" Value of the field as raw bits"]
136    #[inline]
137    pub fn bit(&self) -> bool {
138        self.bits
139    }
140    #[doc = r" Returns `true` if the bit is clear (0)"]
141    #[inline]
142    pub fn bit_is_clear(&self) -> bool {
143        !self.bit()
144    }
145    #[doc = r" Returns `true` if the bit is set (1)"]
146    #[inline]
147    pub fn bit_is_set(&self) -> bool {
148        self.bit()
149    }
150}
151#[doc = r" Value of the field"]
152pub struct BDRSTR {
153    bits: bool,
154}
155impl BDRSTR {
156    #[doc = r" Value of the field as raw bits"]
157    #[inline]
158    pub fn bit(&self) -> bool {
159        self.bits
160    }
161    #[doc = r" Returns `true` if the bit is clear (0)"]
162    #[inline]
163    pub fn bit_is_clear(&self) -> bool {
164        !self.bit()
165    }
166    #[doc = r" Returns `true` if the bit is set (1)"]
167    #[inline]
168    pub fn bit_is_set(&self) -> bool {
169        self.bit()
170    }
171}
172#[doc = r" Proxy"]
173pub struct _LSEONW<'a> {
174    w: &'a mut W,
175}
176impl<'a> _LSEONW<'a> {
177    #[doc = r" Sets the field bit"]
178    pub fn set_bit(self) -> &'a mut W {
179        self.bit(true)
180    }
181    #[doc = r" Clears the field bit"]
182    pub fn clear_bit(self) -> &'a mut W {
183        self.bit(false)
184    }
185    #[doc = r" Writes raw bits to the field"]
186    #[inline]
187    pub fn bit(self, value: bool) -> &'a mut W {
188        const MASK: bool = true;
189        const OFFSET: u8 = 0;
190        self.w.bits &= !((MASK as u32) << OFFSET);
191        self.w.bits |= ((value & MASK) as u32) << OFFSET;
192        self.w
193    }
194}
195#[doc = r" Proxy"]
196pub struct _LSEBYPW<'a> {
197    w: &'a mut W,
198}
199impl<'a> _LSEBYPW<'a> {
200    #[doc = r" Sets the field bit"]
201    pub fn set_bit(self) -> &'a mut W {
202        self.bit(true)
203    }
204    #[doc = r" Clears the field bit"]
205    pub fn clear_bit(self) -> &'a mut W {
206        self.bit(false)
207    }
208    #[doc = r" Writes raw bits to the field"]
209    #[inline]
210    pub fn bit(self, value: bool) -> &'a mut W {
211        const MASK: bool = true;
212        const OFFSET: u8 = 2;
213        self.w.bits &= !((MASK as u32) << OFFSET);
214        self.w.bits |= ((value & MASK) as u32) << OFFSET;
215        self.w
216    }
217}
218#[doc = r" Proxy"]
219pub struct _LSEDRVW<'a> {
220    w: &'a mut W,
221}
222impl<'a> _LSEDRVW<'a> {
223    #[doc = r" Writes raw bits to the field"]
224    #[inline]
225    pub unsafe fn bits(self, value: u8) -> &'a mut W {
226        const MASK: u8 = 3;
227        const OFFSET: u8 = 3;
228        self.w.bits &= !((MASK as u32) << OFFSET);
229        self.w.bits |= ((value & MASK) as u32) << OFFSET;
230        self.w
231    }
232}
233#[doc = r" Proxy"]
234pub struct _RTCSELW<'a> {
235    w: &'a mut W,
236}
237impl<'a> _RTCSELW<'a> {
238    #[doc = r" Writes raw bits to the field"]
239    #[inline]
240    pub unsafe fn bits(self, value: u8) -> &'a mut W {
241        const MASK: u8 = 3;
242        const OFFSET: u8 = 8;
243        self.w.bits &= !((MASK as u32) << OFFSET);
244        self.w.bits |= ((value & MASK) as u32) << OFFSET;
245        self.w
246    }
247}
248#[doc = r" Proxy"]
249pub struct _RTCENW<'a> {
250    w: &'a mut W,
251}
252impl<'a> _RTCENW<'a> {
253    #[doc = r" Sets the field bit"]
254    pub fn set_bit(self) -> &'a mut W {
255        self.bit(true)
256    }
257    #[doc = r" Clears the field bit"]
258    pub fn clear_bit(self) -> &'a mut W {
259        self.bit(false)
260    }
261    #[doc = r" Writes raw bits to the field"]
262    #[inline]
263    pub fn bit(self, value: bool) -> &'a mut W {
264        const MASK: bool = true;
265        const OFFSET: u8 = 15;
266        self.w.bits &= !((MASK as u32) << OFFSET);
267        self.w.bits |= ((value & MASK) as u32) << OFFSET;
268        self.w
269    }
270}
271#[doc = r" Proxy"]
272pub struct _BDRSTW<'a> {
273    w: &'a mut W,
274}
275impl<'a> _BDRSTW<'a> {
276    #[doc = r" Sets the field bit"]
277    pub fn set_bit(self) -> &'a mut W {
278        self.bit(true)
279    }
280    #[doc = r" Clears the field bit"]
281    pub fn clear_bit(self) -> &'a mut W {
282        self.bit(false)
283    }
284    #[doc = r" Writes raw bits to the field"]
285    #[inline]
286    pub fn bit(self, value: bool) -> &'a mut W {
287        const MASK: bool = true;
288        const OFFSET: u8 = 16;
289        self.w.bits &= !((MASK as u32) << OFFSET);
290        self.w.bits |= ((value & MASK) as u32) << OFFSET;
291        self.w
292    }
293}
294impl R {
295    #[doc = r" Value of the register as raw bits"]
296    #[inline]
297    pub fn bits(&self) -> u32 {
298        self.bits
299    }
300    #[doc = "Bit 0 - External Low Speed oscillator enable"]
301    #[inline]
302    pub fn lseon(&self) -> LSEONR {
303        let bits = {
304            const MASK: bool = true;
305            const OFFSET: u8 = 0;
306            ((self.bits >> OFFSET) & MASK as u32) != 0
307        };
308        LSEONR { bits }
309    }
310    #[doc = "Bit 1 - External Low Speed oscillator ready"]
311    #[inline]
312    pub fn lserdy(&self) -> LSERDYR {
313        let bits = {
314            const MASK: bool = true;
315            const OFFSET: u8 = 1;
316            ((self.bits >> OFFSET) & MASK as u32) != 0
317        };
318        LSERDYR { bits }
319    }
320    #[doc = "Bit 2 - External Low Speed oscillator bypass"]
321    #[inline]
322    pub fn lsebyp(&self) -> LSEBYPR {
323        let bits = {
324            const MASK: bool = true;
325            const OFFSET: u8 = 2;
326            ((self.bits >> OFFSET) & MASK as u32) != 0
327        };
328        LSEBYPR { bits }
329    }
330    #[doc = "Bits 3:4 - LSE oscillator drive capability"]
331    #[inline]
332    pub fn lsedrv(&self) -> LSEDRVR {
333        let bits = {
334            const MASK: u8 = 3;
335            const OFFSET: u8 = 3;
336            ((self.bits >> OFFSET) & MASK as u32) as u8
337        };
338        LSEDRVR { bits }
339    }
340    #[doc = "Bits 8:9 - RTC clock source selection"]
341    #[inline]
342    pub fn rtcsel(&self) -> RTCSELR {
343        let bits = {
344            const MASK: u8 = 3;
345            const OFFSET: u8 = 8;
346            ((self.bits >> OFFSET) & MASK as u32) as u8
347        };
348        RTCSELR { bits }
349    }
350    #[doc = "Bit 15 - RTC clock enable"]
351    #[inline]
352    pub fn rtcen(&self) -> RTCENR {
353        let bits = {
354            const MASK: bool = true;
355            const OFFSET: u8 = 15;
356            ((self.bits >> OFFSET) & MASK as u32) != 0
357        };
358        RTCENR { bits }
359    }
360    #[doc = "Bit 16 - Backup domain software reset"]
361    #[inline]
362    pub fn bdrst(&self) -> BDRSTR {
363        let bits = {
364            const MASK: bool = true;
365            const OFFSET: u8 = 16;
366            ((self.bits >> OFFSET) & MASK as u32) != 0
367        };
368        BDRSTR { bits }
369    }
370}
371impl W {
372    #[doc = r" Reset value of the register"]
373    #[inline]
374    pub fn reset_value() -> W {
375        W { bits: 0 }
376    }
377    #[doc = r" Writes raw bits to the register"]
378    #[inline]
379    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
380        self.bits = bits;
381        self
382    }
383    #[doc = "Bit 0 - External Low Speed oscillator enable"]
384    #[inline]
385    pub fn lseon(&mut self) -> _LSEONW {
386        _LSEONW { w: self }
387    }
388    #[doc = "Bit 2 - External Low Speed oscillator bypass"]
389    #[inline]
390    pub fn lsebyp(&mut self) -> _LSEBYPW {
391        _LSEBYPW { w: self }
392    }
393    #[doc = "Bits 3:4 - LSE oscillator drive capability"]
394    #[inline]
395    pub fn lsedrv(&mut self) -> _LSEDRVW {
396        _LSEDRVW { w: self }
397    }
398    #[doc = "Bits 8:9 - RTC clock source selection"]
399    #[inline]
400    pub fn rtcsel(&mut self) -> _RTCSELW {
401        _RTCSELW { w: self }
402    }
403    #[doc = "Bit 15 - RTC clock enable"]
404    #[inline]
405    pub fn rtcen(&mut self) -> _RTCENW {
406        _RTCENW { w: self }
407    }
408    #[doc = "Bit 16 - Backup domain software reset"]
409    #[inline]
410    pub fn bdrst(&mut self) -> _BDRSTW {
411        _BDRSTW { w: self }
412    }
413}