stm32l4x2_pac/rtc/
calr.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::CALR {
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 CALPR {
47    bits: bool,
48}
49impl CALPR {
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 CALW8R {
68    bits: bool,
69}
70impl CALW8R {
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 CALW16R {
89    bits: bool,
90}
91impl CALW16R {
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 CALMR {
110    bits: u16,
111}
112impl CALMR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bits(&self) -> u16 {
116        self.bits
117    }
118}
119#[doc = r" Proxy"]
120pub struct _CALPW<'a> {
121    w: &'a mut W,
122}
123impl<'a> _CALPW<'a> {
124    #[doc = r" Sets the field bit"]
125    pub fn set_bit(self) -> &'a mut W {
126        self.bit(true)
127    }
128    #[doc = r" Clears the field bit"]
129    pub fn clear_bit(self) -> &'a mut W {
130        self.bit(false)
131    }
132    #[doc = r" Writes raw bits to the field"]
133    #[inline]
134    pub fn bit(self, value: bool) -> &'a mut W {
135        const MASK: bool = true;
136        const OFFSET: u8 = 15;
137        self.w.bits &= !((MASK as u32) << OFFSET);
138        self.w.bits |= ((value & MASK) as u32) << OFFSET;
139        self.w
140    }
141}
142#[doc = r" Proxy"]
143pub struct _CALW8W<'a> {
144    w: &'a mut W,
145}
146impl<'a> _CALW8W<'a> {
147    #[doc = r" Sets the field bit"]
148    pub fn set_bit(self) -> &'a mut W {
149        self.bit(true)
150    }
151    #[doc = r" Clears the field bit"]
152    pub fn clear_bit(self) -> &'a mut W {
153        self.bit(false)
154    }
155    #[doc = r" Writes raw bits to the field"]
156    #[inline]
157    pub fn bit(self, value: bool) -> &'a mut W {
158        const MASK: bool = true;
159        const OFFSET: u8 = 14;
160        self.w.bits &= !((MASK as u32) << OFFSET);
161        self.w.bits |= ((value & MASK) as u32) << OFFSET;
162        self.w
163    }
164}
165#[doc = r" Proxy"]
166pub struct _CALW16W<'a> {
167    w: &'a mut W,
168}
169impl<'a> _CALW16W<'a> {
170    #[doc = r" Sets the field bit"]
171    pub fn set_bit(self) -> &'a mut W {
172        self.bit(true)
173    }
174    #[doc = r" Clears the field bit"]
175    pub fn clear_bit(self) -> &'a mut W {
176        self.bit(false)
177    }
178    #[doc = r" Writes raw bits to the field"]
179    #[inline]
180    pub fn bit(self, value: bool) -> &'a mut W {
181        const MASK: bool = true;
182        const OFFSET: u8 = 13;
183        self.w.bits &= !((MASK as u32) << OFFSET);
184        self.w.bits |= ((value & MASK) as u32) << OFFSET;
185        self.w
186    }
187}
188#[doc = r" Proxy"]
189pub struct _CALMW<'a> {
190    w: &'a mut W,
191}
192impl<'a> _CALMW<'a> {
193    #[doc = r" Writes raw bits to the field"]
194    #[inline]
195    pub unsafe fn bits(self, value: u16) -> &'a mut W {
196        const MASK: u16 = 511;
197        const OFFSET: u8 = 0;
198        self.w.bits &= !((MASK as u32) << OFFSET);
199        self.w.bits |= ((value & MASK) as u32) << OFFSET;
200        self.w
201    }
202}
203impl R {
204    #[doc = r" Value of the register as raw bits"]
205    #[inline]
206    pub fn bits(&self) -> u32 {
207        self.bits
208    }
209    #[doc = "Bit 15 - Increase frequency of RTC by 488.5 ppm"]
210    #[inline]
211    pub fn calp(&self) -> CALPR {
212        let bits = {
213            const MASK: bool = true;
214            const OFFSET: u8 = 15;
215            ((self.bits >> OFFSET) & MASK as u32) != 0
216        };
217        CALPR { bits }
218    }
219    #[doc = "Bit 14 - Use an 8-second calibration cycle period"]
220    #[inline]
221    pub fn calw8(&self) -> CALW8R {
222        let bits = {
223            const MASK: bool = true;
224            const OFFSET: u8 = 14;
225            ((self.bits >> OFFSET) & MASK as u32) != 0
226        };
227        CALW8R { bits }
228    }
229    #[doc = "Bit 13 - Use a 16-second calibration cycle period"]
230    #[inline]
231    pub fn calw16(&self) -> CALW16R {
232        let bits = {
233            const MASK: bool = true;
234            const OFFSET: u8 = 13;
235            ((self.bits >> OFFSET) & MASK as u32) != 0
236        };
237        CALW16R { bits }
238    }
239    #[doc = "Bits 0:8 - Calibration minus"]
240    #[inline]
241    pub fn calm(&self) -> CALMR {
242        let bits = {
243            const MASK: u16 = 511;
244            const OFFSET: u8 = 0;
245            ((self.bits >> OFFSET) & MASK as u32) as u16
246        };
247        CALMR { bits }
248    }
249}
250impl W {
251    #[doc = r" Reset value of the register"]
252    #[inline]
253    pub fn reset_value() -> W {
254        W { bits: 0 }
255    }
256    #[doc = r" Writes raw bits to the register"]
257    #[inline]
258    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
259        self.bits = bits;
260        self
261    }
262    #[doc = "Bit 15 - Increase frequency of RTC by 488.5 ppm"]
263    #[inline]
264    pub fn calp(&mut self) -> _CALPW {
265        _CALPW { w: self }
266    }
267    #[doc = "Bit 14 - Use an 8-second calibration cycle period"]
268    #[inline]
269    pub fn calw8(&mut self) -> _CALW8W {
270        _CALW8W { w: self }
271    }
272    #[doc = "Bit 13 - Use a 16-second calibration cycle period"]
273    #[inline]
274    pub fn calw16(&mut self) -> _CALW16W {
275        _CALW16W { w: self }
276    }
277    #[doc = "Bits 0:8 - Calibration minus"]
278    #[inline]
279    pub fn calm(&mut self) -> _CALMW {
280        _CALMW { w: self }
281    }
282}