stm32f4/stm32f407/rtc/
alrmr.rs

1///Register `ALRM%sR` reader
2pub type R = crate::R<ALRMRrs>;
3///Register `ALRM%sR` writer
4pub type W = crate::W<ALRMRrs>;
5///Field `SU` reader - Second units in BCD format
6pub type SU_R = crate::FieldReader;
7///Field `SU` writer - Second units in BCD format
8pub type SU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
9///Field `ST` reader - Second tens in BCD format
10pub type ST_R = crate::FieldReader;
11///Field `ST` writer - Second tens in BCD format
12pub type ST_W<'a, REG> = crate::FieldWriter<'a, REG, 3, u8, crate::Safe>;
13/**Alarm seconds mask
14
15Value on reset: 0*/
16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17#[derive(Clone, Copy, Debug, PartialEq, Eq)]
18pub enum MSK1 {
19    ///0: Alarm set if the date/day match
20    Mask = 0,
21    ///1: Date/day don’t care in Alarm comparison
22    NotMask = 1,
23}
24impl From<MSK1> for bool {
25    #[inline(always)]
26    fn from(variant: MSK1) -> Self {
27        variant as u8 != 0
28    }
29}
30///Field `MSK1` reader - Alarm seconds mask
31pub type MSK1_R = crate::BitReader<MSK1>;
32impl MSK1_R {
33    ///Get enumerated values variant
34    #[inline(always)]
35    pub const fn variant(&self) -> MSK1 {
36        match self.bits {
37            false => MSK1::Mask,
38            true => MSK1::NotMask,
39        }
40    }
41    ///Alarm set if the date/day match
42    #[inline(always)]
43    pub fn is_mask(&self) -> bool {
44        *self == MSK1::Mask
45    }
46    ///Date/day don’t care in Alarm comparison
47    #[inline(always)]
48    pub fn is_not_mask(&self) -> bool {
49        *self == MSK1::NotMask
50    }
51}
52///Field `MSK1` writer - Alarm seconds mask
53pub type MSK1_W<'a, REG> = crate::BitWriter<'a, REG, MSK1>;
54impl<'a, REG> MSK1_W<'a, REG>
55where
56    REG: crate::Writable + crate::RegisterSpec,
57{
58    ///Alarm set if the date/day match
59    #[inline(always)]
60    pub fn mask(self) -> &'a mut crate::W<REG> {
61        self.variant(MSK1::Mask)
62    }
63    ///Date/day don’t care in Alarm comparison
64    #[inline(always)]
65    pub fn not_mask(self) -> &'a mut crate::W<REG> {
66        self.variant(MSK1::NotMask)
67    }
68}
69///Field `MNU` reader - Minute units in BCD format
70pub type MNU_R = crate::FieldReader;
71///Field `MNU` writer - Minute units in BCD format
72pub type MNU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
73///Field `MNT` reader - Minute tens in BCD format
74pub type MNT_R = crate::FieldReader;
75///Field `MNT` writer - Minute tens in BCD format
76pub type MNT_W<'a, REG> = crate::FieldWriter<'a, REG, 3, u8, crate::Safe>;
77///Field `MSK2` reader - Alarm minutes mask
78pub use MSK1_R as MSK2_R;
79///Field `MSK2` writer - Alarm minutes mask
80pub use MSK1_W as MSK2_W;
81///Field `HU` reader - Hour units in BCD format
82pub type HU_R = crate::FieldReader;
83///Field `HU` writer - Hour units in BCD format
84pub type HU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
85///Field `HT` reader - Hour tens in BCD format
86pub type HT_R = crate::FieldReader;
87///Field `HT` writer - Hour tens in BCD format
88pub type HT_W<'a, REG> = crate::FieldWriter<'a, REG, 2, u8, crate::Safe>;
89/**AM/PM notation
90
91Value on reset: 0*/
92#[cfg_attr(feature = "defmt", derive(defmt::Format))]
93#[derive(Clone, Copy, Debug, PartialEq, Eq)]
94pub enum PM {
95    ///0: AM or 24-hour format
96    Am = 0,
97    ///1: PM
98    Pm = 1,
99}
100impl From<PM> for bool {
101    #[inline(always)]
102    fn from(variant: PM) -> Self {
103        variant as u8 != 0
104    }
105}
106///Field `PM` reader - AM/PM notation
107pub type PM_R = crate::BitReader<PM>;
108impl PM_R {
109    ///Get enumerated values variant
110    #[inline(always)]
111    pub const fn variant(&self) -> PM {
112        match self.bits {
113            false => PM::Am,
114            true => PM::Pm,
115        }
116    }
117    ///AM or 24-hour format
118    #[inline(always)]
119    pub fn is_am(&self) -> bool {
120        *self == PM::Am
121    }
122    ///PM
123    #[inline(always)]
124    pub fn is_pm(&self) -> bool {
125        *self == PM::Pm
126    }
127}
128///Field `PM` writer - AM/PM notation
129pub type PM_W<'a, REG> = crate::BitWriter<'a, REG, PM>;
130impl<'a, REG> PM_W<'a, REG>
131where
132    REG: crate::Writable + crate::RegisterSpec,
133{
134    ///AM or 24-hour format
135    #[inline(always)]
136    pub fn am(self) -> &'a mut crate::W<REG> {
137        self.variant(PM::Am)
138    }
139    ///PM
140    #[inline(always)]
141    pub fn pm(self) -> &'a mut crate::W<REG> {
142        self.variant(PM::Pm)
143    }
144}
145///Field `MSK3` reader - Alarm hours mask
146pub use MSK1_R as MSK3_R;
147///Field `MSK3` writer - Alarm hours mask
148pub use MSK1_W as MSK3_W;
149///Field `DU` reader - Date units or day in BCD format
150pub type DU_R = crate::FieldReader;
151///Field `DU` writer - Date units or day in BCD format
152pub type DU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
153///Field `DT` reader - Date tens in BCD format
154pub type DT_R = crate::FieldReader;
155///Field `DT` writer - Date tens in BCD format
156pub type DT_W<'a, REG> = crate::FieldWriter<'a, REG, 2, u8, crate::Safe>;
157/**Week day selection
158
159Value on reset: 0*/
160#[cfg_attr(feature = "defmt", derive(defmt::Format))]
161#[derive(Clone, Copy, Debug, PartialEq, Eq)]
162pub enum WDSEL {
163    ///0: DU\[3:0\] represents the date units
164    DateUnits = 0,
165    ///1: DU\[3:0\] represents the week day. DT\[1:0\] is don’t care.
166    WeekDay = 1,
167}
168impl From<WDSEL> for bool {
169    #[inline(always)]
170    fn from(variant: WDSEL) -> Self {
171        variant as u8 != 0
172    }
173}
174///Field `WDSEL` reader - Week day selection
175pub type WDSEL_R = crate::BitReader<WDSEL>;
176impl WDSEL_R {
177    ///Get enumerated values variant
178    #[inline(always)]
179    pub const fn variant(&self) -> WDSEL {
180        match self.bits {
181            false => WDSEL::DateUnits,
182            true => WDSEL::WeekDay,
183        }
184    }
185    ///DU\[3:0\] represents the date units
186    #[inline(always)]
187    pub fn is_date_units(&self) -> bool {
188        *self == WDSEL::DateUnits
189    }
190    ///DU\[3:0\] represents the week day. DT\[1:0\] is don’t care.
191    #[inline(always)]
192    pub fn is_week_day(&self) -> bool {
193        *self == WDSEL::WeekDay
194    }
195}
196///Field `WDSEL` writer - Week day selection
197pub type WDSEL_W<'a, REG> = crate::BitWriter<'a, REG, WDSEL>;
198impl<'a, REG> WDSEL_W<'a, REG>
199where
200    REG: crate::Writable + crate::RegisterSpec,
201{
202    ///DU\[3:0\] represents the date units
203    #[inline(always)]
204    pub fn date_units(self) -> &'a mut crate::W<REG> {
205        self.variant(WDSEL::DateUnits)
206    }
207    ///DU\[3:0\] represents the week day. DT\[1:0\] is don’t care.
208    #[inline(always)]
209    pub fn week_day(self) -> &'a mut crate::W<REG> {
210        self.variant(WDSEL::WeekDay)
211    }
212}
213///Field `MSK4` reader - Alarm date mask
214pub use MSK1_R as MSK4_R;
215///Field `MSK4` writer - Alarm date mask
216pub use MSK1_W as MSK4_W;
217impl R {
218    ///Bits 0:3 - Second units in BCD format
219    #[inline(always)]
220    pub fn su(&self) -> SU_R {
221        SU_R::new((self.bits & 0x0f) as u8)
222    }
223    ///Bits 4:6 - Second tens in BCD format
224    #[inline(always)]
225    pub fn st(&self) -> ST_R {
226        ST_R::new(((self.bits >> 4) & 7) as u8)
227    }
228    ///Bit 7 - Alarm seconds mask
229    #[inline(always)]
230    pub fn msk1(&self) -> MSK1_R {
231        MSK1_R::new(((self.bits >> 7) & 1) != 0)
232    }
233    ///Bits 8:11 - Minute units in BCD format
234    #[inline(always)]
235    pub fn mnu(&self) -> MNU_R {
236        MNU_R::new(((self.bits >> 8) & 0x0f) as u8)
237    }
238    ///Bits 12:14 - Minute tens in BCD format
239    #[inline(always)]
240    pub fn mnt(&self) -> MNT_R {
241        MNT_R::new(((self.bits >> 12) & 7) as u8)
242    }
243    ///Bit 15 - Alarm minutes mask
244    #[inline(always)]
245    pub fn msk2(&self) -> MSK2_R {
246        MSK2_R::new(((self.bits >> 15) & 1) != 0)
247    }
248    ///Bits 16:19 - Hour units in BCD format
249    #[inline(always)]
250    pub fn hu(&self) -> HU_R {
251        HU_R::new(((self.bits >> 16) & 0x0f) as u8)
252    }
253    ///Bits 20:21 - Hour tens in BCD format
254    #[inline(always)]
255    pub fn ht(&self) -> HT_R {
256        HT_R::new(((self.bits >> 20) & 3) as u8)
257    }
258    ///Bit 22 - AM/PM notation
259    #[inline(always)]
260    pub fn pm(&self) -> PM_R {
261        PM_R::new(((self.bits >> 22) & 1) != 0)
262    }
263    ///Bit 23 - Alarm hours mask
264    #[inline(always)]
265    pub fn msk3(&self) -> MSK3_R {
266        MSK3_R::new(((self.bits >> 23) & 1) != 0)
267    }
268    ///Bits 24:27 - Date units or day in BCD format
269    #[inline(always)]
270    pub fn du(&self) -> DU_R {
271        DU_R::new(((self.bits >> 24) & 0x0f) as u8)
272    }
273    ///Bits 28:29 - Date tens in BCD format
274    #[inline(always)]
275    pub fn dt(&self) -> DT_R {
276        DT_R::new(((self.bits >> 28) & 3) as u8)
277    }
278    ///Bit 30 - Week day selection
279    #[inline(always)]
280    pub fn wdsel(&self) -> WDSEL_R {
281        WDSEL_R::new(((self.bits >> 30) & 1) != 0)
282    }
283    ///Bit 31 - Alarm date mask
284    #[inline(always)]
285    pub fn msk4(&self) -> MSK4_R {
286        MSK4_R::new(((self.bits >> 31) & 1) != 0)
287    }
288}
289impl core::fmt::Debug for R {
290    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
291        f.debug_struct("ALRMR")
292            .field("msk1", &self.msk1())
293            .field("msk4", &self.msk4())
294            .field("wdsel", &self.wdsel())
295            .field("dt", &self.dt())
296            .field("du", &self.du())
297            .field("msk3", &self.msk3())
298            .field("pm", &self.pm())
299            .field("ht", &self.ht())
300            .field("hu", &self.hu())
301            .field("msk2", &self.msk2())
302            .field("mnt", &self.mnt())
303            .field("mnu", &self.mnu())
304            .field("st", &self.st())
305            .field("su", &self.su())
306            .finish()
307    }
308}
309impl W {
310    ///Bits 0:3 - Second units in BCD format
311    #[inline(always)]
312    pub fn su(&mut self) -> SU_W<ALRMRrs> {
313        SU_W::new(self, 0)
314    }
315    ///Bits 4:6 - Second tens in BCD format
316    #[inline(always)]
317    pub fn st(&mut self) -> ST_W<ALRMRrs> {
318        ST_W::new(self, 4)
319    }
320    ///Bit 7 - Alarm seconds mask
321    #[inline(always)]
322    pub fn msk1(&mut self) -> MSK1_W<ALRMRrs> {
323        MSK1_W::new(self, 7)
324    }
325    ///Bits 8:11 - Minute units in BCD format
326    #[inline(always)]
327    pub fn mnu(&mut self) -> MNU_W<ALRMRrs> {
328        MNU_W::new(self, 8)
329    }
330    ///Bits 12:14 - Minute tens in BCD format
331    #[inline(always)]
332    pub fn mnt(&mut self) -> MNT_W<ALRMRrs> {
333        MNT_W::new(self, 12)
334    }
335    ///Bit 15 - Alarm minutes mask
336    #[inline(always)]
337    pub fn msk2(&mut self) -> MSK2_W<ALRMRrs> {
338        MSK2_W::new(self, 15)
339    }
340    ///Bits 16:19 - Hour units in BCD format
341    #[inline(always)]
342    pub fn hu(&mut self) -> HU_W<ALRMRrs> {
343        HU_W::new(self, 16)
344    }
345    ///Bits 20:21 - Hour tens in BCD format
346    #[inline(always)]
347    pub fn ht(&mut self) -> HT_W<ALRMRrs> {
348        HT_W::new(self, 20)
349    }
350    ///Bit 22 - AM/PM notation
351    #[inline(always)]
352    pub fn pm(&mut self) -> PM_W<ALRMRrs> {
353        PM_W::new(self, 22)
354    }
355    ///Bit 23 - Alarm hours mask
356    #[inline(always)]
357    pub fn msk3(&mut self) -> MSK3_W<ALRMRrs> {
358        MSK3_W::new(self, 23)
359    }
360    ///Bits 24:27 - Date units or day in BCD format
361    #[inline(always)]
362    pub fn du(&mut self) -> DU_W<ALRMRrs> {
363        DU_W::new(self, 24)
364    }
365    ///Bits 28:29 - Date tens in BCD format
366    #[inline(always)]
367    pub fn dt(&mut self) -> DT_W<ALRMRrs> {
368        DT_W::new(self, 28)
369    }
370    ///Bit 30 - Week day selection
371    #[inline(always)]
372    pub fn wdsel(&mut self) -> WDSEL_W<ALRMRrs> {
373        WDSEL_W::new(self, 30)
374    }
375    ///Bit 31 - Alarm date mask
376    #[inline(always)]
377    pub fn msk4(&mut self) -> MSK4_W<ALRMRrs> {
378        MSK4_W::new(self, 31)
379    }
380}
381/**Alarm %s register
382
383You can [`read`](crate::Reg::read) this register and get [`alrmr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`alrmr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
384
385See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F407.html#RTC:ALRM[A]R)*/
386pub struct ALRMRrs;
387impl crate::RegisterSpec for ALRMRrs {
388    type Ux = u32;
389}
390///`read()` method returns [`alrmr::R`](R) reader structure
391impl crate::Readable for ALRMRrs {}
392///`write(|w| ..)` method takes [`alrmr::W`](W) writer structure
393impl crate::Writable for ALRMRrs {
394    type Safety = crate::Unsafe;
395}
396///`reset()` method sets ALRM%sR to value 0
397impl crate::Resettable for ALRMRrs {}