stm32l4x2_pac/rtc/
dr.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::DR {
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 YTR {
47    bits: u8,
48}
49impl YTR {
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 YUR {
58    bits: u8,
59}
60impl YUR {
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 WDUR {
69    bits: u8,
70}
71impl WDUR {
72    #[doc = r" Value of the field as raw bits"]
73    #[inline]
74    pub fn bits(&self) -> u8 {
75        self.bits
76    }
77}
78#[doc = r" Value of the field"]
79pub struct MTR {
80    bits: bool,
81}
82impl MTR {
83    #[doc = r" Value of the field as raw bits"]
84    #[inline]
85    pub fn bit(&self) -> bool {
86        self.bits
87    }
88    #[doc = r" Returns `true` if the bit is clear (0)"]
89    #[inline]
90    pub fn bit_is_clear(&self) -> bool {
91        !self.bit()
92    }
93    #[doc = r" Returns `true` if the bit is set (1)"]
94    #[inline]
95    pub fn bit_is_set(&self) -> bool {
96        self.bit()
97    }
98}
99#[doc = r" Value of the field"]
100pub struct MUR {
101    bits: u8,
102}
103impl MUR {
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 DTR {
112    bits: u8,
113}
114impl DTR {
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 DUR {
123    bits: u8,
124}
125impl DUR {
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" Proxy"]
133pub struct _YTW<'a> {
134    w: &'a mut W,
135}
136impl<'a> _YTW<'a> {
137    #[doc = r" Writes raw bits to the field"]
138    #[inline]
139    pub unsafe fn bits(self, value: u8) -> &'a mut W {
140        const MASK: u8 = 15;
141        const OFFSET: u8 = 20;
142        self.w.bits &= !((MASK as u32) << OFFSET);
143        self.w.bits |= ((value & MASK) as u32) << OFFSET;
144        self.w
145    }
146}
147#[doc = r" Proxy"]
148pub struct _YUW<'a> {
149    w: &'a mut W,
150}
151impl<'a> _YUW<'a> {
152    #[doc = r" Writes raw bits to the field"]
153    #[inline]
154    pub unsafe fn bits(self, value: u8) -> &'a mut W {
155        const MASK: u8 = 15;
156        const OFFSET: u8 = 16;
157        self.w.bits &= !((MASK as u32) << OFFSET);
158        self.w.bits |= ((value & MASK) as u32) << OFFSET;
159        self.w
160    }
161}
162#[doc = r" Proxy"]
163pub struct _WDUW<'a> {
164    w: &'a mut W,
165}
166impl<'a> _WDUW<'a> {
167    #[doc = r" Writes raw bits to the field"]
168    #[inline]
169    pub unsafe fn bits(self, value: u8) -> &'a mut W {
170        const MASK: u8 = 7;
171        const OFFSET: u8 = 13;
172        self.w.bits &= !((MASK as u32) << OFFSET);
173        self.w.bits |= ((value & MASK) as u32) << OFFSET;
174        self.w
175    }
176}
177#[doc = r" Proxy"]
178pub struct _MTW<'a> {
179    w: &'a mut W,
180}
181impl<'a> _MTW<'a> {
182    #[doc = r" Sets the field bit"]
183    pub fn set_bit(self) -> &'a mut W {
184        self.bit(true)
185    }
186    #[doc = r" Clears the field bit"]
187    pub fn clear_bit(self) -> &'a mut W {
188        self.bit(false)
189    }
190    #[doc = r" Writes raw bits to the field"]
191    #[inline]
192    pub fn bit(self, value: bool) -> &'a mut W {
193        const MASK: bool = true;
194        const OFFSET: u8 = 12;
195        self.w.bits &= !((MASK as u32) << OFFSET);
196        self.w.bits |= ((value & MASK) as u32) << OFFSET;
197        self.w
198    }
199}
200#[doc = r" Proxy"]
201pub struct _MUW<'a> {
202    w: &'a mut W,
203}
204impl<'a> _MUW<'a> {
205    #[doc = r" Writes raw bits to the field"]
206    #[inline]
207    pub unsafe fn bits(self, value: u8) -> &'a mut W {
208        const MASK: u8 = 15;
209        const OFFSET: u8 = 8;
210        self.w.bits &= !((MASK as u32) << OFFSET);
211        self.w.bits |= ((value & MASK) as u32) << OFFSET;
212        self.w
213    }
214}
215#[doc = r" Proxy"]
216pub struct _DTW<'a> {
217    w: &'a mut W,
218}
219impl<'a> _DTW<'a> {
220    #[doc = r" Writes raw bits to the field"]
221    #[inline]
222    pub unsafe fn bits(self, value: u8) -> &'a mut W {
223        const MASK: u8 = 3;
224        const OFFSET: u8 = 4;
225        self.w.bits &= !((MASK as u32) << OFFSET);
226        self.w.bits |= ((value & MASK) as u32) << OFFSET;
227        self.w
228    }
229}
230#[doc = r" Proxy"]
231pub struct _DUW<'a> {
232    w: &'a mut W,
233}
234impl<'a> _DUW<'a> {
235    #[doc = r" Writes raw bits to the field"]
236    #[inline]
237    pub unsafe fn bits(self, value: u8) -> &'a mut W {
238        const MASK: u8 = 15;
239        const OFFSET: u8 = 0;
240        self.w.bits &= !((MASK as u32) << OFFSET);
241        self.w.bits |= ((value & MASK) as u32) << OFFSET;
242        self.w
243    }
244}
245impl R {
246    #[doc = r" Value of the register as raw bits"]
247    #[inline]
248    pub fn bits(&self) -> u32 {
249        self.bits
250    }
251    #[doc = "Bits 20:23 - Year tens in BCD format"]
252    #[inline]
253    pub fn yt(&self) -> YTR {
254        let bits = {
255            const MASK: u8 = 15;
256            const OFFSET: u8 = 20;
257            ((self.bits >> OFFSET) & MASK as u32) as u8
258        };
259        YTR { bits }
260    }
261    #[doc = "Bits 16:19 - Year units in BCD format"]
262    #[inline]
263    pub fn yu(&self) -> YUR {
264        let bits = {
265            const MASK: u8 = 15;
266            const OFFSET: u8 = 16;
267            ((self.bits >> OFFSET) & MASK as u32) as u8
268        };
269        YUR { bits }
270    }
271    #[doc = "Bits 13:15 - Week day units"]
272    #[inline]
273    pub fn wdu(&self) -> WDUR {
274        let bits = {
275            const MASK: u8 = 7;
276            const OFFSET: u8 = 13;
277            ((self.bits >> OFFSET) & MASK as u32) as u8
278        };
279        WDUR { bits }
280    }
281    #[doc = "Bit 12 - Month tens in BCD format"]
282    #[inline]
283    pub fn mt(&self) -> MTR {
284        let bits = {
285            const MASK: bool = true;
286            const OFFSET: u8 = 12;
287            ((self.bits >> OFFSET) & MASK as u32) != 0
288        };
289        MTR { bits }
290    }
291    #[doc = "Bits 8:11 - Month units in BCD format"]
292    #[inline]
293    pub fn mu(&self) -> MUR {
294        let bits = {
295            const MASK: u8 = 15;
296            const OFFSET: u8 = 8;
297            ((self.bits >> OFFSET) & MASK as u32) as u8
298        };
299        MUR { bits }
300    }
301    #[doc = "Bits 4:5 - Date tens in BCD format"]
302    #[inline]
303    pub fn dt(&self) -> DTR {
304        let bits = {
305            const MASK: u8 = 3;
306            const OFFSET: u8 = 4;
307            ((self.bits >> OFFSET) & MASK as u32) as u8
308        };
309        DTR { bits }
310    }
311    #[doc = "Bits 0:3 - Date units in BCD format"]
312    #[inline]
313    pub fn du(&self) -> DUR {
314        let bits = {
315            const MASK: u8 = 15;
316            const OFFSET: u8 = 0;
317            ((self.bits >> OFFSET) & MASK as u32) as u8
318        };
319        DUR { bits }
320    }
321}
322impl W {
323    #[doc = r" Reset value of the register"]
324    #[inline]
325    pub fn reset_value() -> W {
326        W { bits: 8449 }
327    }
328    #[doc = r" Writes raw bits to the register"]
329    #[inline]
330    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
331        self.bits = bits;
332        self
333    }
334    #[doc = "Bits 20:23 - Year tens in BCD format"]
335    #[inline]
336    pub fn yt(&mut self) -> _YTW {
337        _YTW { w: self }
338    }
339    #[doc = "Bits 16:19 - Year units in BCD format"]
340    #[inline]
341    pub fn yu(&mut self) -> _YUW {
342        _YUW { w: self }
343    }
344    #[doc = "Bits 13:15 - Week day units"]
345    #[inline]
346    pub fn wdu(&mut self) -> _WDUW {
347        _WDUW { w: self }
348    }
349    #[doc = "Bit 12 - Month tens in BCD format"]
350    #[inline]
351    pub fn mt(&mut self) -> _MTW {
352        _MTW { w: self }
353    }
354    #[doc = "Bits 8:11 - Month units in BCD format"]
355    #[inline]
356    pub fn mu(&mut self) -> _MUW {
357        _MUW { w: self }
358    }
359    #[doc = "Bits 4:5 - Date tens in BCD format"]
360    #[inline]
361    pub fn dt(&mut self) -> _DTW {
362        _DTW { w: self }
363    }
364    #[doc = "Bits 0:3 - Date units in BCD format"]
365    #[inline]
366    pub fn du(&mut self) -> _DUW {
367        _DUW { w: self }
368    }
369}