ra4m3/rtc/
rcr2_bcnt.rs

1#[doc = "Register `RCR2_BCNT` reader"]
2pub struct R(crate::R<RCR2_BCNT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RCR2_BCNT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RCR2_BCNT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RCR2_BCNT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RCR2_BCNT` writer"]
17pub struct W(crate::W<RCR2_BCNT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RCR2_BCNT_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_BCNT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RCR2_BCNT_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 the 32-bit binary counter, 64-Hz counter, and prescaler"]
43    _0 = 0,
44    #[doc = "1: Operate the 32-bit binary counter, 64-Hz counter, and prescaler 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_BCNT_SPEC, START_A, O>;
75impl<'a, const O: u8> START_W<'a, O> {
76    #[doc = "Stop the 32-bit binary counter, 64-Hz counter, and prescaler"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(START_A::_0)
80    }
81    #[doc = "Operate the 32-bit binary counter, 64-Hz counter, and prescaler 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_BCNT_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 `RTCOE` reader - RTCOUT Output Enable"]
138pub type RTCOE_R = crate::BitReader<RTCOE_A>;
139#[doc = "RTCOUT Output Enable\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq, Eq)]
141pub enum RTCOE_A {
142    #[doc = "0: Disable RTCOUT output"]
143    _0 = 0,
144    #[doc = "1: Enable RTCOUT output"]
145    _1 = 1,
146}
147impl From<RTCOE_A> for bool {
148    #[inline(always)]
149    fn from(variant: RTCOE_A) -> Self {
150        variant as u8 != 0
151    }
152}
153impl RTCOE_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> RTCOE_A {
157        match self.bits {
158            false => RTCOE_A::_0,
159            true => RTCOE_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 == RTCOE_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 == RTCOE_A::_1
171    }
172}
173#[doc = "Field `RTCOE` writer - RTCOUT Output Enable"]
174pub type RTCOE_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_BCNT_SPEC, RTCOE_A, O>;
175impl<'a, const O: u8> RTCOE_W<'a, O> {
176    #[doc = "Disable RTCOUT output"]
177    #[inline(always)]
178    pub fn _0(self) -> &'a mut W {
179        self.variant(RTCOE_A::_0)
180    }
181    #[doc = "Enable RTCOUT output"]
182    #[inline(always)]
183    pub fn _1(self) -> &'a mut W {
184        self.variant(RTCOE_A::_1)
185    }
186}
187#[doc = "Field `AADJE` reader - Automatic Adjustment Enable"]
188pub type AADJE_R = crate::BitReader<AADJE_A>;
189#[doc = "Automatic Adjustment Enable\n\nValue on reset: 0"]
190#[derive(Clone, Copy, Debug, PartialEq, Eq)]
191pub enum AADJE_A {
192    #[doc = "0: Disable automatic adjustment"]
193    _0 = 0,
194    #[doc = "1: Enable automatic adjustment"]
195    _1 = 1,
196}
197impl From<AADJE_A> for bool {
198    #[inline(always)]
199    fn from(variant: AADJE_A) -> Self {
200        variant as u8 != 0
201    }
202}
203impl AADJE_R {
204    #[doc = "Get enumerated values variant"]
205    #[inline(always)]
206    pub fn variant(&self) -> AADJE_A {
207        match self.bits {
208            false => AADJE_A::_0,
209            true => AADJE_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 == AADJE_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 == AADJE_A::_1
221    }
222}
223#[doc = "Field `AADJE` writer - Automatic Adjustment Enable"]
224pub type AADJE_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_BCNT_SPEC, AADJE_A, O>;
225impl<'a, const O: u8> AADJE_W<'a, O> {
226    #[doc = "Disable automatic adjustment"]
227    #[inline(always)]
228    pub fn _0(self) -> &'a mut W {
229        self.variant(AADJE_A::_0)
230    }
231    #[doc = "Enable automatic adjustment"]
232    #[inline(always)]
233    pub fn _1(self) -> &'a mut W {
234        self.variant(AADJE_A::_1)
235    }
236}
237#[doc = "Field `AADJP` reader - Automatic Adjustment Period Select"]
238pub type AADJP_R = crate::BitReader<AADJP_A>;
239#[doc = "Automatic Adjustment Period Select\n\nValue on reset: 0"]
240#[derive(Clone, Copy, Debug, PartialEq, Eq)]
241pub enum AADJP_A {
242    #[doc = "0: Add or subtract RADJ.ADJ \\[5:0\\]
243bits from prescaler count value every 32 seconds"]
244    _0 = 0,
245    #[doc = "1: Add or subtract RADJ.ADJ \\[5:0\\]
246bits from prescaler countvalue every 8 seconds."]
247    _1 = 1,
248}
249impl From<AADJP_A> for bool {
250    #[inline(always)]
251    fn from(variant: AADJP_A) -> Self {
252        variant as u8 != 0
253    }
254}
255impl AADJP_R {
256    #[doc = "Get enumerated values variant"]
257    #[inline(always)]
258    pub fn variant(&self) -> AADJP_A {
259        match self.bits {
260            false => AADJP_A::_0,
261            true => AADJP_A::_1,
262        }
263    }
264    #[doc = "Checks if the value of the field is `_0`"]
265    #[inline(always)]
266    pub fn is_0(&self) -> bool {
267        *self == AADJP_A::_0
268    }
269    #[doc = "Checks if the value of the field is `_1`"]
270    #[inline(always)]
271    pub fn is_1(&self) -> bool {
272        *self == AADJP_A::_1
273    }
274}
275#[doc = "Field `AADJP` writer - Automatic Adjustment Period Select"]
276pub type AADJP_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_BCNT_SPEC, AADJP_A, O>;
277impl<'a, const O: u8> AADJP_W<'a, O> {
278    #[doc = "Add or subtract RADJ.ADJ \\[5:0\\]
279bits from prescaler count value every 32 seconds"]
280    #[inline(always)]
281    pub fn _0(self) -> &'a mut W {
282        self.variant(AADJP_A::_0)
283    }
284    #[doc = "Add or subtract RADJ.ADJ \\[5:0\\]
285bits from prescaler countvalue every 8 seconds."]
286    #[inline(always)]
287    pub fn _1(self) -> &'a mut W {
288        self.variant(AADJP_A::_1)
289    }
290}
291#[doc = "Field `CNTMD` reader - Count Mode Select"]
292pub type CNTMD_R = crate::BitReader<CNTMD_A>;
293#[doc = "Count Mode Select\n\nValue on reset: 0"]
294#[derive(Clone, Copy, Debug, PartialEq, Eq)]
295pub enum CNTMD_A {
296    #[doc = "0: Calendar count mode"]
297    _0 = 0,
298    #[doc = "1: Binary count mode"]
299    _1 = 1,
300}
301impl From<CNTMD_A> for bool {
302    #[inline(always)]
303    fn from(variant: CNTMD_A) -> Self {
304        variant as u8 != 0
305    }
306}
307impl CNTMD_R {
308    #[doc = "Get enumerated values variant"]
309    #[inline(always)]
310    pub fn variant(&self) -> CNTMD_A {
311        match self.bits {
312            false => CNTMD_A::_0,
313            true => CNTMD_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 == CNTMD_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 == CNTMD_A::_1
325    }
326}
327#[doc = "Field `CNTMD` writer - Count Mode Select"]
328pub type CNTMD_W<'a, const O: u8> = crate::BitWriter<'a, u8, RCR2_BCNT_SPEC, CNTMD_A, O>;
329impl<'a, const O: u8> CNTMD_W<'a, O> {
330    #[doc = "Calendar count mode"]
331    #[inline(always)]
332    pub fn _0(self) -> &'a mut W {
333        self.variant(CNTMD_A::_0)
334    }
335    #[doc = "Binary count mode"]
336    #[inline(always)]
337    pub fn _1(self) -> &'a mut W {
338        self.variant(CNTMD_A::_1)
339    }
340}
341impl R {
342    #[doc = "Bit 0 - Start"]
343    #[inline(always)]
344    pub fn start(&self) -> START_R {
345        START_R::new((self.bits & 1) != 0)
346    }
347    #[doc = "Bit 1 - RTC Software Reset"]
348    #[inline(always)]
349    pub fn reset(&self) -> RESET_R {
350        RESET_R::new(((self.bits >> 1) & 1) != 0)
351    }
352    #[doc = "Bit 3 - RTCOUT Output Enable"]
353    #[inline(always)]
354    pub fn rtcoe(&self) -> RTCOE_R {
355        RTCOE_R::new(((self.bits >> 3) & 1) != 0)
356    }
357    #[doc = "Bit 4 - Automatic Adjustment Enable"]
358    #[inline(always)]
359    pub fn aadje(&self) -> AADJE_R {
360        AADJE_R::new(((self.bits >> 4) & 1) != 0)
361    }
362    #[doc = "Bit 5 - Automatic Adjustment Period Select"]
363    #[inline(always)]
364    pub fn aadjp(&self) -> AADJP_R {
365        AADJP_R::new(((self.bits >> 5) & 1) != 0)
366    }
367    #[doc = "Bit 7 - Count Mode Select"]
368    #[inline(always)]
369    pub fn cntmd(&self) -> CNTMD_R {
370        CNTMD_R::new(((self.bits >> 7) & 1) != 0)
371    }
372}
373impl W {
374    #[doc = "Bit 0 - Start"]
375    #[inline(always)]
376    #[must_use]
377    pub fn start(&mut self) -> START_W<0> {
378        START_W::new(self)
379    }
380    #[doc = "Bit 1 - RTC Software Reset"]
381    #[inline(always)]
382    #[must_use]
383    pub fn reset(&mut self) -> RESET_W<1> {
384        RESET_W::new(self)
385    }
386    #[doc = "Bit 3 - RTCOUT Output Enable"]
387    #[inline(always)]
388    #[must_use]
389    pub fn rtcoe(&mut self) -> RTCOE_W<3> {
390        RTCOE_W::new(self)
391    }
392    #[doc = "Bit 4 - Automatic Adjustment Enable"]
393    #[inline(always)]
394    #[must_use]
395    pub fn aadje(&mut self) -> AADJE_W<4> {
396        AADJE_W::new(self)
397    }
398    #[doc = "Bit 5 - Automatic Adjustment Period Select"]
399    #[inline(always)]
400    #[must_use]
401    pub fn aadjp(&mut self) -> AADJP_W<5> {
402        AADJP_W::new(self)
403    }
404    #[doc = "Bit 7 - Count Mode Select"]
405    #[inline(always)]
406    #[must_use]
407    pub fn cntmd(&mut self) -> CNTMD_W<7> {
408        CNTMD_W::new(self)
409    }
410    #[doc = "Writes raw bits to the register."]
411    #[inline(always)]
412    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
413        self.0.bits(bits);
414        self
415    }
416}
417#[doc = "RTC Control Register 2 (in Binary 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_bcnt](index.html) module"]
418pub struct RCR2_BCNT_SPEC;
419impl crate::RegisterSpec for RCR2_BCNT_SPEC {
420    type Ux = u8;
421}
422#[doc = "`read()` method returns [rcr2_bcnt::R](R) reader structure"]
423impl crate::Readable for RCR2_BCNT_SPEC {
424    type Reader = R;
425}
426#[doc = "`write(|w| ..)` method takes [rcr2_bcnt::W](W) writer structure"]
427impl crate::Writable for RCR2_BCNT_SPEC {
428    type Writer = W;
429    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
430    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
431}
432#[doc = "`reset()` method sets RCR2_BCNT to value 0"]
433impl crate::Resettable for RCR2_BCNT_SPEC {
434    const RESET_VALUE: Self::Ux = 0;
435}