stm32l4x2_pac/rcc/
cfgr.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::CFGR {
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 MCOPRER {
47    bits: u8,
48}
49impl MCOPRER {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u8 {
53        self.bits
54    }
55}
56#[doc = r" Value of the field"]
57pub struct MCOSELR {
58    bits: u8,
59}
60impl MCOSELR {
61    #[doc = r" Value of the field as raw bits"]
62    #[inline]
63    pub fn bits(&self) -> u8 {
64        self.bits
65    }
66}
67#[doc = r" Value of the field"]
68pub struct STOPWUCKR {
69    bits: bool,
70}
71impl STOPWUCKR {
72    #[doc = r" Value of the field as raw bits"]
73    #[inline]
74    pub fn bit(&self) -> bool {
75        self.bits
76    }
77    #[doc = r" Returns `true` if the bit is clear (0)"]
78    #[inline]
79    pub fn bit_is_clear(&self) -> bool {
80        !self.bit()
81    }
82    #[doc = r" Returns `true` if the bit is set (1)"]
83    #[inline]
84    pub fn bit_is_set(&self) -> bool {
85        self.bit()
86    }
87}
88#[doc = r" Value of the field"]
89pub struct PPRE2R {
90    bits: u8,
91}
92impl PPRE2R {
93    #[doc = r" Value of the field as raw bits"]
94    #[inline]
95    pub fn bits(&self) -> u8 {
96        self.bits
97    }
98}
99#[doc = r" Value of the field"]
100pub struct PPRE1R {
101    bits: u8,
102}
103impl PPRE1R {
104    #[doc = r" Value of the field as raw bits"]
105    #[inline]
106    pub fn bits(&self) -> u8 {
107        self.bits
108    }
109}
110#[doc = r" Value of the field"]
111pub struct HPRER {
112    bits: u8,
113}
114impl HPRER {
115    #[doc = r" Value of the field as raw bits"]
116    #[inline]
117    pub fn bits(&self) -> u8 {
118        self.bits
119    }
120}
121#[doc = r" Value of the field"]
122pub struct SWSR {
123    bits: u8,
124}
125impl SWSR {
126    #[doc = r" Value of the field as raw bits"]
127    #[inline]
128    pub fn bits(&self) -> u8 {
129        self.bits
130    }
131}
132#[doc = r" Value of the field"]
133pub struct SWR {
134    bits: u8,
135}
136impl SWR {
137    #[doc = r" Value of the field as raw bits"]
138    #[inline]
139    pub fn bits(&self) -> u8 {
140        self.bits
141    }
142}
143#[doc = r" Proxy"]
144pub struct _MCOSELW<'a> {
145    w: &'a mut W,
146}
147impl<'a> _MCOSELW<'a> {
148    #[doc = r" Writes raw bits to the field"]
149    #[inline]
150    pub unsafe fn bits(self, value: u8) -> &'a mut W {
151        const MASK: u8 = 7;
152        const OFFSET: u8 = 24;
153        self.w.bits &= !((MASK as u32) << OFFSET);
154        self.w.bits |= ((value & MASK) as u32) << OFFSET;
155        self.w
156    }
157}
158#[doc = r" Proxy"]
159pub struct _STOPWUCKW<'a> {
160    w: &'a mut W,
161}
162impl<'a> _STOPWUCKW<'a> {
163    #[doc = r" Sets the field bit"]
164    pub fn set_bit(self) -> &'a mut W {
165        self.bit(true)
166    }
167    #[doc = r" Clears the field bit"]
168    pub fn clear_bit(self) -> &'a mut W {
169        self.bit(false)
170    }
171    #[doc = r" Writes raw bits to the field"]
172    #[inline]
173    pub fn bit(self, value: bool) -> &'a mut W {
174        const MASK: bool = true;
175        const OFFSET: u8 = 15;
176        self.w.bits &= !((MASK as u32) << OFFSET);
177        self.w.bits |= ((value & MASK) as u32) << OFFSET;
178        self.w
179    }
180}
181#[doc = r" Proxy"]
182pub struct _PPRE2W<'a> {
183    w: &'a mut W,
184}
185impl<'a> _PPRE2W<'a> {
186    #[doc = r" Writes raw bits to the field"]
187    #[inline]
188    pub unsafe fn bits(self, value: u8) -> &'a mut W {
189        const MASK: u8 = 7;
190        const OFFSET: u8 = 11;
191        self.w.bits &= !((MASK as u32) << OFFSET);
192        self.w.bits |= ((value & MASK) as u32) << OFFSET;
193        self.w
194    }
195}
196#[doc = r" Proxy"]
197pub struct _PPRE1W<'a> {
198    w: &'a mut W,
199}
200impl<'a> _PPRE1W<'a> {
201    #[doc = r" Writes raw bits to the field"]
202    #[inline]
203    pub unsafe fn bits(self, value: u8) -> &'a mut W {
204        const MASK: u8 = 7;
205        const OFFSET: u8 = 8;
206        self.w.bits &= !((MASK as u32) << OFFSET);
207        self.w.bits |= ((value & MASK) as u32) << OFFSET;
208        self.w
209    }
210}
211#[doc = r" Proxy"]
212pub struct _HPREW<'a> {
213    w: &'a mut W,
214}
215impl<'a> _HPREW<'a> {
216    #[doc = r" Writes raw bits to the field"]
217    #[inline]
218    pub unsafe fn bits(self, value: u8) -> &'a mut W {
219        const MASK: u8 = 15;
220        const OFFSET: u8 = 4;
221        self.w.bits &= !((MASK as u32) << OFFSET);
222        self.w.bits |= ((value & MASK) as u32) << OFFSET;
223        self.w
224    }
225}
226#[doc = r" Proxy"]
227pub struct _SWW<'a> {
228    w: &'a mut W,
229}
230impl<'a> _SWW<'a> {
231    #[doc = r" Writes raw bits to the field"]
232    #[inline]
233    pub unsafe fn bits(self, value: u8) -> &'a mut W {
234        const MASK: u8 = 3;
235        const OFFSET: u8 = 0;
236        self.w.bits &= !((MASK as u32) << OFFSET);
237        self.w.bits |= ((value & MASK) as u32) << OFFSET;
238        self.w
239    }
240}
241impl R {
242    #[doc = r" Value of the register as raw bits"]
243    #[inline]
244    pub fn bits(&self) -> u32 {
245        self.bits
246    }
247    #[doc = "Bits 28:30 - Microcontroller clock output prescaler"]
248    #[inline]
249    pub fn mcopre(&self) -> MCOPRER {
250        let bits = {
251            const MASK: u8 = 7;
252            const OFFSET: u8 = 28;
253            ((self.bits >> OFFSET) & MASK as u32) as u8
254        };
255        MCOPRER { bits }
256    }
257    #[doc = "Bits 24:26 - Microcontroller clock output"]
258    #[inline]
259    pub fn mcosel(&self) -> MCOSELR {
260        let bits = {
261            const MASK: u8 = 7;
262            const OFFSET: u8 = 24;
263            ((self.bits >> OFFSET) & MASK as u32) as u8
264        };
265        MCOSELR { bits }
266    }
267    #[doc = "Bit 15 - Wakeup from Stop and CSS backup clock selection"]
268    #[inline]
269    pub fn stopwuck(&self) -> STOPWUCKR {
270        let bits = {
271            const MASK: bool = true;
272            const OFFSET: u8 = 15;
273            ((self.bits >> OFFSET) & MASK as u32) != 0
274        };
275        STOPWUCKR { bits }
276    }
277    #[doc = "Bits 11:13 - APB high-speed prescaler (APB2)"]
278    #[inline]
279    pub fn ppre2(&self) -> PPRE2R {
280        let bits = {
281            const MASK: u8 = 7;
282            const OFFSET: u8 = 11;
283            ((self.bits >> OFFSET) & MASK as u32) as u8
284        };
285        PPRE2R { bits }
286    }
287    #[doc = "Bits 8:10 - PB low-speed prescaler (APB1)"]
288    #[inline]
289    pub fn ppre1(&self) -> PPRE1R {
290        let bits = {
291            const MASK: u8 = 7;
292            const OFFSET: u8 = 8;
293            ((self.bits >> OFFSET) & MASK as u32) as u8
294        };
295        PPRE1R { bits }
296    }
297    #[doc = "Bits 4:7 - AHB prescaler"]
298    #[inline]
299    pub fn hpre(&self) -> HPRER {
300        let bits = {
301            const MASK: u8 = 15;
302            const OFFSET: u8 = 4;
303            ((self.bits >> OFFSET) & MASK as u32) as u8
304        };
305        HPRER { bits }
306    }
307    #[doc = "Bits 2:3 - System clock switch status"]
308    #[inline]
309    pub fn sws(&self) -> SWSR {
310        let bits = {
311            const MASK: u8 = 3;
312            const OFFSET: u8 = 2;
313            ((self.bits >> OFFSET) & MASK as u32) as u8
314        };
315        SWSR { bits }
316    }
317    #[doc = "Bits 0:1 - System clock switch"]
318    #[inline]
319    pub fn sw(&self) -> SWR {
320        let bits = {
321            const MASK: u8 = 3;
322            const OFFSET: u8 = 0;
323            ((self.bits >> OFFSET) & MASK as u32) as u8
324        };
325        SWR { bits }
326    }
327}
328impl W {
329    #[doc = r" Reset value of the register"]
330    #[inline]
331    pub fn reset_value() -> W {
332        W { bits: 0 }
333    }
334    #[doc = r" Writes raw bits to the register"]
335    #[inline]
336    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
337        self.bits = bits;
338        self
339    }
340    #[doc = "Bits 24:26 - Microcontroller clock output"]
341    #[inline]
342    pub fn mcosel(&mut self) -> _MCOSELW {
343        _MCOSELW { w: self }
344    }
345    #[doc = "Bit 15 - Wakeup from Stop and CSS backup clock selection"]
346    #[inline]
347    pub fn stopwuck(&mut self) -> _STOPWUCKW {
348        _STOPWUCKW { w: self }
349    }
350    #[doc = "Bits 11:13 - APB high-speed prescaler (APB2)"]
351    #[inline]
352    pub fn ppre2(&mut self) -> _PPRE2W {
353        _PPRE2W { w: self }
354    }
355    #[doc = "Bits 8:10 - PB low-speed prescaler (APB1)"]
356    #[inline]
357    pub fn ppre1(&mut self) -> _PPRE1W {
358        _PPRE1W { w: self }
359    }
360    #[doc = "Bits 4:7 - AHB prescaler"]
361    #[inline]
362    pub fn hpre(&mut self) -> _HPREW {
363        _HPREW { w: self }
364    }
365    #[doc = "Bits 0:1 - System clock switch"]
366    #[inline]
367    pub fn sw(&mut self) -> _SWW {
368        _SWW { w: self }
369    }
370}