stm32f7_staging/stm32f733/rtc/
dr.rs

1///Register `DR` reader
2pub type R = crate::R<DRrs>;
3///Register `DR` writer
4pub type W = crate::W<DRrs>;
5///Field `DU` reader - Date units in BCD format
6pub type DU_R = crate::FieldReader;
7///Field `DU` writer - Date units in BCD format
8pub type DU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
9///Field `DT` reader - Date tens in BCD format
10pub type DT_R = crate::FieldReader;
11///Field `DT` writer - Date tens in BCD format
12pub type DT_W<'a, REG> = crate::FieldWriter<'a, REG, 2, u8, crate::Safe>;
13///Field `MU` reader - Month units in BCD format
14pub type MU_R = crate::FieldReader;
15///Field `MU` writer - Month units in BCD format
16pub type MU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
17/**Month tens in BCD format
18
19Value on reset: 0*/
20#[cfg_attr(feature = "defmt", derive(defmt::Format))]
21#[derive(Clone, Copy, Debug, PartialEq, Eq)]
22pub enum MT {
23    ///0: Month tens is 0
24    Zero = 0,
25    ///1: Month tens is 1
26    One = 1,
27}
28impl From<MT> for bool {
29    #[inline(always)]
30    fn from(variant: MT) -> Self {
31        variant as u8 != 0
32    }
33}
34///Field `MT` reader - Month tens in BCD format
35pub type MT_R = crate::BitReader<MT>;
36impl MT_R {
37    ///Get enumerated values variant
38    #[inline(always)]
39    pub const fn variant(&self) -> MT {
40        match self.bits {
41            false => MT::Zero,
42            true => MT::One,
43        }
44    }
45    ///Month tens is 0
46    #[inline(always)]
47    pub fn is_zero(&self) -> bool {
48        *self == MT::Zero
49    }
50    ///Month tens is 1
51    #[inline(always)]
52    pub fn is_one(&self) -> bool {
53        *self == MT::One
54    }
55}
56///Field `MT` writer - Month tens in BCD format
57pub type MT_W<'a, REG> = crate::BitWriter<'a, REG, MT>;
58impl<'a, REG> MT_W<'a, REG>
59where
60    REG: crate::Writable + crate::RegisterSpec,
61{
62    ///Month tens is 0
63    #[inline(always)]
64    pub fn zero(self) -> &'a mut crate::W<REG> {
65        self.variant(MT::Zero)
66    }
67    ///Month tens is 1
68    #[inline(always)]
69    pub fn one(self) -> &'a mut crate::W<REG> {
70        self.variant(MT::One)
71    }
72}
73///Field `WDU` reader - Week day units
74pub type WDU_R = crate::FieldReader;
75///Field `WDU` writer - Week day units
76pub type WDU_W<'a, REG> = crate::FieldWriter<'a, REG, 3>;
77///Field `YU` reader - Year units in BCD format
78pub type YU_R = crate::FieldReader;
79///Field `YU` writer - Year units in BCD format
80pub type YU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
81///Field `YT` reader - Year tens in BCD format
82pub type YT_R = crate::FieldReader;
83///Field `YT` writer - Year tens in BCD format
84pub type YT_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
85impl R {
86    ///Bits 0:3 - Date units in BCD format
87    #[inline(always)]
88    pub fn du(&self) -> DU_R {
89        DU_R::new((self.bits & 0x0f) as u8)
90    }
91    ///Bits 4:5 - Date tens in BCD format
92    #[inline(always)]
93    pub fn dt(&self) -> DT_R {
94        DT_R::new(((self.bits >> 4) & 3) as u8)
95    }
96    ///Bits 8:11 - Month units in BCD format
97    #[inline(always)]
98    pub fn mu(&self) -> MU_R {
99        MU_R::new(((self.bits >> 8) & 0x0f) as u8)
100    }
101    ///Bit 12 - Month tens in BCD format
102    #[inline(always)]
103    pub fn mt(&self) -> MT_R {
104        MT_R::new(((self.bits >> 12) & 1) != 0)
105    }
106    ///Bits 13:15 - Week day units
107    #[inline(always)]
108    pub fn wdu(&self) -> WDU_R {
109        WDU_R::new(((self.bits >> 13) & 7) as u8)
110    }
111    ///Bits 16:19 - Year units in BCD format
112    #[inline(always)]
113    pub fn yu(&self) -> YU_R {
114        YU_R::new(((self.bits >> 16) & 0x0f) as u8)
115    }
116    ///Bits 20:23 - Year tens in BCD format
117    #[inline(always)]
118    pub fn yt(&self) -> YT_R {
119        YT_R::new(((self.bits >> 20) & 0x0f) as u8)
120    }
121}
122impl core::fmt::Debug for R {
123    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
124        f.debug_struct("DR")
125            .field("yt", &self.yt())
126            .field("yu", &self.yu())
127            .field("wdu", &self.wdu())
128            .field("mt", &self.mt())
129            .field("mu", &self.mu())
130            .field("dt", &self.dt())
131            .field("du", &self.du())
132            .finish()
133    }
134}
135impl W {
136    ///Bits 0:3 - Date units in BCD format
137    #[inline(always)]
138    pub fn du(&mut self) -> DU_W<DRrs> {
139        DU_W::new(self, 0)
140    }
141    ///Bits 4:5 - Date tens in BCD format
142    #[inline(always)]
143    pub fn dt(&mut self) -> DT_W<DRrs> {
144        DT_W::new(self, 4)
145    }
146    ///Bits 8:11 - Month units in BCD format
147    #[inline(always)]
148    pub fn mu(&mut self) -> MU_W<DRrs> {
149        MU_W::new(self, 8)
150    }
151    ///Bit 12 - Month tens in BCD format
152    #[inline(always)]
153    pub fn mt(&mut self) -> MT_W<DRrs> {
154        MT_W::new(self, 12)
155    }
156    ///Bits 13:15 - Week day units
157    #[inline(always)]
158    pub fn wdu(&mut self) -> WDU_W<DRrs> {
159        WDU_W::new(self, 13)
160    }
161    ///Bits 16:19 - Year units in BCD format
162    #[inline(always)]
163    pub fn yu(&mut self) -> YU_W<DRrs> {
164        YU_W::new(self, 16)
165    }
166    ///Bits 20:23 - Year tens in BCD format
167    #[inline(always)]
168    pub fn yt(&mut self) -> YT_W<DRrs> {
169        YT_W::new(self, 20)
170    }
171}
172/**date register
173
174You can [`read`](crate::Reg::read) this register and get [`dr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`dr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
175
176See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F733.html#RTC:DR)*/
177pub struct DRrs;
178impl crate::RegisterSpec for DRrs {
179    type Ux = u32;
180}
181///`read()` method returns [`dr::R`](R) reader structure
182impl crate::Readable for DRrs {}
183///`write(|w| ..)` method takes [`dr::W`](W) writer structure
184impl crate::Writable for DRrs {
185    type Safety = crate::Unsafe;
186}
187///`reset()` method sets DR to value 0x2101
188impl crate::Resettable for DRrs {
189    const RESET_VALUE: u32 = 0x2101;
190}