stm32wb_pac/rtc/
tr.rs

1#[doc = "Reader of register TR"]
2pub type R = crate::R<u32, super::TR>;
3#[doc = "Writer for register TR"]
4pub type W = crate::W<u32, super::TR>;
5#[doc = "Register TR `reset()`'s with value 0"]
6impl crate::ResetValue for super::TR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `PM`"]
14pub type PM_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `PM`"]
16pub struct PM_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> PM_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22);
34        self.w
35    }
36}
37#[doc = "Reader of field `HT`"]
38pub type HT_R = crate::R<u8, u8>;
39#[doc = "Write proxy for field `HT`"]
40pub struct HT_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> HT_W<'a> {
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub unsafe fn bits(self, value: u8) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x03 << 20)) | (((value as u32) & 0x03) << 20);
48        self.w
49    }
50}
51#[doc = "Reader of field `HU`"]
52pub type HU_R = crate::R<u8, u8>;
53#[doc = "Write proxy for field `HU`"]
54pub struct HU_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> HU_W<'a> {
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub unsafe fn bits(self, value: u8) -> &'a mut W {
61        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
62        self.w
63    }
64}
65#[doc = "Reader of field `MNT`"]
66pub type MNT_R = crate::R<u8, u8>;
67#[doc = "Write proxy for field `MNT`"]
68pub struct MNT_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> MNT_W<'a> {
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u8) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x07 << 12)) | (((value as u32) & 0x07) << 12);
76        self.w
77    }
78}
79#[doc = "Reader of field `MNU`"]
80pub type MNU_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `MNU`"]
82pub struct MNU_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> MNU_W<'a> {
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub unsafe fn bits(self, value: u8) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
90        self.w
91    }
92}
93#[doc = "Reader of field `ST`"]
94pub type ST_R = crate::R<u8, u8>;
95#[doc = "Write proxy for field `ST`"]
96pub struct ST_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> ST_W<'a> {
100    #[doc = r"Writes raw bits to the field"]
101    #[inline(always)]
102    pub unsafe fn bits(self, value: u8) -> &'a mut W {
103        self.w.bits = (self.w.bits & !(0x07 << 4)) | (((value as u32) & 0x07) << 4);
104        self.w
105    }
106}
107#[doc = "Reader of field `SU`"]
108pub type SU_R = crate::R<u8, u8>;
109#[doc = "Write proxy for field `SU`"]
110pub struct SU_W<'a> {
111    w: &'a mut W,
112}
113impl<'a> SU_W<'a> {
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub unsafe fn bits(self, value: u8) -> &'a mut W {
117        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
118        self.w
119    }
120}
121impl R {
122    #[doc = "Bit 22 - AM/PM notation"]
123    #[inline(always)]
124    pub fn pm(&self) -> PM_R {
125        PM_R::new(((self.bits >> 22) & 0x01) != 0)
126    }
127    #[doc = "Bits 20:21 - Hour tens in BCD format"]
128    #[inline(always)]
129    pub fn ht(&self) -> HT_R {
130        HT_R::new(((self.bits >> 20) & 0x03) as u8)
131    }
132    #[doc = "Bits 16:19 - Hour units in BCD format"]
133    #[inline(always)]
134    pub fn hu(&self) -> HU_R {
135        HU_R::new(((self.bits >> 16) & 0x0f) as u8)
136    }
137    #[doc = "Bits 12:14 - Minute tens in BCD format"]
138    #[inline(always)]
139    pub fn mnt(&self) -> MNT_R {
140        MNT_R::new(((self.bits >> 12) & 0x07) as u8)
141    }
142    #[doc = "Bits 8:11 - Minute units in BCD format"]
143    #[inline(always)]
144    pub fn mnu(&self) -> MNU_R {
145        MNU_R::new(((self.bits >> 8) & 0x0f) as u8)
146    }
147    #[doc = "Bits 4:6 - Second tens in BCD format"]
148    #[inline(always)]
149    pub fn st(&self) -> ST_R {
150        ST_R::new(((self.bits >> 4) & 0x07) as u8)
151    }
152    #[doc = "Bits 0:3 - Second units in BCD format"]
153    #[inline(always)]
154    pub fn su(&self) -> SU_R {
155        SU_R::new((self.bits & 0x0f) as u8)
156    }
157}
158impl W {
159    #[doc = "Bit 22 - AM/PM notation"]
160    #[inline(always)]
161    pub fn pm(&mut self) -> PM_W {
162        PM_W { w: self }
163    }
164    #[doc = "Bits 20:21 - Hour tens in BCD format"]
165    #[inline(always)]
166    pub fn ht(&mut self) -> HT_W {
167        HT_W { w: self }
168    }
169    #[doc = "Bits 16:19 - Hour units in BCD format"]
170    #[inline(always)]
171    pub fn hu(&mut self) -> HU_W {
172        HU_W { w: self }
173    }
174    #[doc = "Bits 12:14 - Minute tens in BCD format"]
175    #[inline(always)]
176    pub fn mnt(&mut self) -> MNT_W {
177        MNT_W { w: self }
178    }
179    #[doc = "Bits 8:11 - Minute units in BCD format"]
180    #[inline(always)]
181    pub fn mnu(&mut self) -> MNU_W {
182        MNU_W { w: self }
183    }
184    #[doc = "Bits 4:6 - Second tens in BCD format"]
185    #[inline(always)]
186    pub fn st(&mut self) -> ST_W {
187        ST_W { w: self }
188    }
189    #[doc = "Bits 0:3 - Second units in BCD format"]
190    #[inline(always)]
191    pub fn su(&mut self) -> SU_W {
192        SU_W { w: self }
193    }
194}