atsaml21e16b/rtc/mode2/
clock.rs

1#[doc = "Register `CLOCK` reader"]
2pub struct R(crate::R<CLOCK_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CLOCK_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CLOCK_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CLOCK_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CLOCK` writer"]
17pub struct W(crate::W<CLOCK_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CLOCK_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<CLOCK_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CLOCK_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SECOND` reader - Second"]
38pub type SECOND_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `SECOND` writer - Second"]
40pub type SECOND_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, u8, 6, O>;
41#[doc = "Field `MINUTE` reader - Minute"]
42pub type MINUTE_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `MINUTE` writer - Minute"]
44pub type MINUTE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, u8, 6, O>;
45#[doc = "Field `HOUR` reader - Hour"]
46pub type HOUR_R = crate::FieldReader<u8, HOURSELECT_A>;
47#[doc = "Hour\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum HOURSELECT_A {
51    #[doc = "0: AM when CLKREP in 12-hour"]
52    AM = 0,
53    #[doc = "16: PM when CLKREP in 12-hour"]
54    PM = 16,
55}
56impl From<HOURSELECT_A> for u8 {
57    #[inline(always)]
58    fn from(variant: HOURSELECT_A) -> Self {
59        variant as _
60    }
61}
62impl HOUR_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<HOURSELECT_A> {
66        match self.bits {
67            0 => Some(HOURSELECT_A::AM),
68            16 => Some(HOURSELECT_A::PM),
69            _ => None,
70        }
71    }
72    #[doc = "Checks if the value of the field is `AM`"]
73    #[inline(always)]
74    pub fn is_am(&self) -> bool {
75        *self == HOURSELECT_A::AM
76    }
77    #[doc = "Checks if the value of the field is `PM`"]
78    #[inline(always)]
79    pub fn is_pm(&self) -> bool {
80        *self == HOURSELECT_A::PM
81    }
82}
83#[doc = "Field `HOUR` writer - Hour"]
84pub type HOUR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, HOURSELECT_A, 5, O>;
85impl<'a, const O: u8> HOUR_W<'a, O> {
86    #[doc = "AM when CLKREP in 12-hour"]
87    #[inline(always)]
88    pub fn am(self) -> &'a mut W {
89        self.variant(HOURSELECT_A::AM)
90    }
91    #[doc = "PM when CLKREP in 12-hour"]
92    #[inline(always)]
93    pub fn pm(self) -> &'a mut W {
94        self.variant(HOURSELECT_A::PM)
95    }
96}
97#[doc = "Field `DAY` reader - Day"]
98pub type DAY_R = crate::FieldReader<u8, u8>;
99#[doc = "Field `DAY` writer - Day"]
100pub type DAY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, u8, 5, O>;
101#[doc = "Field `MONTH` reader - Month"]
102pub type MONTH_R = crate::FieldReader<u8, u8>;
103#[doc = "Field `MONTH` writer - Month"]
104pub type MONTH_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, u8, 4, O>;
105#[doc = "Field `YEAR` reader - Year"]
106pub type YEAR_R = crate::FieldReader<u8, u8>;
107#[doc = "Field `YEAR` writer - Year"]
108pub type YEAR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CLOCK_SPEC, u8, u8, 6, O>;
109impl R {
110    #[doc = "Bits 0:5 - Second"]
111    #[inline(always)]
112    pub fn second(&self) -> SECOND_R {
113        SECOND_R::new((self.bits & 0x3f) as u8)
114    }
115    #[doc = "Bits 6:11 - Minute"]
116    #[inline(always)]
117    pub fn minute(&self) -> MINUTE_R {
118        MINUTE_R::new(((self.bits >> 6) & 0x3f) as u8)
119    }
120    #[doc = "Bits 12:16 - Hour"]
121    #[inline(always)]
122    pub fn hour(&self) -> HOUR_R {
123        HOUR_R::new(((self.bits >> 12) & 0x1f) as u8)
124    }
125    #[doc = "Bits 17:21 - Day"]
126    #[inline(always)]
127    pub fn day(&self) -> DAY_R {
128        DAY_R::new(((self.bits >> 17) & 0x1f) as u8)
129    }
130    #[doc = "Bits 22:25 - Month"]
131    #[inline(always)]
132    pub fn month(&self) -> MONTH_R {
133        MONTH_R::new(((self.bits >> 22) & 0x0f) as u8)
134    }
135    #[doc = "Bits 26:31 - Year"]
136    #[inline(always)]
137    pub fn year(&self) -> YEAR_R {
138        YEAR_R::new(((self.bits >> 26) & 0x3f) as u8)
139    }
140}
141impl W {
142    #[doc = "Bits 0:5 - Second"]
143    #[inline(always)]
144    #[must_use]
145    pub fn second(&mut self) -> SECOND_W<0> {
146        SECOND_W::new(self)
147    }
148    #[doc = "Bits 6:11 - Minute"]
149    #[inline(always)]
150    #[must_use]
151    pub fn minute(&mut self) -> MINUTE_W<6> {
152        MINUTE_W::new(self)
153    }
154    #[doc = "Bits 12:16 - Hour"]
155    #[inline(always)]
156    #[must_use]
157    pub fn hour(&mut self) -> HOUR_W<12> {
158        HOUR_W::new(self)
159    }
160    #[doc = "Bits 17:21 - Day"]
161    #[inline(always)]
162    #[must_use]
163    pub fn day(&mut self) -> DAY_W<17> {
164        DAY_W::new(self)
165    }
166    #[doc = "Bits 22:25 - Month"]
167    #[inline(always)]
168    #[must_use]
169    pub fn month(&mut self) -> MONTH_W<22> {
170        MONTH_W::new(self)
171    }
172    #[doc = "Bits 26:31 - Year"]
173    #[inline(always)]
174    #[must_use]
175    pub fn year(&mut self) -> YEAR_W<26> {
176        YEAR_W::new(self)
177    }
178    #[doc = "Writes raw bits to the register."]
179    #[inline(always)]
180    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
181        self.0.bits(bits);
182        self
183    }
184}
185#[doc = "MODE2 Clock Value\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 [clock](index.html) module"]
186pub struct CLOCK_SPEC;
187impl crate::RegisterSpec for CLOCK_SPEC {
188    type Ux = u32;
189}
190#[doc = "`read()` method returns [clock::R](R) reader structure"]
191impl crate::Readable for CLOCK_SPEC {
192    type Reader = R;
193}
194#[doc = "`write(|w| ..)` method takes [clock::W](W) writer structure"]
195impl crate::Writable for CLOCK_SPEC {
196    type Writer = W;
197    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
198    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
199}
200#[doc = "`reset()` method sets CLOCK to value 0"]
201impl crate::Resettable for CLOCK_SPEC {
202    const RESET_VALUE: Self::Ux = 0;
203}