efm32pg12_pac/rtcc/
date.rs

1#[doc = "Reader of register DATE"]
2pub type R = crate::R<u32, super::DATE>;
3#[doc = "Writer for register DATE"]
4pub type W = crate::W<u32, super::DATE>;
5#[doc = "Register DATE `reset()`'s with value 0"]
6impl crate::ResetValue for super::DATE {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `DAYOMU`"]
14pub type DAYOMU_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `DAYOMU`"]
16pub struct DAYOMU_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> DAYOMU_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
24        self.w
25    }
26}
27#[doc = "Reader of field `DAYOMT`"]
28pub type DAYOMT_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `DAYOMT`"]
30pub struct DAYOMT_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> DAYOMT_W<'a> {
34    #[doc = r"Writes raw bits to the field"]
35    #[inline(always)]
36    pub unsafe fn bits(self, value: u8) -> &'a mut W {
37        self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
38        self.w
39    }
40}
41#[doc = "Reader of field `MONTHU`"]
42pub type MONTHU_R = crate::R<u8, u8>;
43#[doc = "Write proxy for field `MONTHU`"]
44pub struct MONTHU_W<'a> {
45    w: &'a mut W,
46}
47impl<'a> MONTHU_W<'a> {
48    #[doc = r"Writes raw bits to the field"]
49    #[inline(always)]
50    pub unsafe fn bits(self, value: u8) -> &'a mut W {
51        self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
52        self.w
53    }
54}
55#[doc = "Reader of field `MONTHT`"]
56pub type MONTHT_R = crate::R<bool, bool>;
57#[doc = "Write proxy for field `MONTHT`"]
58pub struct MONTHT_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> MONTHT_W<'a> {
62    #[doc = r"Sets the field bit"]
63    #[inline(always)]
64    pub fn set_bit(self) -> &'a mut W {
65        self.bit(true)
66    }
67    #[doc = r"Clears the field bit"]
68    #[inline(always)]
69    pub fn clear_bit(self) -> &'a mut W {
70        self.bit(false)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub fn bit(self, value: bool) -> &'a mut W {
75        self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
76        self.w
77    }
78}
79#[doc = "Reader of field `YEARU`"]
80pub type YEARU_R = crate::R<u8, u8>;
81#[doc = "Write proxy for field `YEARU`"]
82pub struct YEARU_W<'a> {
83    w: &'a mut W,
84}
85impl<'a> YEARU_W<'a> {
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub unsafe fn bits(self, value: u8) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
90        self.w
91    }
92}
93#[doc = "Reader of field `YEART`"]
94pub type YEART_R = crate::R<u8, u8>;
95#[doc = "Write proxy for field `YEART`"]
96pub struct YEART_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> YEART_W<'a> {
100    #[doc = r"Writes raw bits to the field"]
101    #[inline(always)]
102    pub unsafe fn bits(self, value: u8) -> &'a mut W {
103        self.w.bits = (self.w.bits & !(0x0f << 20)) | (((value as u32) & 0x0f) << 20);
104        self.w
105    }
106}
107#[doc = "Reader of field `DAYOW`"]
108pub type DAYOW_R = crate::R<u8, u8>;
109#[doc = "Write proxy for field `DAYOW`"]
110pub struct DAYOW_W<'a> {
111    w: &'a mut W,
112}
113impl<'a> DAYOW_W<'a> {
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub unsafe fn bits(self, value: u8) -> &'a mut W {
117        self.w.bits = (self.w.bits & !(0x07 << 24)) | (((value as u32) & 0x07) << 24);
118        self.w
119    }
120}
121impl R {
122    #[doc = "Bits 0:3 - Day of Month, Units"]
123    #[inline(always)]
124    pub fn dayomu(&self) -> DAYOMU_R {
125        DAYOMU_R::new((self.bits & 0x0f) as u8)
126    }
127    #[doc = "Bits 4:5 - Day of Month, Tens"]
128    #[inline(always)]
129    pub fn dayomt(&self) -> DAYOMT_R {
130        DAYOMT_R::new(((self.bits >> 4) & 0x03) as u8)
131    }
132    #[doc = "Bits 8:11 - Month, Units"]
133    #[inline(always)]
134    pub fn monthu(&self) -> MONTHU_R {
135        MONTHU_R::new(((self.bits >> 8) & 0x0f) as u8)
136    }
137    #[doc = "Bit 12 - Month, Tens"]
138    #[inline(always)]
139    pub fn montht(&self) -> MONTHT_R {
140        MONTHT_R::new(((self.bits >> 12) & 0x01) != 0)
141    }
142    #[doc = "Bits 16:19 - Year, Units"]
143    #[inline(always)]
144    pub fn yearu(&self) -> YEARU_R {
145        YEARU_R::new(((self.bits >> 16) & 0x0f) as u8)
146    }
147    #[doc = "Bits 20:23 - Year, Tens"]
148    #[inline(always)]
149    pub fn yeart(&self) -> YEART_R {
150        YEART_R::new(((self.bits >> 20) & 0x0f) as u8)
151    }
152    #[doc = "Bits 24:26 - Day of Week"]
153    #[inline(always)]
154    pub fn dayow(&self) -> DAYOW_R {
155        DAYOW_R::new(((self.bits >> 24) & 0x07) as u8)
156    }
157}
158impl W {
159    #[doc = "Bits 0:3 - Day of Month, Units"]
160    #[inline(always)]
161    pub fn dayomu(&mut self) -> DAYOMU_W {
162        DAYOMU_W { w: self }
163    }
164    #[doc = "Bits 4:5 - Day of Month, Tens"]
165    #[inline(always)]
166    pub fn dayomt(&mut self) -> DAYOMT_W {
167        DAYOMT_W { w: self }
168    }
169    #[doc = "Bits 8:11 - Month, Units"]
170    #[inline(always)]
171    pub fn monthu(&mut self) -> MONTHU_W {
172        MONTHU_W { w: self }
173    }
174    #[doc = "Bit 12 - Month, Tens"]
175    #[inline(always)]
176    pub fn montht(&mut self) -> MONTHT_W {
177        MONTHT_W { w: self }
178    }
179    #[doc = "Bits 16:19 - Year, Units"]
180    #[inline(always)]
181    pub fn yearu(&mut self) -> YEARU_W {
182        YEARU_W { w: self }
183    }
184    #[doc = "Bits 20:23 - Year, Tens"]
185    #[inline(always)]
186    pub fn yeart(&mut self) -> YEART_W {
187        YEART_W { w: self }
188    }
189    #[doc = "Bits 24:26 - Day of Week"]
190    #[inline(always)]
191    pub fn dayow(&mut self) -> DAYOW_W {
192        DAYOW_W { w: self }
193    }
194}