atsamv71q21/rtc/
rtc_calr.rs

1#[doc = "Register `RTC_CALR` reader"]
2pub struct R(crate::R<RTC_CALR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RTC_CALR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RTC_CALR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RTC_CALR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RTC_CALR` writer"]
17pub struct W(crate::W<RTC_CALR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RTC_CALR_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<RTC_CALR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RTC_CALR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CENT` reader - Current Century"]
38pub struct CENT_R(crate::FieldReader<u8, u8>);
39impl CENT_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u8) -> Self {
42        CENT_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for CENT_R {
46    type Target = crate::FieldReader<u8, u8>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `CENT` writer - Current Century"]
53pub struct CENT_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> CENT_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u8) -> &'a mut W {
60        self.w.bits = (self.w.bits & !0x7f) | (value as u32 & 0x7f);
61        self.w
62    }
63}
64#[doc = "Field `YEAR` reader - Current Year"]
65pub struct YEAR_R(crate::FieldReader<u8, u8>);
66impl YEAR_R {
67    #[inline(always)]
68    pub(crate) fn new(bits: u8) -> Self {
69        YEAR_R(crate::FieldReader::new(bits))
70    }
71}
72impl core::ops::Deref for YEAR_R {
73    type Target = crate::FieldReader<u8, u8>;
74    #[inline(always)]
75    fn deref(&self) -> &Self::Target {
76        &self.0
77    }
78}
79#[doc = "Field `YEAR` writer - Current Year"]
80pub struct YEAR_W<'a> {
81    w: &'a mut W,
82}
83impl<'a> YEAR_W<'a> {
84    #[doc = r"Writes raw bits to the field"]
85    #[inline(always)]
86    pub unsafe fn bits(self, value: u8) -> &'a mut W {
87        self.w.bits = (self.w.bits & !(0xff << 8)) | ((value as u32 & 0xff) << 8);
88        self.w
89    }
90}
91#[doc = "Field `MONTH` reader - Current Month"]
92pub struct MONTH_R(crate::FieldReader<u8, u8>);
93impl MONTH_R {
94    #[inline(always)]
95    pub(crate) fn new(bits: u8) -> Self {
96        MONTH_R(crate::FieldReader::new(bits))
97    }
98}
99impl core::ops::Deref for MONTH_R {
100    type Target = crate::FieldReader<u8, u8>;
101    #[inline(always)]
102    fn deref(&self) -> &Self::Target {
103        &self.0
104    }
105}
106#[doc = "Field `MONTH` writer - Current Month"]
107pub struct MONTH_W<'a> {
108    w: &'a mut W,
109}
110impl<'a> MONTH_W<'a> {
111    #[doc = r"Writes raw bits to the field"]
112    #[inline(always)]
113    pub unsafe fn bits(self, value: u8) -> &'a mut W {
114        self.w.bits = (self.w.bits & !(0x1f << 16)) | ((value as u32 & 0x1f) << 16);
115        self.w
116    }
117}
118#[doc = "Field `DAY` reader - Current Day in Current Week"]
119pub struct DAY_R(crate::FieldReader<u8, u8>);
120impl DAY_R {
121    #[inline(always)]
122    pub(crate) fn new(bits: u8) -> Self {
123        DAY_R(crate::FieldReader::new(bits))
124    }
125}
126impl core::ops::Deref for DAY_R {
127    type Target = crate::FieldReader<u8, u8>;
128    #[inline(always)]
129    fn deref(&self) -> &Self::Target {
130        &self.0
131    }
132}
133#[doc = "Field `DAY` writer - Current Day in Current Week"]
134pub struct DAY_W<'a> {
135    w: &'a mut W,
136}
137impl<'a> DAY_W<'a> {
138    #[doc = r"Writes raw bits to the field"]
139    #[inline(always)]
140    pub unsafe fn bits(self, value: u8) -> &'a mut W {
141        self.w.bits = (self.w.bits & !(0x07 << 21)) | ((value as u32 & 0x07) << 21);
142        self.w
143    }
144}
145#[doc = "Field `DATE` reader - Current Day in Current Month"]
146pub struct DATE_R(crate::FieldReader<u8, u8>);
147impl DATE_R {
148    #[inline(always)]
149    pub(crate) fn new(bits: u8) -> Self {
150        DATE_R(crate::FieldReader::new(bits))
151    }
152}
153impl core::ops::Deref for DATE_R {
154    type Target = crate::FieldReader<u8, u8>;
155    #[inline(always)]
156    fn deref(&self) -> &Self::Target {
157        &self.0
158    }
159}
160#[doc = "Field `DATE` writer - Current Day in Current Month"]
161pub struct DATE_W<'a> {
162    w: &'a mut W,
163}
164impl<'a> DATE_W<'a> {
165    #[doc = r"Writes raw bits to the field"]
166    #[inline(always)]
167    pub unsafe fn bits(self, value: u8) -> &'a mut W {
168        self.w.bits = (self.w.bits & !(0x3f << 24)) | ((value as u32 & 0x3f) << 24);
169        self.w
170    }
171}
172impl R {
173    #[doc = "Bits 0:6 - Current Century"]
174    #[inline(always)]
175    pub fn cent(&self) -> CENT_R {
176        CENT_R::new((self.bits & 0x7f) as u8)
177    }
178    #[doc = "Bits 8:15 - Current Year"]
179    #[inline(always)]
180    pub fn year(&self) -> YEAR_R {
181        YEAR_R::new(((self.bits >> 8) & 0xff) as u8)
182    }
183    #[doc = "Bits 16:20 - Current Month"]
184    #[inline(always)]
185    pub fn month(&self) -> MONTH_R {
186        MONTH_R::new(((self.bits >> 16) & 0x1f) as u8)
187    }
188    #[doc = "Bits 21:23 - Current Day in Current Week"]
189    #[inline(always)]
190    pub fn day(&self) -> DAY_R {
191        DAY_R::new(((self.bits >> 21) & 0x07) as u8)
192    }
193    #[doc = "Bits 24:29 - Current Day in Current Month"]
194    #[inline(always)]
195    pub fn date(&self) -> DATE_R {
196        DATE_R::new(((self.bits >> 24) & 0x3f) as u8)
197    }
198}
199impl W {
200    #[doc = "Bits 0:6 - Current Century"]
201    #[inline(always)]
202    pub fn cent(&mut self) -> CENT_W {
203        CENT_W { w: self }
204    }
205    #[doc = "Bits 8:15 - Current Year"]
206    #[inline(always)]
207    pub fn year(&mut self) -> YEAR_W {
208        YEAR_W { w: self }
209    }
210    #[doc = "Bits 16:20 - Current Month"]
211    #[inline(always)]
212    pub fn month(&mut self) -> MONTH_W {
213        MONTH_W { w: self }
214    }
215    #[doc = "Bits 21:23 - Current Day in Current Week"]
216    #[inline(always)]
217    pub fn day(&mut self) -> DAY_W {
218        DAY_W { w: self }
219    }
220    #[doc = "Bits 24:29 - Current Day in Current Month"]
221    #[inline(always)]
222    pub fn date(&mut self) -> DATE_W {
223        DATE_W { w: self }
224    }
225    #[doc = "Writes raw bits to the register."]
226    #[inline(always)]
227    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
228        self.0.bits(bits);
229        self
230    }
231}
232#[doc = "Calendar Register\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 [rtc_calr](index.html) module"]
233pub struct RTC_CALR_SPEC;
234impl crate::RegisterSpec for RTC_CALR_SPEC {
235    type Ux = u32;
236}
237#[doc = "`read()` method returns [rtc_calr::R](R) reader structure"]
238impl crate::Readable for RTC_CALR_SPEC {
239    type Reader = R;
240}
241#[doc = "`write(|w| ..)` method takes [rtc_calr::W](W) writer structure"]
242impl crate::Writable for RTC_CALR_SPEC {
243    type Writer = W;
244}
245#[doc = "`reset()` method sets RTC_CALR to value 0"]
246impl crate::Resettable for RTC_CALR_SPEC {
247    #[inline(always)]
248    fn reset_value() -> Self::Ux {
249        0
250    }
251}