atsams70j19/rtc/
rtc_sr.rs

1#[doc = "Register `RTC_SR` reader"]
2pub struct R(crate::R<RTC_SR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RTC_SR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RTC_SR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RTC_SR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Acknowledge for Update\n\nValue on reset: 0"]
17#[derive(Clone, Copy, Debug, PartialEq)]
18pub enum ACKUPD_A {
19    #[doc = "0: Time and calendar registers cannot be updated."]
20    FREERUN = 0,
21    #[doc = "1: Time and calendar registers can be updated."]
22    UPDATE = 1,
23}
24impl From<ACKUPD_A> for bool {
25    #[inline(always)]
26    fn from(variant: ACKUPD_A) -> Self {
27        variant as u8 != 0
28    }
29}
30#[doc = "Field `ACKUPD` reader - Acknowledge for Update"]
31pub struct ACKUPD_R(crate::FieldReader<bool, ACKUPD_A>);
32impl ACKUPD_R {
33    #[inline(always)]
34    pub(crate) fn new(bits: bool) -> Self {
35        ACKUPD_R(crate::FieldReader::new(bits))
36    }
37    #[doc = r"Get enumerated values variant"]
38    #[inline(always)]
39    pub fn variant(&self) -> ACKUPD_A {
40        match self.bits {
41            false => ACKUPD_A::FREERUN,
42            true => ACKUPD_A::UPDATE,
43        }
44    }
45    #[doc = "Checks if the value of the field is `FREERUN`"]
46    #[inline(always)]
47    pub fn is_freerun(&self) -> bool {
48        **self == ACKUPD_A::FREERUN
49    }
50    #[doc = "Checks if the value of the field is `UPDATE`"]
51    #[inline(always)]
52    pub fn is_update(&self) -> bool {
53        **self == ACKUPD_A::UPDATE
54    }
55}
56impl core::ops::Deref for ACKUPD_R {
57    type Target = crate::FieldReader<bool, ACKUPD_A>;
58    #[inline(always)]
59    fn deref(&self) -> &Self::Target {
60        &self.0
61    }
62}
63#[doc = "Alarm Flag\n\nValue on reset: 0"]
64#[derive(Clone, Copy, Debug, PartialEq)]
65pub enum ALARM_A {
66    #[doc = "0: No alarm matching condition occurred."]
67    NO_ALARMEVENT = 0,
68    #[doc = "1: An alarm matching condition has occurred."]
69    ALARMEVENT = 1,
70}
71impl From<ALARM_A> for bool {
72    #[inline(always)]
73    fn from(variant: ALARM_A) -> Self {
74        variant as u8 != 0
75    }
76}
77#[doc = "Field `ALARM` reader - Alarm Flag"]
78pub struct ALARM_R(crate::FieldReader<bool, ALARM_A>);
79impl ALARM_R {
80    #[inline(always)]
81    pub(crate) fn new(bits: bool) -> Self {
82        ALARM_R(crate::FieldReader::new(bits))
83    }
84    #[doc = r"Get enumerated values variant"]
85    #[inline(always)]
86    pub fn variant(&self) -> ALARM_A {
87        match self.bits {
88            false => ALARM_A::NO_ALARMEVENT,
89            true => ALARM_A::ALARMEVENT,
90        }
91    }
92    #[doc = "Checks if the value of the field is `NO_ALARMEVENT`"]
93    #[inline(always)]
94    pub fn is_no_alarmevent(&self) -> bool {
95        **self == ALARM_A::NO_ALARMEVENT
96    }
97    #[doc = "Checks if the value of the field is `ALARMEVENT`"]
98    #[inline(always)]
99    pub fn is_alarmevent(&self) -> bool {
100        **self == ALARM_A::ALARMEVENT
101    }
102}
103impl core::ops::Deref for ALARM_R {
104    type Target = crate::FieldReader<bool, ALARM_A>;
105    #[inline(always)]
106    fn deref(&self) -> &Self::Target {
107        &self.0
108    }
109}
110#[doc = "Second Event\n\nValue on reset: 0"]
111#[derive(Clone, Copy, Debug, PartialEq)]
112pub enum SEC_A {
113    #[doc = "0: No second event has occurred since the last clear."]
114    NO_SECEVENT = 0,
115    #[doc = "1: At least one second event has occurred since the last clear."]
116    SECEVENT = 1,
117}
118impl From<SEC_A> for bool {
119    #[inline(always)]
120    fn from(variant: SEC_A) -> Self {
121        variant as u8 != 0
122    }
123}
124#[doc = "Field `SEC` reader - Second Event"]
125pub struct SEC_R(crate::FieldReader<bool, SEC_A>);
126impl SEC_R {
127    #[inline(always)]
128    pub(crate) fn new(bits: bool) -> Self {
129        SEC_R(crate::FieldReader::new(bits))
130    }
131    #[doc = r"Get enumerated values variant"]
132    #[inline(always)]
133    pub fn variant(&self) -> SEC_A {
134        match self.bits {
135            false => SEC_A::NO_SECEVENT,
136            true => SEC_A::SECEVENT,
137        }
138    }
139    #[doc = "Checks if the value of the field is `NO_SECEVENT`"]
140    #[inline(always)]
141    pub fn is_no_secevent(&self) -> bool {
142        **self == SEC_A::NO_SECEVENT
143    }
144    #[doc = "Checks if the value of the field is `SECEVENT`"]
145    #[inline(always)]
146    pub fn is_secevent(&self) -> bool {
147        **self == SEC_A::SECEVENT
148    }
149}
150impl core::ops::Deref for SEC_R {
151    type Target = crate::FieldReader<bool, SEC_A>;
152    #[inline(always)]
153    fn deref(&self) -> &Self::Target {
154        &self.0
155    }
156}
157#[doc = "Time Event\n\nValue on reset: 0"]
158#[derive(Clone, Copy, Debug, PartialEq)]
159pub enum TIMEV_A {
160    #[doc = "0: No time event has occurred since the last clear."]
161    NO_TIMEVENT = 0,
162    #[doc = "1: At least one time event has occurred since the last clear."]
163    TIMEVENT = 1,
164}
165impl From<TIMEV_A> for bool {
166    #[inline(always)]
167    fn from(variant: TIMEV_A) -> Self {
168        variant as u8 != 0
169    }
170}
171#[doc = "Field `TIMEV` reader - Time Event"]
172pub struct TIMEV_R(crate::FieldReader<bool, TIMEV_A>);
173impl TIMEV_R {
174    #[inline(always)]
175    pub(crate) fn new(bits: bool) -> Self {
176        TIMEV_R(crate::FieldReader::new(bits))
177    }
178    #[doc = r"Get enumerated values variant"]
179    #[inline(always)]
180    pub fn variant(&self) -> TIMEV_A {
181        match self.bits {
182            false => TIMEV_A::NO_TIMEVENT,
183            true => TIMEV_A::TIMEVENT,
184        }
185    }
186    #[doc = "Checks if the value of the field is `NO_TIMEVENT`"]
187    #[inline(always)]
188    pub fn is_no_timevent(&self) -> bool {
189        **self == TIMEV_A::NO_TIMEVENT
190    }
191    #[doc = "Checks if the value of the field is `TIMEVENT`"]
192    #[inline(always)]
193    pub fn is_timevent(&self) -> bool {
194        **self == TIMEV_A::TIMEVENT
195    }
196}
197impl core::ops::Deref for TIMEV_R {
198    type Target = crate::FieldReader<bool, TIMEV_A>;
199    #[inline(always)]
200    fn deref(&self) -> &Self::Target {
201        &self.0
202    }
203}
204#[doc = "Calendar Event\n\nValue on reset: 0"]
205#[derive(Clone, Copy, Debug, PartialEq)]
206pub enum CALEV_A {
207    #[doc = "0: No calendar event has occurred since the last clear."]
208    NO_CALEVENT = 0,
209    #[doc = "1: At least one calendar event has occurred since the last clear."]
210    CALEVENT = 1,
211}
212impl From<CALEV_A> for bool {
213    #[inline(always)]
214    fn from(variant: CALEV_A) -> Self {
215        variant as u8 != 0
216    }
217}
218#[doc = "Field `CALEV` reader - Calendar Event"]
219pub struct CALEV_R(crate::FieldReader<bool, CALEV_A>);
220impl CALEV_R {
221    #[inline(always)]
222    pub(crate) fn new(bits: bool) -> Self {
223        CALEV_R(crate::FieldReader::new(bits))
224    }
225    #[doc = r"Get enumerated values variant"]
226    #[inline(always)]
227    pub fn variant(&self) -> CALEV_A {
228        match self.bits {
229            false => CALEV_A::NO_CALEVENT,
230            true => CALEV_A::CALEVENT,
231        }
232    }
233    #[doc = "Checks if the value of the field is `NO_CALEVENT`"]
234    #[inline(always)]
235    pub fn is_no_calevent(&self) -> bool {
236        **self == CALEV_A::NO_CALEVENT
237    }
238    #[doc = "Checks if the value of the field is `CALEVENT`"]
239    #[inline(always)]
240    pub fn is_calevent(&self) -> bool {
241        **self == CALEV_A::CALEVENT
242    }
243}
244impl core::ops::Deref for CALEV_R {
245    type Target = crate::FieldReader<bool, CALEV_A>;
246    #[inline(always)]
247    fn deref(&self) -> &Self::Target {
248        &self.0
249    }
250}
251#[doc = "Time and/or Date Free Running Error\n\nValue on reset: 0"]
252#[derive(Clone, Copy, Debug, PartialEq)]
253pub enum TDERR_A {
254    #[doc = "0: The internal free running counters are carrying valid values since the last read of the Status Register (RTC_SR)."]
255    CORRECT = 0,
256    #[doc = "1: The internal free running counters have been corrupted (invalid date or time, non-BCD values) since the last read and/or they are still invalid."]
257    ERR_TIMEDATE = 1,
258}
259impl From<TDERR_A> for bool {
260    #[inline(always)]
261    fn from(variant: TDERR_A) -> Self {
262        variant as u8 != 0
263    }
264}
265#[doc = "Field `TDERR` reader - Time and/or Date Free Running Error"]
266pub struct TDERR_R(crate::FieldReader<bool, TDERR_A>);
267impl TDERR_R {
268    #[inline(always)]
269    pub(crate) fn new(bits: bool) -> Self {
270        TDERR_R(crate::FieldReader::new(bits))
271    }
272    #[doc = r"Get enumerated values variant"]
273    #[inline(always)]
274    pub fn variant(&self) -> TDERR_A {
275        match self.bits {
276            false => TDERR_A::CORRECT,
277            true => TDERR_A::ERR_TIMEDATE,
278        }
279    }
280    #[doc = "Checks if the value of the field is `CORRECT`"]
281    #[inline(always)]
282    pub fn is_correct(&self) -> bool {
283        **self == TDERR_A::CORRECT
284    }
285    #[doc = "Checks if the value of the field is `ERR_TIMEDATE`"]
286    #[inline(always)]
287    pub fn is_err_timedate(&self) -> bool {
288        **self == TDERR_A::ERR_TIMEDATE
289    }
290}
291impl core::ops::Deref for TDERR_R {
292    type Target = crate::FieldReader<bool, TDERR_A>;
293    #[inline(always)]
294    fn deref(&self) -> &Self::Target {
295        &self.0
296    }
297}
298impl R {
299    #[doc = "Bit 0 - Acknowledge for Update"]
300    #[inline(always)]
301    pub fn ackupd(&self) -> ACKUPD_R {
302        ACKUPD_R::new((self.bits & 0x01) != 0)
303    }
304    #[doc = "Bit 1 - Alarm Flag"]
305    #[inline(always)]
306    pub fn alarm(&self) -> ALARM_R {
307        ALARM_R::new(((self.bits >> 1) & 0x01) != 0)
308    }
309    #[doc = "Bit 2 - Second Event"]
310    #[inline(always)]
311    pub fn sec(&self) -> SEC_R {
312        SEC_R::new(((self.bits >> 2) & 0x01) != 0)
313    }
314    #[doc = "Bit 3 - Time Event"]
315    #[inline(always)]
316    pub fn timev(&self) -> TIMEV_R {
317        TIMEV_R::new(((self.bits >> 3) & 0x01) != 0)
318    }
319    #[doc = "Bit 4 - Calendar Event"]
320    #[inline(always)]
321    pub fn calev(&self) -> CALEV_R {
322        CALEV_R::new(((self.bits >> 4) & 0x01) != 0)
323    }
324    #[doc = "Bit 5 - Time and/or Date Free Running Error"]
325    #[inline(always)]
326    pub fn tderr(&self) -> TDERR_R {
327        TDERR_R::new(((self.bits >> 5) & 0x01) != 0)
328    }
329}
330#[doc = "Status Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtc_sr](index.html) module"]
331pub struct RTC_SR_SPEC;
332impl crate::RegisterSpec for RTC_SR_SPEC {
333    type Ux = u32;
334}
335#[doc = "`read()` method returns [rtc_sr::R](R) reader structure"]
336impl crate::Readable for RTC_SR_SPEC {
337    type Reader = R;
338}
339#[doc = "`reset()` method sets RTC_SR to value 0"]
340impl crate::Resettable for RTC_SR_SPEC {
341    #[inline(always)]
342    fn reset_value() -> Self::Ux {
343        0
344    }
345}