ra2e1/rtc/
rcr2.rs

1#[doc = "Register `RCR2` reader"]
2pub struct R(crate::R<RCR2_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RCR2_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RCR2_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RCR2_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RCR2` writer"]
17pub struct W(crate::W<RCR2_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RCR2_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<RCR2_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RCR2_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `START` reader - Start"]
38pub type START_R = crate::BitReader<START_A>;
39#[doc = "Start\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum START_A {
42    #[doc = "0: Stop prescaler and time counter"]
43    _0 = 0,
44    #[doc = "1: Operate prescaler and time counter normally"]
45    _1 = 1,
46}
47impl From<START_A> for bool {
48    #[inline(always)]
49    fn from(variant: START_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl START_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> START_A {
57        match self.bits {
58            false => START_A::_0,
59            true => START_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == START_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == START_A::_1
71    }
72}
73#[doc = "Field `START` writer - Start"]
74pub type START_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, START_A, O>;
75impl<'a, const O: u8> START_W<'a, O> {
76    #[doc = "Stop prescaler and time counter"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(START_A::_0)
80    }
81    #[doc = "Operate prescaler and time counter normally"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(START_A::_1)
85    }
86}
87#[doc = "Field `RESET` reader - RTC Software Reset"]
88pub type RESET_R = crate::BitReader<RESET_A>;
89#[doc = "RTC Software Reset\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum RESET_A {
92    #[doc = "0: In writing: Invalid (writing 0 has no effect). In reading: Normal time operation in progress, or an RTC software reset has completed."]
93    _0 = 0,
94    #[doc = "1: In writing: Initialize the prescaler and target registers for RTC software reset. In reading: RTC software reset in progress."]
95    _1 = 1,
96}
97impl From<RESET_A> for bool {
98    #[inline(always)]
99    fn from(variant: RESET_A) -> Self {
100        variant as u8 != 0
101    }
102}
103impl RESET_R {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub fn variant(&self) -> RESET_A {
107        match self.bits {
108            false => RESET_A::_0,
109            true => RESET_A::_1,
110        }
111    }
112    #[doc = "Checks if the value of the field is `_0`"]
113    #[inline(always)]
114    pub fn is_0(&self) -> bool {
115        *self == RESET_A::_0
116    }
117    #[doc = "Checks if the value of the field is `_1`"]
118    #[inline(always)]
119    pub fn is_1(&self) -> bool {
120        *self == RESET_A::_1
121    }
122}
123#[doc = "Field `RESET` writer - RTC Software Reset"]
124pub type RESET_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, RESET_A, O>;
125impl<'a, const O: u8> RESET_W<'a, O> {
126    #[doc = "In writing: Invalid (writing 0 has no effect). In reading: Normal time operation in progress, or an RTC software reset has completed."]
127    #[inline(always)]
128    pub fn _0(self) -> &'a mut W {
129        self.variant(RESET_A::_0)
130    }
131    #[doc = "In writing: Initialize the prescaler and target registers for RTC software reset. In reading: RTC software reset in progress."]
132    #[inline(always)]
133    pub fn _1(self) -> &'a mut W {
134        self.variant(RESET_A::_1)
135    }
136}
137#[doc = "Field `ADJ30` reader - 30-Second Adjustment"]
138pub type ADJ30_R = crate::BitReader<ADJ30_A>;
139#[doc = "30-Second Adjustment\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq, Eq)]
141pub enum ADJ30_A {
142    #[doc = "0: In writing: Invalid (writing 0 has no effect). In reading: Normal time operation in progress, or 30-second adjustment has completed."]
143    _0 = 0,
144    #[doc = "1: In writing: Execute 30-second adjustment. In reading: 30-second adjustment in progress."]
145    _1 = 1,
146}
147impl From<ADJ30_A> for bool {
148    #[inline(always)]
149    fn from(variant: ADJ30_A) -> Self {
150        variant as u8 != 0
151    }
152}
153impl ADJ30_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> ADJ30_A {
157        match self.bits {
158            false => ADJ30_A::_0,
159            true => ADJ30_A::_1,
160        }
161    }
162    #[doc = "Checks if the value of the field is `_0`"]
163    #[inline(always)]
164    pub fn is_0(&self) -> bool {
165        *self == ADJ30_A::_0
166    }
167    #[doc = "Checks if the value of the field is `_1`"]
168    #[inline(always)]
169    pub fn is_1(&self) -> bool {
170        *self == ADJ30_A::_1
171    }
172}
173#[doc = "Field `ADJ30` writer - 30-Second Adjustment"]
174pub type ADJ30_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, ADJ30_A, O>;
175impl<'a, const O: u8> ADJ30_W<'a, O> {
176    #[doc = "In writing: Invalid (writing 0 has no effect). In reading: Normal time operation in progress, or 30-second adjustment has completed."]
177    #[inline(always)]
178    pub fn _0(self) -> &'a mut W {
179        self.variant(ADJ30_A::_0)
180    }
181    #[doc = "In writing: Execute 30-second adjustment. In reading: 30-second adjustment in progress."]
182    #[inline(always)]
183    pub fn _1(self) -> &'a mut W {
184        self.variant(ADJ30_A::_1)
185    }
186}
187#[doc = "Field `RTCOE` reader - RTCOUT Output Enable"]
188pub type RTCOE_R = crate::BitReader<RTCOE_A>;
189#[doc = "RTCOUT Output Enable\n\nValue on reset: 0"]
190#[derive(Clone, Copy, Debug, PartialEq, Eq)]
191pub enum RTCOE_A {
192    #[doc = "0: Disable RTCOUT output"]
193    _0 = 0,
194    #[doc = "1: Enable RTCOUT output"]
195    _1 = 1,
196}
197impl From<RTCOE_A> for bool {
198    #[inline(always)]
199    fn from(variant: RTCOE_A) -> Self {
200        variant as u8 != 0
201    }
202}
203impl RTCOE_R {
204    #[doc = "Get enumerated values variant"]
205    #[inline(always)]
206    pub fn variant(&self) -> RTCOE_A {
207        match self.bits {
208            false => RTCOE_A::_0,
209            true => RTCOE_A::_1,
210        }
211    }
212    #[doc = "Checks if the value of the field is `_0`"]
213    #[inline(always)]
214    pub fn is_0(&self) -> bool {
215        *self == RTCOE_A::_0
216    }
217    #[doc = "Checks if the value of the field is `_1`"]
218    #[inline(always)]
219    pub fn is_1(&self) -> bool {
220        *self == RTCOE_A::_1
221    }
222}
223#[doc = "Field `RTCOE` writer - RTCOUT Output Enable"]
224pub type RTCOE_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, RTCOE_A, O>;
225impl<'a, const O: u8> RTCOE_W<'a, O> {
226    #[doc = "Disable RTCOUT output"]
227    #[inline(always)]
228    pub fn _0(self) -> &'a mut W {
229        self.variant(RTCOE_A::_0)
230    }
231    #[doc = "Enable RTCOUT output"]
232    #[inline(always)]
233    pub fn _1(self) -> &'a mut W {
234        self.variant(RTCOE_A::_1)
235    }
236}
237#[doc = "Field `AADJE` reader - Automatic Adjustment Enable"]
238pub type AADJE_R = crate::BitReader<AADJE_A>;
239#[doc = "Automatic Adjustment Enable\n\nValue on reset: 0"]
240#[derive(Clone, Copy, Debug, PartialEq, Eq)]
241pub enum AADJE_A {
242    #[doc = "0: Disable automatic adjustment"]
243    _0 = 0,
244    #[doc = "1: Enable automatic adjustment"]
245    _1 = 1,
246}
247impl From<AADJE_A> for bool {
248    #[inline(always)]
249    fn from(variant: AADJE_A) -> Self {
250        variant as u8 != 0
251    }
252}
253impl AADJE_R {
254    #[doc = "Get enumerated values variant"]
255    #[inline(always)]
256    pub fn variant(&self) -> AADJE_A {
257        match self.bits {
258            false => AADJE_A::_0,
259            true => AADJE_A::_1,
260        }
261    }
262    #[doc = "Checks if the value of the field is `_0`"]
263    #[inline(always)]
264    pub fn is_0(&self) -> bool {
265        *self == AADJE_A::_0
266    }
267    #[doc = "Checks if the value of the field is `_1`"]
268    #[inline(always)]
269    pub fn is_1(&self) -> bool {
270        *self == AADJE_A::_1
271    }
272}
273#[doc = "Field `AADJE` writer - Automatic Adjustment Enable"]
274pub type AADJE_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, AADJE_A, O>;
275impl<'a, const O: u8> AADJE_W<'a, O> {
276    #[doc = "Disable automatic adjustment"]
277    #[inline(always)]
278    pub fn _0(self) -> &'a mut W {
279        self.variant(AADJE_A::_0)
280    }
281    #[doc = "Enable automatic adjustment"]
282    #[inline(always)]
283    pub fn _1(self) -> &'a mut W {
284        self.variant(AADJE_A::_1)
285    }
286}
287#[doc = "Field `AADJP` reader - Automatic Adjustment Period Select"]
288pub type AADJP_R = crate::BitReader<AADJP_A>;
289#[doc = "Automatic Adjustment Period Select\n\nValue on reset: 0"]
290#[derive(Clone, Copy, Debug, PartialEq, Eq)]
291pub enum AADJP_A {
292    #[doc = "0: In normal operation mode, adjust RADJ.ADJ\\[5:0\\]
293setting from the count value of the prescaler every minute. In low-consumption clock mode, adjust RADJ.ADJ\\[5:0\\]
294setting from the count value of the 64-Hz counter every day."]
295    _0 = 0,
296    #[doc = "1: In normal operation mode, adjust RADJ.ADJ\\[5:0\\]
297setting from the count value of the prescaler every 10 seconds. In low-consumption clock mode, adjust RADJ.ADJ\\[5:0\\]
298setting from the count value of the 64-Hz counter every hour."]
299    _1 = 1,
300}
301impl From<AADJP_A> for bool {
302    #[inline(always)]
303    fn from(variant: AADJP_A) -> Self {
304        variant as u8 != 0
305    }
306}
307impl AADJP_R {
308    #[doc = "Get enumerated values variant"]
309    #[inline(always)]
310    pub fn variant(&self) -> AADJP_A {
311        match self.bits {
312            false => AADJP_A::_0,
313            true => AADJP_A::_1,
314        }
315    }
316    #[doc = "Checks if the value of the field is `_0`"]
317    #[inline(always)]
318    pub fn is_0(&self) -> bool {
319        *self == AADJP_A::_0
320    }
321    #[doc = "Checks if the value of the field is `_1`"]
322    #[inline(always)]
323    pub fn is_1(&self) -> bool {
324        *self == AADJP_A::_1
325    }
326}
327#[doc = "Field `AADJP` writer - Automatic Adjustment Period Select"]
328pub type AADJP_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, AADJP_A, O>;
329impl<'a, const O: u8> AADJP_W<'a, O> {
330    #[doc = "In normal operation mode, adjust RADJ.ADJ\\[5:0\\]
331setting from the count value of the prescaler every minute. In low-consumption clock mode, adjust RADJ.ADJ\\[5:0\\]
332setting from the count value of the 64-Hz counter every day."]
333    #[inline(always)]
334    pub fn _0(self) -> &'a mut W {
335        self.variant(AADJP_A::_0)
336    }
337    #[doc = "In normal operation mode, adjust RADJ.ADJ\\[5:0\\]
338setting from the count value of the prescaler every 10 seconds. In low-consumption clock mode, adjust RADJ.ADJ\\[5:0\\]
339setting from the count value of the 64-Hz counter every hour."]
340    #[inline(always)]
341    pub fn _1(self) -> &'a mut W {
342        self.variant(AADJP_A::_1)
343    }
344}
345#[doc = "Field `HR24` reader - Hours Mode"]
346pub type HR24_R = crate::BitReader<HR24_A>;
347#[doc = "Hours Mode\n\nValue on reset: 0"]
348#[derive(Clone, Copy, Debug, PartialEq, Eq)]
349pub enum HR24_A {
350    #[doc = "0: Operate RTC in 12-hour mode"]
351    _0 = 0,
352    #[doc = "1: Operate RTC in 24-hour mode"]
353    _1 = 1,
354}
355impl From<HR24_A> for bool {
356    #[inline(always)]
357    fn from(variant: HR24_A) -> Self {
358        variant as u8 != 0
359    }
360}
361impl HR24_R {
362    #[doc = "Get enumerated values variant"]
363    #[inline(always)]
364    pub fn variant(&self) -> HR24_A {
365        match self.bits {
366            false => HR24_A::_0,
367            true => HR24_A::_1,
368        }
369    }
370    #[doc = "Checks if the value of the field is `_0`"]
371    #[inline(always)]
372    pub fn is_0(&self) -> bool {
373        *self == HR24_A::_0
374    }
375    #[doc = "Checks if the value of the field is `_1`"]
376    #[inline(always)]
377    pub fn is_1(&self) -> bool {
378        *self == HR24_A::_1
379    }
380}
381#[doc = "Field `HR24` writer - Hours Mode"]
382pub type HR24_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, HR24_A, O>;
383impl<'a, const O: u8> HR24_W<'a, O> {
384    #[doc = "Operate RTC in 12-hour mode"]
385    #[inline(always)]
386    pub fn _0(self) -> &'a mut W {
387        self.variant(HR24_A::_0)
388    }
389    #[doc = "Operate RTC in 24-hour mode"]
390    #[inline(always)]
391    pub fn _1(self) -> &'a mut W {
392        self.variant(HR24_A::_1)
393    }
394}
395#[doc = "Field `CNTMD` reader - Count Mode Select"]
396pub type CNTMD_R = crate::BitReader<CNTMD_A>;
397#[doc = "Count Mode Select\n\nValue on reset: 0"]
398#[derive(Clone, Copy, Debug, PartialEq, Eq)]
399pub enum CNTMD_A {
400    #[doc = "0: Calendar count mode"]
401    _0 = 0,
402    #[doc = "1: Binary count mode"]
403    _1 = 1,
404}
405impl From<CNTMD_A> for bool {
406    #[inline(always)]
407    fn from(variant: CNTMD_A) -> Self {
408        variant as u8 != 0
409    }
410}
411impl CNTMD_R {
412    #[doc = "Get enumerated values variant"]
413    #[inline(always)]
414    pub fn variant(&self) -> CNTMD_A {
415        match self.bits {
416            false => CNTMD_A::_0,
417            true => CNTMD_A::_1,
418        }
419    }
420    #[doc = "Checks if the value of the field is `_0`"]
421    #[inline(always)]
422    pub fn is_0(&self) -> bool {
423        *self == CNTMD_A::_0
424    }
425    #[doc = "Checks if the value of the field is `_1`"]
426    #[inline(always)]
427    pub fn is_1(&self) -> bool {
428        *self == CNTMD_A::_1
429    }
430}
431#[doc = "Field `CNTMD` writer - Count Mode Select"]
432pub type CNTMD_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_SPEC, CNTMD_A, O>;
433impl<'a, const O: u8> CNTMD_W<'a, O> {
434    #[doc = "Calendar count mode"]
435    #[inline(always)]
436    pub fn _0(self) -> &'a mut W {
437        self.variant(CNTMD_A::_0)
438    }
439    #[doc = "Binary count mode"]
440    #[inline(always)]
441    pub fn _1(self) -> &'a mut W {
442        self.variant(CNTMD_A::_1)
443    }
444}
445impl R {
446    #[doc = "Bit 0 - Start"]
447    #[inline(always)]
448    pub fn start(&self) -> START_R {
449        START_R::new((self.bits & 1) != 0)
450    }
451    #[doc = "Bit 1 - RTC Software Reset"]
452    #[inline(always)]
453    pub fn reset(&self) -> RESET_R {
454        RESET_R::new(((self.bits >> 1) & 1) != 0)
455    }
456    #[doc = "Bit 2 - 30-Second Adjustment"]
457    #[inline(always)]
458    pub fn adj30(&self) -> ADJ30_R {
459        ADJ30_R::new(((self.bits >> 2) & 1) != 0)
460    }
461    #[doc = "Bit 3 - RTCOUT Output Enable"]
462    #[inline(always)]
463    pub fn rtcoe(&self) -> RTCOE_R {
464        RTCOE_R::new(((self.bits >> 3) & 1) != 0)
465    }
466    #[doc = "Bit 4 - Automatic Adjustment Enable"]
467    #[inline(always)]
468    pub fn aadje(&self) -> AADJE_R {
469        AADJE_R::new(((self.bits >> 4) & 1) != 0)
470    }
471    #[doc = "Bit 5 - Automatic Adjustment Period Select"]
472    #[inline(always)]
473    pub fn aadjp(&self) -> AADJP_R {
474        AADJP_R::new(((self.bits >> 5) & 1) != 0)
475    }
476    #[doc = "Bit 6 - Hours Mode"]
477    #[inline(always)]
478    pub fn hr24(&self) -> HR24_R {
479        HR24_R::new(((self.bits >> 6) & 1) != 0)
480    }
481    #[doc = "Bit 7 - Count Mode Select"]
482    #[inline(always)]
483    pub fn cntmd(&self) -> CNTMD_R {
484        CNTMD_R::new(((self.bits >> 7) & 1) != 0)
485    }
486}
487impl W {
488    #[doc = "Bit 0 - Start"]
489    #[inline(always)]
490    #[must_use]
491    pub fn start(&mut self) -> START_W<0> {
492        START_W::new(self)
493    }
494    #[doc = "Bit 1 - RTC Software Reset"]
495    #[inline(always)]
496    #[must_use]
497    pub fn reset(&mut self) -> RESET_W<1> {
498        RESET_W::new(self)
499    }
500    #[doc = "Bit 2 - 30-Second Adjustment"]
501    #[inline(always)]
502    #[must_use]
503    pub fn adj30(&mut self) -> ADJ30_W<2> {
504        ADJ30_W::new(self)
505    }
506    #[doc = "Bit 3 - RTCOUT Output Enable"]
507    #[inline(always)]
508    #[must_use]
509    pub fn rtcoe(&mut self) -> RTCOE_W<3> {
510        RTCOE_W::new(self)
511    }
512    #[doc = "Bit 4 - Automatic Adjustment Enable"]
513    #[inline(always)]
514    #[must_use]
515    pub fn aadje(&mut self) -> AADJE_W<4> {
516        AADJE_W::new(self)
517    }
518    #[doc = "Bit 5 - Automatic Adjustment Period Select"]
519    #[inline(always)]
520    #[must_use]
521    pub fn aadjp(&mut self) -> AADJP_W<5> {
522        AADJP_W::new(self)
523    }
524    #[doc = "Bit 6 - Hours Mode"]
525    #[inline(always)]
526    #[must_use]
527    pub fn hr24(&mut self) -> HR24_W<6> {
528        HR24_W::new(self)
529    }
530    #[doc = "Bit 7 - Count Mode Select"]
531    #[inline(always)]
532    #[must_use]
533    pub fn cntmd(&mut self) -> CNTMD_W<7> {
534        CNTMD_W::new(self)
535    }
536    #[doc = "Writes raw bits to the register."]
537    #[inline(always)]
538    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
539        self.0.bits(bits);
540        self
541    }
542}
543#[doc = "RTC Control Register 2 (in Calendar Count Mode)\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 [rcr2](index.html) module"]
544pub struct RCR2_SPEC;
545impl crate::RegisterSpec for RCR2_SPEC {
546    type Ux = u8;
547}
548#[doc = "`read()` method returns [rcr2::R](R) reader structure"]
549impl crate::Readable for RCR2_SPEC {
550    type Reader = R;
551}
552#[doc = "`write(|w| ..)` method takes [rcr2::W](W) writer structure"]
553impl crate::Writable for RCR2_SPEC {
554    type Writer = W;
555    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
556    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
557}
558#[doc = "`reset()` method sets RCR2 to value 0"]
559impl crate::Resettable for RCR2_SPEC {
560    const RESET_VALUE: Self::Ux = 0;
561}