stm32l4x2_pac/rtc/
tr.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::TR {
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 PMR {
47    bits: bool,
48}
49impl PMR {
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 HTR {
68    bits: u8,
69}
70impl HTR {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bits(&self) -> u8 {
74        self.bits
75    }
76}
77#[doc = r" Value of the field"]
78pub struct HUR {
79    bits: u8,
80}
81impl HUR {
82    #[doc = r" Value of the field as raw bits"]
83    #[inline]
84    pub fn bits(&self) -> u8 {
85        self.bits
86    }
87}
88#[doc = r" Value of the field"]
89pub struct MNTR {
90    bits: u8,
91}
92impl MNTR {
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 MNUR {
101    bits: u8,
102}
103impl MNUR {
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 STR {
112    bits: u8,
113}
114impl STR {
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 SUR {
123    bits: u8,
124}
125impl SUR {
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 _PMW<'a> {
134    w: &'a mut W,
135}
136impl<'a> _PMW<'a> {
137    #[doc = r" Sets the field bit"]
138    pub fn set_bit(self) -> &'a mut W {
139        self.bit(true)
140    }
141    #[doc = r" Clears the field bit"]
142    pub fn clear_bit(self) -> &'a mut W {
143        self.bit(false)
144    }
145    #[doc = r" Writes raw bits to the field"]
146    #[inline]
147    pub fn bit(self, value: bool) -> &'a mut W {
148        const MASK: bool = true;
149        const OFFSET: u8 = 22;
150        self.w.bits &= !((MASK as u32) << OFFSET);
151        self.w.bits |= ((value & MASK) as u32) << OFFSET;
152        self.w
153    }
154}
155#[doc = r" Proxy"]
156pub struct _HTW<'a> {
157    w: &'a mut W,
158}
159impl<'a> _HTW<'a> {
160    #[doc = r" Writes raw bits to the field"]
161    #[inline]
162    pub unsafe fn bits(self, value: u8) -> &'a mut W {
163        const MASK: u8 = 3;
164        const OFFSET: u8 = 20;
165        self.w.bits &= !((MASK as u32) << OFFSET);
166        self.w.bits |= ((value & MASK) as u32) << OFFSET;
167        self.w
168    }
169}
170#[doc = r" Proxy"]
171pub struct _HUW<'a> {
172    w: &'a mut W,
173}
174impl<'a> _HUW<'a> {
175    #[doc = r" Writes raw bits to the field"]
176    #[inline]
177    pub unsafe fn bits(self, value: u8) -> &'a mut W {
178        const MASK: u8 = 15;
179        const OFFSET: u8 = 16;
180        self.w.bits &= !((MASK as u32) << OFFSET);
181        self.w.bits |= ((value & MASK) as u32) << OFFSET;
182        self.w
183    }
184}
185#[doc = r" Proxy"]
186pub struct _MNTW<'a> {
187    w: &'a mut W,
188}
189impl<'a> _MNTW<'a> {
190    #[doc = r" Writes raw bits to the field"]
191    #[inline]
192    pub unsafe fn bits(self, value: u8) -> &'a mut W {
193        const MASK: u8 = 7;
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 _MNUW<'a> {
202    w: &'a mut W,
203}
204impl<'a> _MNUW<'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 _STW<'a> {
217    w: &'a mut W,
218}
219impl<'a> _STW<'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 = 7;
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 _SUW<'a> {
232    w: &'a mut W,
233}
234impl<'a> _SUW<'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 = "Bit 22 - AM/PM notation"]
252    #[inline]
253    pub fn pm(&self) -> PMR {
254        let bits = {
255            const MASK: bool = true;
256            const OFFSET: u8 = 22;
257            ((self.bits >> OFFSET) & MASK as u32) != 0
258        };
259        PMR { bits }
260    }
261    #[doc = "Bits 20:21 - Hour tens in BCD format"]
262    #[inline]
263    pub fn ht(&self) -> HTR {
264        let bits = {
265            const MASK: u8 = 3;
266            const OFFSET: u8 = 20;
267            ((self.bits >> OFFSET) & MASK as u32) as u8
268        };
269        HTR { bits }
270    }
271    #[doc = "Bits 16:19 - Hour units in BCD format"]
272    #[inline]
273    pub fn hu(&self) -> HUR {
274        let bits = {
275            const MASK: u8 = 15;
276            const OFFSET: u8 = 16;
277            ((self.bits >> OFFSET) & MASK as u32) as u8
278        };
279        HUR { bits }
280    }
281    #[doc = "Bits 12:14 - Minute tens in BCD format"]
282    #[inline]
283    pub fn mnt(&self) -> MNTR {
284        let bits = {
285            const MASK: u8 = 7;
286            const OFFSET: u8 = 12;
287            ((self.bits >> OFFSET) & MASK as u32) as u8
288        };
289        MNTR { bits }
290    }
291    #[doc = "Bits 8:11 - Minute units in BCD format"]
292    #[inline]
293    pub fn mnu(&self) -> MNUR {
294        let bits = {
295            const MASK: u8 = 15;
296            const OFFSET: u8 = 8;
297            ((self.bits >> OFFSET) & MASK as u32) as u8
298        };
299        MNUR { bits }
300    }
301    #[doc = "Bits 4:6 - Second tens in BCD format"]
302    #[inline]
303    pub fn st(&self) -> STR {
304        let bits = {
305            const MASK: u8 = 7;
306            const OFFSET: u8 = 4;
307            ((self.bits >> OFFSET) & MASK as u32) as u8
308        };
309        STR { bits }
310    }
311    #[doc = "Bits 0:3 - Second units in BCD format"]
312    #[inline]
313    pub fn su(&self) -> SUR {
314        let bits = {
315            const MASK: u8 = 15;
316            const OFFSET: u8 = 0;
317            ((self.bits >> OFFSET) & MASK as u32) as u8
318        };
319        SUR { bits }
320    }
321}
322impl W {
323    #[doc = r" Reset value of the register"]
324    #[inline]
325    pub fn reset_value() -> W {
326        W { bits: 0 }
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 = "Bit 22 - AM/PM notation"]
335    #[inline]
336    pub fn pm(&mut self) -> _PMW {
337        _PMW { w: self }
338    }
339    #[doc = "Bits 20:21 - Hour tens in BCD format"]
340    #[inline]
341    pub fn ht(&mut self) -> _HTW {
342        _HTW { w: self }
343    }
344    #[doc = "Bits 16:19 - Hour units in BCD format"]
345    #[inline]
346    pub fn hu(&mut self) -> _HUW {
347        _HUW { w: self }
348    }
349    #[doc = "Bits 12:14 - Minute tens in BCD format"]
350    #[inline]
351    pub fn mnt(&mut self) -> _MNTW {
352        _MNTW { w: self }
353    }
354    #[doc = "Bits 8:11 - Minute units in BCD format"]
355    #[inline]
356    pub fn mnu(&mut self) -> _MNUW {
357        _MNUW { w: self }
358    }
359    #[doc = "Bits 4:6 - Second tens in BCD format"]
360    #[inline]
361    pub fn st(&mut self) -> _STW {
362        _STW { w: self }
363    }
364    #[doc = "Bits 0:3 - Second units in BCD format"]
365    #[inline]
366    pub fn su(&mut self) -> _SUW {
367        _SUW { w: self }
368    }
369}