stm32wb_pac/rtc/
dr.rs

1#[doc = "Reader of register DR"]
2pub type R = crate::R<u32, super::DR>;
3#[doc = "Writer for register DR"]
4pub type W = crate::W<u32, super::DR>;
5#[doc = "Register DR `reset()`'s with value 0x2101"]
6impl crate::ResetValue for super::DR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x2101
11    }
12}
13#[doc = "Reader of field `YT`"]
14pub type YT_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `YT`"]
16pub struct YT_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> YT_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !(0x0f << 20)) | (((value as u32) & 0x0f) << 20);
24        self.w
25    }
26}
27#[doc = "Reader of field `YU`"]
28pub type YU_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `YU`"]
30pub struct YU_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> YU_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
38        self.w
39    }
40}
41#[doc = "Reader of field `WDU`"]
42pub type WDU_R = crate::R<u8, u8>;
43#[doc = "Write proxy for field `WDU`"]
44pub struct WDU_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> WDU_W<'a> {
48    #[doc = r"Writes raw bits to the field"]
49    #[inline(always)]
50    pub unsafe fn bits(self, value: u8) -> &'a mut W {
51        self.w.bits = (self.w.bits & !(0x07 << 13)) | (((value as u32) & 0x07) << 13);
52        self.w
53    }
54}
55#[doc = "Reader of field `MT`"]
56pub type MT_R = crate::R<bool, bool>;
57#[doc = "Write proxy for field `MT`"]
58pub struct MT_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> MT_W<'a> {
62    #[doc = r"Sets the field bit"]
63    #[inline(always)]
64    pub fn set_bit(self) -> &'a mut W {
65        self.bit(true)
66    }
67    #[doc = r"Clears the field bit"]
68    #[inline(always)]
69    pub fn clear_bit(self) -> &'a mut W {
70        self.bit(false)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub fn bit(self, value: bool) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
76        self.w
77    }
78}
79#[doc = "Reader of field `MU`"]
80pub type MU_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `MU`"]
82pub struct MU_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> MU_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 `DT`"]
94pub type DT_R = crate::R<u8, u8>;
95#[doc = "Write proxy for field `DT`"]
96pub struct DT_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> DT_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 & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
104        self.w
105    }
106}
107#[doc = "Reader of field `DU`"]
108pub type DU_R = crate::R<u8, u8>;
109#[doc = "Write proxy for field `DU`"]
110pub struct DU_W<'a> {
111    w: &'a mut W,
112}
113impl<'a> DU_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 = "Bits 20:23 - Year tens in BCD format"]
123    #[inline(always)]
124    pub fn yt(&self) -> YT_R {
125        YT_R::new(((self.bits >> 20) & 0x0f) as u8)
126    }
127    #[doc = "Bits 16:19 - Year units in BCD format"]
128    #[inline(always)]
129    pub fn yu(&self) -> YU_R {
130        YU_R::new(((self.bits >> 16) & 0x0f) as u8)
131    }
132    #[doc = "Bits 13:15 - Week day units"]
133    #[inline(always)]
134    pub fn wdu(&self) -> WDU_R {
135        WDU_R::new(((self.bits >> 13) & 0x07) as u8)
136    }
137    #[doc = "Bit 12 - Month tens in BCD format"]
138    #[inline(always)]
139    pub fn mt(&self) -> MT_R {
140        MT_R::new(((self.bits >> 12) & 0x01) != 0)
141    }
142    #[doc = "Bits 8:11 - Month units in BCD format"]
143    #[inline(always)]
144    pub fn mu(&self) -> MU_R {
145        MU_R::new(((self.bits >> 8) & 0x0f) as u8)
146    }
147    #[doc = "Bits 4:5 - Date tens in BCD format"]
148    #[inline(always)]
149    pub fn dt(&self) -> DT_R {
150        DT_R::new(((self.bits >> 4) & 0x03) as u8)
151    }
152    #[doc = "Bits 0:3 - Date units in BCD format"]
153    #[inline(always)]
154    pub fn du(&self) -> DU_R {
155        DU_R::new((self.bits & 0x0f) as u8)
156    }
157}
158impl W {
159    #[doc = "Bits 20:23 - Year tens in BCD format"]
160    #[inline(always)]
161    pub fn yt(&mut self) -> YT_W {
162        YT_W { w: self }
163    }
164    #[doc = "Bits 16:19 - Year units in BCD format"]
165    #[inline(always)]
166    pub fn yu(&mut self) -> YU_W {
167        YU_W { w: self }
168    }
169    #[doc = "Bits 13:15 - Week day units"]
170    #[inline(always)]
171    pub fn wdu(&mut self) -> WDU_W {
172        WDU_W { w: self }
173    }
174    #[doc = "Bit 12 - Month tens in BCD format"]
175    #[inline(always)]
176    pub fn mt(&mut self) -> MT_W {
177        MT_W { w: self }
178    }
179    #[doc = "Bits 8:11 - Month units in BCD format"]
180    #[inline(always)]
181    pub fn mu(&mut self) -> MU_W {
182        MU_W { w: self }
183    }
184    #[doc = "Bits 4:5 - Date tens in BCD format"]
185    #[inline(always)]
186    pub fn dt(&mut self) -> DT_W {
187        DT_W { w: self }
188    }
189    #[doc = "Bits 0:3 - Date units in BCD format"]
190    #[inline(always)]
191    pub fn du(&mut self) -> DU_W {
192        DU_W { w: self }
193    }
194}