stm32f0/stm32f0x2/rtc/
tr.rs

1///Register `TR` reader
2pub type R = crate::R<TRrs>;
3///Register `TR` writer
4pub type W = crate::W<TRrs>;
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///Field `MNU` reader - Minute units in BCD format
14pub type MNU_R = crate::FieldReader;
15///Field `MNU` writer - Minute units in BCD format
16pub type MNU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
17///Field `MNT` reader - Minute tens in BCD format
18pub type MNT_R = crate::FieldReader;
19///Field `MNT` writer - Minute tens in BCD format
20pub type MNT_W<'a, REG> = crate::FieldWriter<'a, REG, 3, u8, crate::Safe>;
21///Field `HU` reader - Hour units in BCD format
22pub type HU_R = crate::FieldReader;
23///Field `HU` writer - Hour units in BCD format
24pub type HU_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
25///Field `HT` reader - Hour tens in BCD format
26pub type HT_R = crate::FieldReader;
27///Field `HT` writer - Hour tens in BCD format
28pub type HT_W<'a, REG> = crate::FieldWriter<'a, REG, 2, u8, crate::Safe>;
29/**AM/PM notation
30
31Value on reset: 0*/
32#[cfg_attr(feature = "defmt", derive(defmt::Format))]
33#[derive(Clone, Copy, Debug, PartialEq, Eq)]
34pub enum PM {
35    ///0: AM or 24-hour format
36    Am = 0,
37    ///1: PM
38    Pm = 1,
39}
40impl From<PM> for bool {
41    #[inline(always)]
42    fn from(variant: PM) -> Self {
43        variant as u8 != 0
44    }
45}
46///Field `PM` reader - AM/PM notation
47pub type PM_R = crate::BitReader<PM>;
48impl PM_R {
49    ///Get enumerated values variant
50    #[inline(always)]
51    pub const fn variant(&self) -> PM {
52        match self.bits {
53            false => PM::Am,
54            true => PM::Pm,
55        }
56    }
57    ///AM or 24-hour format
58    #[inline(always)]
59    pub fn is_am(&self) -> bool {
60        *self == PM::Am
61    }
62    ///PM
63    #[inline(always)]
64    pub fn is_pm(&self) -> bool {
65        *self == PM::Pm
66    }
67}
68///Field `PM` writer - AM/PM notation
69pub type PM_W<'a, REG> = crate::BitWriter<'a, REG, PM>;
70impl<'a, REG> PM_W<'a, REG>
71where
72    REG: crate::Writable + crate::RegisterSpec,
73{
74    ///AM or 24-hour format
75    #[inline(always)]
76    pub fn am(self) -> &'a mut crate::W<REG> {
77        self.variant(PM::Am)
78    }
79    ///PM
80    #[inline(always)]
81    pub fn pm(self) -> &'a mut crate::W<REG> {
82        self.variant(PM::Pm)
83    }
84}
85impl R {
86    ///Bits 0:3 - Second units in BCD format
87    #[inline(always)]
88    pub fn su(&self) -> SU_R {
89        SU_R::new((self.bits & 0x0f) as u8)
90    }
91    ///Bits 4:6 - Second tens in BCD format
92    #[inline(always)]
93    pub fn st(&self) -> ST_R {
94        ST_R::new(((self.bits >> 4) & 7) as u8)
95    }
96    ///Bits 8:11 - Minute units in BCD format
97    #[inline(always)]
98    pub fn mnu(&self) -> MNU_R {
99        MNU_R::new(((self.bits >> 8) & 0x0f) as u8)
100    }
101    ///Bits 12:14 - Minute tens in BCD format
102    #[inline(always)]
103    pub fn mnt(&self) -> MNT_R {
104        MNT_R::new(((self.bits >> 12) & 7) as u8)
105    }
106    ///Bits 16:19 - Hour units in BCD format
107    #[inline(always)]
108    pub fn hu(&self) -> HU_R {
109        HU_R::new(((self.bits >> 16) & 0x0f) as u8)
110    }
111    ///Bits 20:21 - Hour tens in BCD format
112    #[inline(always)]
113    pub fn ht(&self) -> HT_R {
114        HT_R::new(((self.bits >> 20) & 3) as u8)
115    }
116    ///Bit 22 - AM/PM notation
117    #[inline(always)]
118    pub fn pm(&self) -> PM_R {
119        PM_R::new(((self.bits >> 22) & 1) != 0)
120    }
121}
122impl core::fmt::Debug for R {
123    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
124        f.debug_struct("TR")
125            .field("pm", &self.pm())
126            .field("ht", &self.ht())
127            .field("hu", &self.hu())
128            .field("mnt", &self.mnt())
129            .field("mnu", &self.mnu())
130            .field("st", &self.st())
131            .field("su", &self.su())
132            .finish()
133    }
134}
135impl W {
136    ///Bits 0:3 - Second units in BCD format
137    #[inline(always)]
138    pub fn su(&mut self) -> SU_W<TRrs> {
139        SU_W::new(self, 0)
140    }
141    ///Bits 4:6 - Second tens in BCD format
142    #[inline(always)]
143    pub fn st(&mut self) -> ST_W<TRrs> {
144        ST_W::new(self, 4)
145    }
146    ///Bits 8:11 - Minute units in BCD format
147    #[inline(always)]
148    pub fn mnu(&mut self) -> MNU_W<TRrs> {
149        MNU_W::new(self, 8)
150    }
151    ///Bits 12:14 - Minute tens in BCD format
152    #[inline(always)]
153    pub fn mnt(&mut self) -> MNT_W<TRrs> {
154        MNT_W::new(self, 12)
155    }
156    ///Bits 16:19 - Hour units in BCD format
157    #[inline(always)]
158    pub fn hu(&mut self) -> HU_W<TRrs> {
159        HU_W::new(self, 16)
160    }
161    ///Bits 20:21 - Hour tens in BCD format
162    #[inline(always)]
163    pub fn ht(&mut self) -> HT_W<TRrs> {
164        HT_W::new(self, 20)
165    }
166    ///Bit 22 - AM/PM notation
167    #[inline(always)]
168    pub fn pm(&mut self) -> PM_W<TRrs> {
169        PM_W::new(self, 22)
170    }
171}
172/**time register
173
174You can [`read`](crate::Reg::read) this register and get [`tr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`tr::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/STM32F0x2.html#RTC:TR)*/
177pub struct TRrs;
178impl crate::RegisterSpec for TRrs {
179    type Ux = u32;
180}
181///`read()` method returns [`tr::R`](R) reader structure
182impl crate::Readable for TRrs {}
183///`write(|w| ..)` method takes [`tr::W`](W) writer structure
184impl crate::Writable for TRrs {
185    type Safety = crate::Unsafe;
186}
187///`reset()` method sets TR to value 0
188impl crate::Resettable for TRrs {}