ra2a1/rtc/
rhrcnt.rs

1#[doc = "Register `RHRCNT` reader"]
2pub struct R(crate::R<RHRCNT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RHRCNT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RHRCNT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RHRCNT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RHRCNT` writer"]
17pub struct W(crate::W<RHRCNT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RHRCNT_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<RHRCNT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RHRCNT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `HR1` reader - 1-Hour Count Counts from 0 to 9 once per hour. When a carry is generated, 1 is added to the tens place."]
38pub type HR1_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `HR1` writer - 1-Hour Count Counts from 0 to 9 once per hour. When a carry is generated, 1 is added to the tens place."]
40pub type HR1_W<'a, const O: u8> = crate::FieldWriter<'a, u8, RHRCNT_SPEC, u8, u8, 4, O>;
41#[doc = "Field `HR10` reader - 10-Hour Count Counts from 0 to 2 once per carry from the ones place."]
42pub type HR10_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `HR10` writer - 10-Hour Count Counts from 0 to 2 once per carry from the ones place."]
44pub type HR10_W<'a, const O: u8> = crate::FieldWriter<'a, u8, RHRCNT_SPEC, u8, u8, 2, O>;
45#[doc = "Field `PM` reader - Time Counter Setting for a.m./p.m."]
46pub type PM_R = crate::BitReader<PM_A>;
47#[doc = "Time Counter Setting for a.m./p.m.\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49pub enum PM_A {
50    #[doc = "0: a.m."]
51    _0 = 0,
52    #[doc = "1: p.m."]
53    _1 = 1,
54}
55impl From<PM_A> for bool {
56    #[inline(always)]
57    fn from(variant: PM_A) -> Self {
58        variant as u8 != 0
59    }
60}
61impl PM_R {
62    #[doc = "Get enumerated values variant"]
63    #[inline(always)]
64    pub fn variant(&self) -> PM_A {
65        match self.bits {
66            false => PM_A::_0,
67            true => PM_A::_1,
68        }
69    }
70    #[doc = "Checks if the value of the field is `_0`"]
71    #[inline(always)]
72    pub fn is_0(&self) -> bool {
73        *self == PM_A::_0
74    }
75    #[doc = "Checks if the value of the field is `_1`"]
76    #[inline(always)]
77    pub fn is_1(&self) -> bool {
78        *self == PM_A::_1
79    }
80}
81#[doc = "Field `PM` writer - Time Counter Setting for a.m./p.m."]
82pub type PM_W<'a, const O: u8> = crate::BitWriter<'a, u8, RHRCNT_SPEC, PM_A, O>;
83impl<'a, const O: u8> PM_W<'a, O> {
84    #[doc = "a.m."]
85    #[inline(always)]
86    pub fn _0(self) -> &'a mut W {
87        self.variant(PM_A::_0)
88    }
89    #[doc = "p.m."]
90    #[inline(always)]
91    pub fn _1(self) -> &'a mut W {
92        self.variant(PM_A::_1)
93    }
94}
95impl R {
96    #[doc = "Bits 0:3 - 1-Hour Count Counts from 0 to 9 once per hour. When a carry is generated, 1 is added to the tens place."]
97    #[inline(always)]
98    pub fn hr1(&self) -> HR1_R {
99        HR1_R::new(self.bits & 0x0f)
100    }
101    #[doc = "Bits 4:5 - 10-Hour Count Counts from 0 to 2 once per carry from the ones place."]
102    #[inline(always)]
103    pub fn hr10(&self) -> HR10_R {
104        HR10_R::new((self.bits >> 4) & 3)
105    }
106    #[doc = "Bit 6 - Time Counter Setting for a.m./p.m."]
107    #[inline(always)]
108    pub fn pm(&self) -> PM_R {
109        PM_R::new(((self.bits >> 6) & 1) != 0)
110    }
111}
112impl W {
113    #[doc = "Bits 0:3 - 1-Hour Count Counts from 0 to 9 once per hour. When a carry is generated, 1 is added to the tens place."]
114    #[inline(always)]
115    #[must_use]
116    pub fn hr1(&mut self) -> HR1_W<0> {
117        HR1_W::new(self)
118    }
119    #[doc = "Bits 4:5 - 10-Hour Count Counts from 0 to 2 once per carry from the ones place."]
120    #[inline(always)]
121    #[must_use]
122    pub fn hr10(&mut self) -> HR10_W<4> {
123        HR10_W::new(self)
124    }
125    #[doc = "Bit 6 - Time Counter Setting for a.m./p.m."]
126    #[inline(always)]
127    #[must_use]
128    pub fn pm(&mut self) -> PM_W<6> {
129        PM_W::new(self)
130    }
131    #[doc = "Writes raw bits to the register."]
132    #[inline(always)]
133    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
134        self.0.bits(bits);
135        self
136    }
137}
138#[doc = "Hour Counter\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 [rhrcnt](index.html) module"]
139pub struct RHRCNT_SPEC;
140impl crate::RegisterSpec for RHRCNT_SPEC {
141    type Ux = u8;
142}
143#[doc = "`read()` method returns [rhrcnt::R](R) reader structure"]
144impl crate::Readable for RHRCNT_SPEC {
145    type Reader = R;
146}
147#[doc = "`write(|w| ..)` method takes [rhrcnt::W](W) writer structure"]
148impl crate::Writable for RHRCNT_SPEC {
149    type Writer = W;
150    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
151    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
152}
153#[doc = "`reset()` method sets RHRCNT to value 0"]
154impl crate::Resettable for RHRCNT_SPEC {
155    const RESET_VALUE: Self::Ux = 0;
156}