atsams70j19/rtc/
rtc_cr.rs

1#[doc = "Register `RTC_CR` reader"]
2pub struct R(crate::R<RTC_CR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<RTC_CR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<RTC_CR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<RTC_CR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `RTC_CR` writer"]
17pub struct W(crate::W<RTC_CR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<RTC_CR_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_CR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<RTC_CR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `UPDTIM` reader - Update Request Time Register"]
38pub struct UPDTIM_R(crate::FieldReader<bool, bool>);
39impl UPDTIM_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: bool) -> Self {
42        UPDTIM_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for UPDTIM_R {
46    type Target = crate::FieldReader<bool, bool>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `UPDTIM` writer - Update Request Time Register"]
53pub struct UPDTIM_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> UPDTIM_W<'a> {
57    #[doc = r"Sets the field bit"]
58    #[inline(always)]
59    pub fn set_bit(self) -> &'a mut W {
60        self.bit(true)
61    }
62    #[doc = r"Clears the field bit"]
63    #[inline(always)]
64    pub fn clear_bit(self) -> &'a mut W {
65        self.bit(false)
66    }
67    #[doc = r"Writes raw bits to the field"]
68    #[inline(always)]
69    pub fn bit(self, value: bool) -> &'a mut W {
70        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
71        self.w
72    }
73}
74#[doc = "Field `UPDCAL` reader - Update Request Calendar Register"]
75pub struct UPDCAL_R(crate::FieldReader<bool, bool>);
76impl UPDCAL_R {
77    #[inline(always)]
78    pub(crate) fn new(bits: bool) -> Self {
79        UPDCAL_R(crate::FieldReader::new(bits))
80    }
81}
82impl core::ops::Deref for UPDCAL_R {
83    type Target = crate::FieldReader<bool, bool>;
84    #[inline(always)]
85    fn deref(&self) -> &Self::Target {
86        &self.0
87    }
88}
89#[doc = "Field `UPDCAL` writer - Update Request Calendar Register"]
90pub struct UPDCAL_W<'a> {
91    w: &'a mut W,
92}
93impl<'a> UPDCAL_W<'a> {
94    #[doc = r"Sets the field bit"]
95    #[inline(always)]
96    pub fn set_bit(self) -> &'a mut W {
97        self.bit(true)
98    }
99    #[doc = r"Clears the field bit"]
100    #[inline(always)]
101    pub fn clear_bit(self) -> &'a mut W {
102        self.bit(false)
103    }
104    #[doc = r"Writes raw bits to the field"]
105    #[inline(always)]
106    pub fn bit(self, value: bool) -> &'a mut W {
107        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
108        self.w
109    }
110}
111#[doc = "Time Event Selection\n\nValue on reset: 0"]
112#[derive(Clone, Copy, Debug, PartialEq)]
113#[repr(u8)]
114pub enum TIMEVSEL_A {
115    #[doc = "0: Minute change"]
116    MINUTE = 0,
117    #[doc = "1: Hour change"]
118    HOUR = 1,
119    #[doc = "2: Every day at midnight"]
120    MIDNIGHT = 2,
121    #[doc = "3: Every day at noon"]
122    NOON = 3,
123}
124impl From<TIMEVSEL_A> for u8 {
125    #[inline(always)]
126    fn from(variant: TIMEVSEL_A) -> Self {
127        variant as _
128    }
129}
130#[doc = "Field `TIMEVSEL` reader - Time Event Selection"]
131pub struct TIMEVSEL_R(crate::FieldReader<u8, TIMEVSEL_A>);
132impl TIMEVSEL_R {
133    #[inline(always)]
134    pub(crate) fn new(bits: u8) -> Self {
135        TIMEVSEL_R(crate::FieldReader::new(bits))
136    }
137    #[doc = r"Get enumerated values variant"]
138    #[inline(always)]
139    pub fn variant(&self) -> TIMEVSEL_A {
140        match self.bits {
141            0 => TIMEVSEL_A::MINUTE,
142            1 => TIMEVSEL_A::HOUR,
143            2 => TIMEVSEL_A::MIDNIGHT,
144            3 => TIMEVSEL_A::NOON,
145            _ => unreachable!(),
146        }
147    }
148    #[doc = "Checks if the value of the field is `MINUTE`"]
149    #[inline(always)]
150    pub fn is_minute(&self) -> bool {
151        **self == TIMEVSEL_A::MINUTE
152    }
153    #[doc = "Checks if the value of the field is `HOUR`"]
154    #[inline(always)]
155    pub fn is_hour(&self) -> bool {
156        **self == TIMEVSEL_A::HOUR
157    }
158    #[doc = "Checks if the value of the field is `MIDNIGHT`"]
159    #[inline(always)]
160    pub fn is_midnight(&self) -> bool {
161        **self == TIMEVSEL_A::MIDNIGHT
162    }
163    #[doc = "Checks if the value of the field is `NOON`"]
164    #[inline(always)]
165    pub fn is_noon(&self) -> bool {
166        **self == TIMEVSEL_A::NOON
167    }
168}
169impl core::ops::Deref for TIMEVSEL_R {
170    type Target = crate::FieldReader<u8, TIMEVSEL_A>;
171    #[inline(always)]
172    fn deref(&self) -> &Self::Target {
173        &self.0
174    }
175}
176#[doc = "Field `TIMEVSEL` writer - Time Event Selection"]
177pub struct TIMEVSEL_W<'a> {
178    w: &'a mut W,
179}
180impl<'a> TIMEVSEL_W<'a> {
181    #[doc = r"Writes `variant` to the field"]
182    #[inline(always)]
183    pub fn variant(self, variant: TIMEVSEL_A) -> &'a mut W {
184        self.bits(variant.into())
185    }
186    #[doc = "Minute change"]
187    #[inline(always)]
188    pub fn minute(self) -> &'a mut W {
189        self.variant(TIMEVSEL_A::MINUTE)
190    }
191    #[doc = "Hour change"]
192    #[inline(always)]
193    pub fn hour(self) -> &'a mut W {
194        self.variant(TIMEVSEL_A::HOUR)
195    }
196    #[doc = "Every day at midnight"]
197    #[inline(always)]
198    pub fn midnight(self) -> &'a mut W {
199        self.variant(TIMEVSEL_A::MIDNIGHT)
200    }
201    #[doc = "Every day at noon"]
202    #[inline(always)]
203    pub fn noon(self) -> &'a mut W {
204        self.variant(TIMEVSEL_A::NOON)
205    }
206    #[doc = r"Writes raw bits to the field"]
207    #[inline(always)]
208    pub fn bits(self, value: u8) -> &'a mut W {
209        self.w.bits = (self.w.bits & !(0x03 << 8)) | ((value as u32 & 0x03) << 8);
210        self.w
211    }
212}
213#[doc = "Calendar Event Selection\n\nValue on reset: 0"]
214#[derive(Clone, Copy, Debug, PartialEq)]
215#[repr(u8)]
216pub enum CALEVSEL_A {
217    #[doc = "0: Week change (every Monday at time 00:00:00)"]
218    WEEK = 0,
219    #[doc = "1: Month change (every 01 of each month at time 00:00:00)"]
220    MONTH = 1,
221    #[doc = "2: Year change (every January 1 at time 00:00:00)"]
222    YEAR = 2,
223}
224impl From<CALEVSEL_A> for u8 {
225    #[inline(always)]
226    fn from(variant: CALEVSEL_A) -> Self {
227        variant as _
228    }
229}
230#[doc = "Field `CALEVSEL` reader - Calendar Event Selection"]
231pub struct CALEVSEL_R(crate::FieldReader<u8, CALEVSEL_A>);
232impl CALEVSEL_R {
233    #[inline(always)]
234    pub(crate) fn new(bits: u8) -> Self {
235        CALEVSEL_R(crate::FieldReader::new(bits))
236    }
237    #[doc = r"Get enumerated values variant"]
238    #[inline(always)]
239    pub fn variant(&self) -> Option<CALEVSEL_A> {
240        match self.bits {
241            0 => Some(CALEVSEL_A::WEEK),
242            1 => Some(CALEVSEL_A::MONTH),
243            2 => Some(CALEVSEL_A::YEAR),
244            _ => None,
245        }
246    }
247    #[doc = "Checks if the value of the field is `WEEK`"]
248    #[inline(always)]
249    pub fn is_week(&self) -> bool {
250        **self == CALEVSEL_A::WEEK
251    }
252    #[doc = "Checks if the value of the field is `MONTH`"]
253    #[inline(always)]
254    pub fn is_month(&self) -> bool {
255        **self == CALEVSEL_A::MONTH
256    }
257    #[doc = "Checks if the value of the field is `YEAR`"]
258    #[inline(always)]
259    pub fn is_year(&self) -> bool {
260        **self == CALEVSEL_A::YEAR
261    }
262}
263impl core::ops::Deref for CALEVSEL_R {
264    type Target = crate::FieldReader<u8, CALEVSEL_A>;
265    #[inline(always)]
266    fn deref(&self) -> &Self::Target {
267        &self.0
268    }
269}
270#[doc = "Field `CALEVSEL` writer - Calendar Event Selection"]
271pub struct CALEVSEL_W<'a> {
272    w: &'a mut W,
273}
274impl<'a> CALEVSEL_W<'a> {
275    #[doc = r"Writes `variant` to the field"]
276    #[inline(always)]
277    pub fn variant(self, variant: CALEVSEL_A) -> &'a mut W {
278        unsafe { self.bits(variant.into()) }
279    }
280    #[doc = "Week change (every Monday at time 00:00:00)"]
281    #[inline(always)]
282    pub fn week(self) -> &'a mut W {
283        self.variant(CALEVSEL_A::WEEK)
284    }
285    #[doc = "Month change (every 01 of each month at time 00:00:00)"]
286    #[inline(always)]
287    pub fn month(self) -> &'a mut W {
288        self.variant(CALEVSEL_A::MONTH)
289    }
290    #[doc = "Year change (every January 1 at time 00:00:00)"]
291    #[inline(always)]
292    pub fn year(self) -> &'a mut W {
293        self.variant(CALEVSEL_A::YEAR)
294    }
295    #[doc = r"Writes raw bits to the field"]
296    #[inline(always)]
297    pub unsafe fn bits(self, value: u8) -> &'a mut W {
298        self.w.bits = (self.w.bits & !(0x03 << 16)) | ((value as u32 & 0x03) << 16);
299        self.w
300    }
301}
302impl R {
303    #[doc = "Bit 0 - Update Request Time Register"]
304    #[inline(always)]
305    pub fn updtim(&self) -> UPDTIM_R {
306        UPDTIM_R::new((self.bits & 0x01) != 0)
307    }
308    #[doc = "Bit 1 - Update Request Calendar Register"]
309    #[inline(always)]
310    pub fn updcal(&self) -> UPDCAL_R {
311        UPDCAL_R::new(((self.bits >> 1) & 0x01) != 0)
312    }
313    #[doc = "Bits 8:9 - Time Event Selection"]
314    #[inline(always)]
315    pub fn timevsel(&self) -> TIMEVSEL_R {
316        TIMEVSEL_R::new(((self.bits >> 8) & 0x03) as u8)
317    }
318    #[doc = "Bits 16:17 - Calendar Event Selection"]
319    #[inline(always)]
320    pub fn calevsel(&self) -> CALEVSEL_R {
321        CALEVSEL_R::new(((self.bits >> 16) & 0x03) as u8)
322    }
323}
324impl W {
325    #[doc = "Bit 0 - Update Request Time Register"]
326    #[inline(always)]
327    pub fn updtim(&mut self) -> UPDTIM_W {
328        UPDTIM_W { w: self }
329    }
330    #[doc = "Bit 1 - Update Request Calendar Register"]
331    #[inline(always)]
332    pub fn updcal(&mut self) -> UPDCAL_W {
333        UPDCAL_W { w: self }
334    }
335    #[doc = "Bits 8:9 - Time Event Selection"]
336    #[inline(always)]
337    pub fn timevsel(&mut self) -> TIMEVSEL_W {
338        TIMEVSEL_W { w: self }
339    }
340    #[doc = "Bits 16:17 - Calendar Event Selection"]
341    #[inline(always)]
342    pub fn calevsel(&mut self) -> CALEVSEL_W {
343        CALEVSEL_W { w: self }
344    }
345    #[doc = "Writes raw bits to the register."]
346    #[inline(always)]
347    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
348        self.0.bits(bits);
349        self
350    }
351}
352#[doc = "Control 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_cr](index.html) module"]
353pub struct RTC_CR_SPEC;
354impl crate::RegisterSpec for RTC_CR_SPEC {
355    type Ux = u32;
356}
357#[doc = "`read()` method returns [rtc_cr::R](R) reader structure"]
358impl crate::Readable for RTC_CR_SPEC {
359    type Reader = R;
360}
361#[doc = "`write(|w| ..)` method takes [rtc_cr::W](W) writer structure"]
362impl crate::Writable for RTC_CR_SPEC {
363    type Writer = W;
364}
365#[doc = "`reset()` method sets RTC_CR to value 0"]
366impl crate::Resettable for RTC_CR_SPEC {
367    #[inline(always)]
368    fn reset_value() -> Self::Ux {
369        0
370    }
371}