mcxa_pac/rtc0/
sr.rs

1#[doc = "Register `SR` reader"]
2pub type R = crate::R<SrSpec>;
3#[doc = "Register `SR` writer"]
4pub type W = crate::W<SrSpec>;
5#[doc = "Time Invalid Flag\n\nValue on reset: 1"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Tif {
9    #[doc = "0: Time is valid."]
10    Tif0 = 0,
11    #[doc = "1: Time is invalid and time counter is read as zero."]
12    Tif1 = 1,
13}
14impl From<Tif> for bool {
15    #[inline(always)]
16    fn from(variant: Tif) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `TIF` reader - Time Invalid Flag"]
21pub type TifR = crate::BitReader<Tif>;
22impl TifR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Tif {
26        match self.bits {
27            false => Tif::Tif0,
28            true => Tif::Tif1,
29        }
30    }
31    #[doc = "Time is valid."]
32    #[inline(always)]
33    pub fn is_tif_0(&self) -> bool {
34        *self == Tif::Tif0
35    }
36    #[doc = "Time is invalid and time counter is read as zero."]
37    #[inline(always)]
38    pub fn is_tif_1(&self) -> bool {
39        *self == Tif::Tif1
40    }
41}
42#[doc = "Time Overflow Flag\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum Tof {
46    #[doc = "0: Time overflow has not occurred."]
47    Tof0 = 0,
48    #[doc = "1: Time overflow has occurred and time counter reads as zero."]
49    Tof1 = 1,
50}
51impl From<Tof> for bool {
52    #[inline(always)]
53    fn from(variant: Tof) -> Self {
54        variant as u8 != 0
55    }
56}
57#[doc = "Field `TOF` reader - Time Overflow Flag"]
58pub type TofR = crate::BitReader<Tof>;
59impl TofR {
60    #[doc = "Get enumerated values variant"]
61    #[inline(always)]
62    pub const fn variant(&self) -> Tof {
63        match self.bits {
64            false => Tof::Tof0,
65            true => Tof::Tof1,
66        }
67    }
68    #[doc = "Time overflow has not occurred."]
69    #[inline(always)]
70    pub fn is_tof_0(&self) -> bool {
71        *self == Tof::Tof0
72    }
73    #[doc = "Time overflow has occurred and time counter reads as zero."]
74    #[inline(always)]
75    pub fn is_tof_1(&self) -> bool {
76        *self == Tof::Tof1
77    }
78}
79#[doc = "Time Alarm Flag\n\nValue on reset: 0"]
80#[cfg_attr(feature = "defmt", derive(defmt::Format))]
81#[derive(Clone, Copy, Debug, PartialEq, Eq)]
82pub enum Taf {
83    #[doc = "0: Time alarm has not occurred."]
84    Taf0 = 0,
85    #[doc = "1: Time alarm has occurred."]
86    Taf1 = 1,
87}
88impl From<Taf> for bool {
89    #[inline(always)]
90    fn from(variant: Taf) -> Self {
91        variant as u8 != 0
92    }
93}
94#[doc = "Field `TAF` reader - Time Alarm Flag"]
95pub type TafR = crate::BitReader<Taf>;
96impl TafR {
97    #[doc = "Get enumerated values variant"]
98    #[inline(always)]
99    pub const fn variant(&self) -> Taf {
100        match self.bits {
101            false => Taf::Taf0,
102            true => Taf::Taf1,
103        }
104    }
105    #[doc = "Time alarm has not occurred."]
106    #[inline(always)]
107    pub fn is_taf_0(&self) -> bool {
108        *self == Taf::Taf0
109    }
110    #[doc = "Time alarm has occurred."]
111    #[inline(always)]
112    pub fn is_taf_1(&self) -> bool {
113        *self == Taf::Taf1
114    }
115}
116#[doc = "Time Counter Enable\n\nValue on reset: 0"]
117#[cfg_attr(feature = "defmt", derive(defmt::Format))]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum Tce {
120    #[doc = "0: Disables."]
121    Tce0 = 0,
122    #[doc = "1: Enables."]
123    Tce1 = 1,
124}
125impl From<Tce> for bool {
126    #[inline(always)]
127    fn from(variant: Tce) -> Self {
128        variant as u8 != 0
129    }
130}
131#[doc = "Field `TCE` reader - Time Counter Enable"]
132pub type TceR = crate::BitReader<Tce>;
133impl TceR {
134    #[doc = "Get enumerated values variant"]
135    #[inline(always)]
136    pub const fn variant(&self) -> Tce {
137        match self.bits {
138            false => Tce::Tce0,
139            true => Tce::Tce1,
140        }
141    }
142    #[doc = "Disables."]
143    #[inline(always)]
144    pub fn is_tce_0(&self) -> bool {
145        *self == Tce::Tce0
146    }
147    #[doc = "Enables."]
148    #[inline(always)]
149    pub fn is_tce_1(&self) -> bool {
150        *self == Tce::Tce1
151    }
152}
153#[doc = "Field `TCE` writer - Time Counter Enable"]
154pub type TceW<'a, REG> = crate::BitWriter<'a, REG, Tce>;
155impl<'a, REG> TceW<'a, REG>
156where
157    REG: crate::Writable + crate::RegisterSpec,
158{
159    #[doc = "Disables."]
160    #[inline(always)]
161    pub fn tce_0(self) -> &'a mut crate::W<REG> {
162        self.variant(Tce::Tce0)
163    }
164    #[doc = "Enables."]
165    #[inline(always)]
166    pub fn tce_1(self) -> &'a mut crate::W<REG> {
167        self.variant(Tce::Tce1)
168    }
169}
170impl R {
171    #[doc = "Bit 0 - Time Invalid Flag"]
172    #[inline(always)]
173    pub fn tif(&self) -> TifR {
174        TifR::new((self.bits & 1) != 0)
175    }
176    #[doc = "Bit 1 - Time Overflow Flag"]
177    #[inline(always)]
178    pub fn tof(&self) -> TofR {
179        TofR::new(((self.bits >> 1) & 1) != 0)
180    }
181    #[doc = "Bit 2 - Time Alarm Flag"]
182    #[inline(always)]
183    pub fn taf(&self) -> TafR {
184        TafR::new(((self.bits >> 2) & 1) != 0)
185    }
186    #[doc = "Bit 4 - Time Counter Enable"]
187    #[inline(always)]
188    pub fn tce(&self) -> TceR {
189        TceR::new(((self.bits >> 4) & 1) != 0)
190    }
191}
192#[cfg(feature = "debug")]
193impl core::fmt::Debug for R {
194    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
195        f.debug_struct("SR")
196            .field("tif", &self.tif())
197            .field("tof", &self.tof())
198            .field("taf", &self.taf())
199            .field("tce", &self.tce())
200            .finish()
201    }
202}
203impl W {
204    #[doc = "Bit 4 - Time Counter Enable"]
205    #[inline(always)]
206    pub fn tce(&mut self) -> TceW<'_, SrSpec> {
207        TceW::new(self, 4)
208    }
209}
210#[doc = "RTC Status\n\nYou can [`read`](crate::Reg::read) this register and get [`sr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
211pub struct SrSpec;
212impl crate::RegisterSpec for SrSpec {
213    type Ux = u32;
214}
215#[doc = "`read()` method returns [`sr::R`](R) reader structure"]
216impl crate::Readable for SrSpec {}
217#[doc = "`write(|w| ..)` method takes [`sr::W`](W) writer structure"]
218impl crate::Writable for SrSpec {
219    type Safety = crate::Unsafe;
220}
221#[doc = "`reset()` method sets SR to value 0x01"]
222impl crate::Resettable for SrSpec {
223    const RESET_VALUE: u32 = 0x01;
224}