s32k142_pac/rtc/
sr.rs

1#[doc = "Register `SR` reader"]
2pub struct R(crate::R<SR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SR` writer"]
17pub struct W(crate::W<SR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SR_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<SR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Time Invalid Flag\n\nValue on reset: 1"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum TIF_A {
40    #[doc = "0: Time is valid."]
41    _0 = 0,
42    #[doc = "1: Time is invalid and time counter is read as zero."]
43    _1 = 1,
44}
45impl From<TIF_A> for bool {
46    #[inline(always)]
47    fn from(variant: TIF_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `TIF` reader - Time Invalid Flag"]
52pub struct TIF_R(crate::FieldReader<bool, TIF_A>);
53impl TIF_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        TIF_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> TIF_A {
61        match self.bits {
62            false => TIF_A::_0,
63            true => TIF_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        **self == TIF_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        **self == TIF_A::_1
75    }
76}
77impl core::ops::Deref for TIF_R {
78    type Target = crate::FieldReader<bool, TIF_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Time Overflow Flag\n\nValue on reset: 0"]
85#[derive(Clone, Copy, Debug, PartialEq)]
86pub enum TOF_A {
87    #[doc = "0: Time overflow has not occurred."]
88    _0 = 0,
89    #[doc = "1: Time overflow has occurred and time counter is read as zero."]
90    _1 = 1,
91}
92impl From<TOF_A> for bool {
93    #[inline(always)]
94    fn from(variant: TOF_A) -> Self {
95        variant as u8 != 0
96    }
97}
98#[doc = "Field `TOF` reader - Time Overflow Flag"]
99pub struct TOF_R(crate::FieldReader<bool, TOF_A>);
100impl TOF_R {
101    #[inline(always)]
102    pub(crate) fn new(bits: bool) -> Self {
103        TOF_R(crate::FieldReader::new(bits))
104    }
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> TOF_A {
108        match self.bits {
109            false => TOF_A::_0,
110            true => TOF_A::_1,
111        }
112    }
113    #[doc = "Checks if the value of the field is `_0`"]
114    #[inline(always)]
115    pub fn is_0(&self) -> bool {
116        **self == TOF_A::_0
117    }
118    #[doc = "Checks if the value of the field is `_1`"]
119    #[inline(always)]
120    pub fn is_1(&self) -> bool {
121        **self == TOF_A::_1
122    }
123}
124impl core::ops::Deref for TOF_R {
125    type Target = crate::FieldReader<bool, TOF_A>;
126    #[inline(always)]
127    fn deref(&self) -> &Self::Target {
128        &self.0
129    }
130}
131#[doc = "Time Alarm Flag\n\nValue on reset: 0"]
132#[derive(Clone, Copy, Debug, PartialEq)]
133pub enum TAF_A {
134    #[doc = "0: Time alarm has not occurred."]
135    _0 = 0,
136    #[doc = "1: Time alarm has occurred."]
137    _1 = 1,
138}
139impl From<TAF_A> for bool {
140    #[inline(always)]
141    fn from(variant: TAF_A) -> Self {
142        variant as u8 != 0
143    }
144}
145#[doc = "Field `TAF` reader - Time Alarm Flag"]
146pub struct TAF_R(crate::FieldReader<bool, TAF_A>);
147impl TAF_R {
148    #[inline(always)]
149    pub(crate) fn new(bits: bool) -> Self {
150        TAF_R(crate::FieldReader::new(bits))
151    }
152    #[doc = r"Get enumerated values variant"]
153    #[inline(always)]
154    pub fn variant(&self) -> TAF_A {
155        match self.bits {
156            false => TAF_A::_0,
157            true => TAF_A::_1,
158        }
159    }
160    #[doc = "Checks if the value of the field is `_0`"]
161    #[inline(always)]
162    pub fn is_0(&self) -> bool {
163        **self == TAF_A::_0
164    }
165    #[doc = "Checks if the value of the field is `_1`"]
166    #[inline(always)]
167    pub fn is_1(&self) -> bool {
168        **self == TAF_A::_1
169    }
170}
171impl core::ops::Deref for TAF_R {
172    type Target = crate::FieldReader<bool, TAF_A>;
173    #[inline(always)]
174    fn deref(&self) -> &Self::Target {
175        &self.0
176    }
177}
178#[doc = "Time Counter Enable\n\nValue on reset: 0"]
179#[derive(Clone, Copy, Debug, PartialEq)]
180pub enum TCE_A {
181    #[doc = "0: Time counter is disabled."]
182    _0 = 0,
183    #[doc = "1: Time counter is enabled."]
184    _1 = 1,
185}
186impl From<TCE_A> for bool {
187    #[inline(always)]
188    fn from(variant: TCE_A) -> Self {
189        variant as u8 != 0
190    }
191}
192#[doc = "Field `TCE` reader - Time Counter Enable"]
193pub struct TCE_R(crate::FieldReader<bool, TCE_A>);
194impl TCE_R {
195    #[inline(always)]
196    pub(crate) fn new(bits: bool) -> Self {
197        TCE_R(crate::FieldReader::new(bits))
198    }
199    #[doc = r"Get enumerated values variant"]
200    #[inline(always)]
201    pub fn variant(&self) -> TCE_A {
202        match self.bits {
203            false => TCE_A::_0,
204            true => TCE_A::_1,
205        }
206    }
207    #[doc = "Checks if the value of the field is `_0`"]
208    #[inline(always)]
209    pub fn is_0(&self) -> bool {
210        **self == TCE_A::_0
211    }
212    #[doc = "Checks if the value of the field is `_1`"]
213    #[inline(always)]
214    pub fn is_1(&self) -> bool {
215        **self == TCE_A::_1
216    }
217}
218impl core::ops::Deref for TCE_R {
219    type Target = crate::FieldReader<bool, TCE_A>;
220    #[inline(always)]
221    fn deref(&self) -> &Self::Target {
222        &self.0
223    }
224}
225#[doc = "Field `TCE` writer - Time Counter Enable"]
226pub struct TCE_W<'a> {
227    w: &'a mut W,
228}
229impl<'a> TCE_W<'a> {
230    #[doc = r"Writes `variant` to the field"]
231    #[inline(always)]
232    pub fn variant(self, variant: TCE_A) -> &'a mut W {
233        self.bit(variant.into())
234    }
235    #[doc = "Time counter is disabled."]
236    #[inline(always)]
237    pub fn _0(self) -> &'a mut W {
238        self.variant(TCE_A::_0)
239    }
240    #[doc = "Time counter is enabled."]
241    #[inline(always)]
242    pub fn _1(self) -> &'a mut W {
243        self.variant(TCE_A::_1)
244    }
245    #[doc = r"Sets the field bit"]
246    #[inline(always)]
247    pub fn set_bit(self) -> &'a mut W {
248        self.bit(true)
249    }
250    #[doc = r"Clears the field bit"]
251    #[inline(always)]
252    pub fn clear_bit(self) -> &'a mut W {
253        self.bit(false)
254    }
255    #[doc = r"Writes raw bits to the field"]
256    #[inline(always)]
257    pub fn bit(self, value: bool) -> &'a mut W {
258        self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
259        self.w
260    }
261}
262impl R {
263    #[doc = "Bit 0 - Time Invalid Flag"]
264    #[inline(always)]
265    pub fn tif(&self) -> TIF_R {
266        TIF_R::new((self.bits & 0x01) != 0)
267    }
268    #[doc = "Bit 1 - Time Overflow Flag"]
269    #[inline(always)]
270    pub fn tof(&self) -> TOF_R {
271        TOF_R::new(((self.bits >> 1) & 0x01) != 0)
272    }
273    #[doc = "Bit 2 - Time Alarm Flag"]
274    #[inline(always)]
275    pub fn taf(&self) -> TAF_R {
276        TAF_R::new(((self.bits >> 2) & 0x01) != 0)
277    }
278    #[doc = "Bit 4 - Time Counter Enable"]
279    #[inline(always)]
280    pub fn tce(&self) -> TCE_R {
281        TCE_R::new(((self.bits >> 4) & 0x01) != 0)
282    }
283}
284impl W {
285    #[doc = "Bit 4 - Time Counter Enable"]
286    #[inline(always)]
287    pub fn tce(&mut self) -> TCE_W {
288        TCE_W { w: self }
289    }
290    #[doc = "Writes raw bits to the register."]
291    #[inline(always)]
292    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
293        self.0.bits(bits);
294        self
295    }
296}
297#[doc = "RTC Status Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sr](index.html) module"]
298pub struct SR_SPEC;
299impl crate::RegisterSpec for SR_SPEC {
300    type Ux = u32;
301}
302#[doc = "`read()` method returns [sr::R](R) reader structure"]
303impl crate::Readable for SR_SPEC {
304    type Reader = R;
305}
306#[doc = "`write(|w| ..)` method takes [sr::W](W) writer structure"]
307impl crate::Writable for SR_SPEC {
308    type Writer = W;
309}
310#[doc = "`reset()` method sets SR to value 0x01"]
311impl crate::Resettable for SR_SPEC {
312    #[inline(always)]
313    fn reset_value() -> Self::Ux {
314        0x01
315    }
316}