stm32g0_staging/stm32g0b0/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\]
164represents the date units*/
165    DateUnits = 0,
166    /**1: DU\[3:0\]
167represents the week day. DT\[1:0\]
168is don’t care.*/
169    WeekDay = 1,
170}
171impl From<WDSEL> for bool {
172    #[inline(always)]
173    fn from(variant: WDSEL) -> Self {
174        variant as u8 != 0
175    }
176}
177///Field `WDSEL` reader - Week day selection
178pub type WDSEL_R = crate::BitReader<WDSEL>;
179impl WDSEL_R {
180    ///Get enumerated values variant
181    #[inline(always)]
182    pub const fn variant(&self) -> WDSEL {
183        match self.bits {
184            false => WDSEL::DateUnits,
185            true => WDSEL::WeekDay,
186        }
187    }
188    /**DU\[3:0\]
189represents the date units*/
190    #[inline(always)]
191    pub fn is_date_units(&self) -> bool {
192        *self == WDSEL::DateUnits
193    }
194    /**DU\[3:0\]
195represents the week day. DT\[1:0\]
196is don’t care.*/
197    #[inline(always)]
198    pub fn is_week_day(&self) -> bool {
199        *self == WDSEL::WeekDay
200    }
201}
202///Field `WDSEL` writer - Week day selection
203pub type WDSEL_W<'a, REG> = crate::BitWriter<'a, REG, WDSEL>;
204impl<'a, REG> WDSEL_W<'a, REG>
205where
206    REG: crate::Writable + crate::RegisterSpec,
207{
208    /**DU\[3:0\]
209represents the date units*/
210    #[inline(always)]
211    pub fn date_units(self) -> &'a mut crate::W<REG> {
212        self.variant(WDSEL::DateUnits)
213    }
214    /**DU\[3:0\]
215represents the week day. DT\[1:0\]
216is don’t care.*/
217    #[inline(always)]
218    pub fn week_day(self) -> &'a mut crate::W<REG> {
219        self.variant(WDSEL::WeekDay)
220    }
221}
222///Field `MSK4` reader - Alarm date mask
223pub use MSK1_R as MSK4_R;
224///Field `MSK4` writer - Alarm date mask
225pub use MSK1_W as MSK4_W;
226impl R {
227    ///Bits 0:3 - Second units in BCD format
228    #[inline(always)]
229    pub fn su(&self) -> SU_R {
230        SU_R::new((self.bits & 0x0f) as u8)
231    }
232    ///Bits 4:6 - Second tens in BCD format
233    #[inline(always)]
234    pub fn st(&self) -> ST_R {
235        ST_R::new(((self.bits >> 4) & 7) as u8)
236    }
237    ///Bit 7 - Alarm seconds mask
238    #[inline(always)]
239    pub fn msk1(&self) -> MSK1_R {
240        MSK1_R::new(((self.bits >> 7) & 1) != 0)
241    }
242    ///Bits 8:11 - Minute units in BCD format
243    #[inline(always)]
244    pub fn mnu(&self) -> MNU_R {
245        MNU_R::new(((self.bits >> 8) & 0x0f) as u8)
246    }
247    ///Bits 12:14 - Minute tens in BCD format
248    #[inline(always)]
249    pub fn mnt(&self) -> MNT_R {
250        MNT_R::new(((self.bits >> 12) & 7) as u8)
251    }
252    ///Bit 15 - Alarm minutes mask
253    #[inline(always)]
254    pub fn msk2(&self) -> MSK2_R {
255        MSK2_R::new(((self.bits >> 15) & 1) != 0)
256    }
257    ///Bits 16:19 - Hour units in BCD format
258    #[inline(always)]
259    pub fn hu(&self) -> HU_R {
260        HU_R::new(((self.bits >> 16) & 0x0f) as u8)
261    }
262    ///Bits 20:21 - Hour tens in BCD format
263    #[inline(always)]
264    pub fn ht(&self) -> HT_R {
265        HT_R::new(((self.bits >> 20) & 3) as u8)
266    }
267    ///Bit 22 - AM/PM notation
268    #[inline(always)]
269    pub fn pm(&self) -> PM_R {
270        PM_R::new(((self.bits >> 22) & 1) != 0)
271    }
272    ///Bit 23 - Alarm hours mask
273    #[inline(always)]
274    pub fn msk3(&self) -> MSK3_R {
275        MSK3_R::new(((self.bits >> 23) & 1) != 0)
276    }
277    ///Bits 24:27 - Date units or day in BCD format
278    #[inline(always)]
279    pub fn du(&self) -> DU_R {
280        DU_R::new(((self.bits >> 24) & 0x0f) as u8)
281    }
282    ///Bits 28:29 - Date tens in BCD format
283    #[inline(always)]
284    pub fn dt(&self) -> DT_R {
285        DT_R::new(((self.bits >> 28) & 3) as u8)
286    }
287    ///Bit 30 - Week day selection
288    #[inline(always)]
289    pub fn wdsel(&self) -> WDSEL_R {
290        WDSEL_R::new(((self.bits >> 30) & 1) != 0)
291    }
292    ///Bit 31 - Alarm date mask
293    #[inline(always)]
294    pub fn msk4(&self) -> MSK4_R {
295        MSK4_R::new(((self.bits >> 31) & 1) != 0)
296    }
297}
298impl core::fmt::Debug for R {
299    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
300        f.debug_struct("ALRMR")
301            .field("su", &self.su())
302            .field("st", &self.st())
303            .field("msk1", &self.msk1())
304            .field("mnu", &self.mnu())
305            .field("mnt", &self.mnt())
306            .field("msk2", &self.msk2())
307            .field("hu", &self.hu())
308            .field("ht", &self.ht())
309            .field("pm", &self.pm())
310            .field("msk3", &self.msk3())
311            .field("du", &self.du())
312            .field("dt", &self.dt())
313            .field("wdsel", &self.wdsel())
314            .field("msk4", &self.msk4())
315            .finish()
316    }
317}
318impl W {
319    ///Bits 0:3 - Second units in BCD format
320    #[inline(always)]
321    pub fn su(&mut self) -> SU_W<ALRMRrs> {
322        SU_W::new(self, 0)
323    }
324    ///Bits 4:6 - Second tens in BCD format
325    #[inline(always)]
326    pub fn st(&mut self) -> ST_W<ALRMRrs> {
327        ST_W::new(self, 4)
328    }
329    ///Bit 7 - Alarm seconds mask
330    #[inline(always)]
331    pub fn msk1(&mut self) -> MSK1_W<ALRMRrs> {
332        MSK1_W::new(self, 7)
333    }
334    ///Bits 8:11 - Minute units in BCD format
335    #[inline(always)]
336    pub fn mnu(&mut self) -> MNU_W<ALRMRrs> {
337        MNU_W::new(self, 8)
338    }
339    ///Bits 12:14 - Minute tens in BCD format
340    #[inline(always)]
341    pub fn mnt(&mut self) -> MNT_W<ALRMRrs> {
342        MNT_W::new(self, 12)
343    }
344    ///Bit 15 - Alarm minutes mask
345    #[inline(always)]
346    pub fn msk2(&mut self) -> MSK2_W<ALRMRrs> {
347        MSK2_W::new(self, 15)
348    }
349    ///Bits 16:19 - Hour units in BCD format
350    #[inline(always)]
351    pub fn hu(&mut self) -> HU_W<ALRMRrs> {
352        HU_W::new(self, 16)
353    }
354    ///Bits 20:21 - Hour tens in BCD format
355    #[inline(always)]
356    pub fn ht(&mut self) -> HT_W<ALRMRrs> {
357        HT_W::new(self, 20)
358    }
359    ///Bit 22 - AM/PM notation
360    #[inline(always)]
361    pub fn pm(&mut self) -> PM_W<ALRMRrs> {
362        PM_W::new(self, 22)
363    }
364    ///Bit 23 - Alarm hours mask
365    #[inline(always)]
366    pub fn msk3(&mut self) -> MSK3_W<ALRMRrs> {
367        MSK3_W::new(self, 23)
368    }
369    ///Bits 24:27 - Date units or day in BCD format
370    #[inline(always)]
371    pub fn du(&mut self) -> DU_W<ALRMRrs> {
372        DU_W::new(self, 24)
373    }
374    ///Bits 28:29 - Date tens in BCD format
375    #[inline(always)]
376    pub fn dt(&mut self) -> DT_W<ALRMRrs> {
377        DT_W::new(self, 28)
378    }
379    ///Bit 30 - Week day selection
380    #[inline(always)]
381    pub fn wdsel(&mut self) -> WDSEL_W<ALRMRrs> {
382        WDSEL_W::new(self, 30)
383    }
384    ///Bit 31 - Alarm date mask
385    #[inline(always)]
386    pub fn msk4(&mut self) -> MSK4_W<ALRMRrs> {
387        MSK4_W::new(self, 31)
388    }
389}
390/**Alarm %s register
391
392You 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).
393
394See register [structure](https://stm32-rs.github.io/stm32-rs/STM32G0B0.html#RTC:ALRM[A]R)*/
395pub struct ALRMRrs;
396impl crate::RegisterSpec for ALRMRrs {
397    type Ux = u32;
398}
399///`read()` method returns [`alrmr::R`](R) reader structure
400impl crate::Readable for ALRMRrs {}
401///`write(|w| ..)` method takes [`alrmr::W`](W) writer structure
402impl crate::Writable for ALRMRrs {
403    type Safety = crate::Unsafe;
404    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
405    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
406}
407///`reset()` method sets ALRM%sR to value 0
408impl crate::Resettable for ALRMRrs {
409    const RESET_VALUE: u32 = 0;
410}