avr_device/devices/atmega4809/rtc/
ctrla.rs1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `RTCEN` reader - Enable"]
38pub type RTCEN_R = crate::BitReader<bool>;
39#[doc = "Field `RTCEN` writer - Enable"]
40pub type RTCEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
41#[doc = "Field `CORREN` reader - Correction enable"]
42pub type CORREN_R = crate::BitReader<bool>;
43#[doc = "Field `CORREN` writer - Correction enable"]
44pub type CORREN_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
45#[doc = "Field `PRESCALER` reader - Prescaling Factor"]
46pub type PRESCALER_R = crate::FieldReader<u8, PRESCALER_A>;
47#[doc = "Prescaling Factor\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum PRESCALER_A {
51 #[doc = "0: RTC Clock / 1"]
52 DIV1 = 0,
53 #[doc = "1: RTC Clock / 2"]
54 DIV2 = 1,
55 #[doc = "2: RTC Clock / 4"]
56 DIV4 = 2,
57 #[doc = "3: RTC Clock / 8"]
58 DIV8 = 3,
59 #[doc = "4: RTC Clock / 16"]
60 DIV16 = 4,
61 #[doc = "5: RTC Clock / 32"]
62 DIV32 = 5,
63 #[doc = "6: RTC Clock / 64"]
64 DIV64 = 6,
65 #[doc = "7: RTC Clock / 128"]
66 DIV128 = 7,
67 #[doc = "8: RTC Clock / 256"]
68 DIV256 = 8,
69 #[doc = "9: RTC Clock / 512"]
70 DIV512 = 9,
71 #[doc = "10: RTC Clock / 1024"]
72 DIV1024 = 10,
73 #[doc = "11: RTC Clock / 2048"]
74 DIV2048 = 11,
75 #[doc = "12: RTC Clock / 4096"]
76 DIV4096 = 12,
77 #[doc = "13: RTC Clock / 8192"]
78 DIV8192 = 13,
79 #[doc = "14: RTC Clock / 16384"]
80 DIV16384 = 14,
81 #[doc = "15: RTC Clock / 32768"]
82 DIV32768 = 15,
83}
84impl From<PRESCALER_A> for u8 {
85 #[inline(always)]
86 fn from(variant: PRESCALER_A) -> Self {
87 variant as _
88 }
89}
90impl PRESCALER_R {
91 #[doc = "Get enumerated values variant"]
92 #[inline(always)]
93 pub fn variant(&self) -> PRESCALER_A {
94 match self.bits {
95 0 => PRESCALER_A::DIV1,
96 1 => PRESCALER_A::DIV2,
97 2 => PRESCALER_A::DIV4,
98 3 => PRESCALER_A::DIV8,
99 4 => PRESCALER_A::DIV16,
100 5 => PRESCALER_A::DIV32,
101 6 => PRESCALER_A::DIV64,
102 7 => PRESCALER_A::DIV128,
103 8 => PRESCALER_A::DIV256,
104 9 => PRESCALER_A::DIV512,
105 10 => PRESCALER_A::DIV1024,
106 11 => PRESCALER_A::DIV2048,
107 12 => PRESCALER_A::DIV4096,
108 13 => PRESCALER_A::DIV8192,
109 14 => PRESCALER_A::DIV16384,
110 15 => PRESCALER_A::DIV32768,
111 _ => unreachable!(),
112 }
113 }
114 #[doc = "Checks if the value of the field is `DIV1`"]
115 #[inline(always)]
116 pub fn is_div1(&self) -> bool {
117 *self == PRESCALER_A::DIV1
118 }
119 #[doc = "Checks if the value of the field is `DIV2`"]
120 #[inline(always)]
121 pub fn is_div2(&self) -> bool {
122 *self == PRESCALER_A::DIV2
123 }
124 #[doc = "Checks if the value of the field is `DIV4`"]
125 #[inline(always)]
126 pub fn is_div4(&self) -> bool {
127 *self == PRESCALER_A::DIV4
128 }
129 #[doc = "Checks if the value of the field is `DIV8`"]
130 #[inline(always)]
131 pub fn is_div8(&self) -> bool {
132 *self == PRESCALER_A::DIV8
133 }
134 #[doc = "Checks if the value of the field is `DIV16`"]
135 #[inline(always)]
136 pub fn is_div16(&self) -> bool {
137 *self == PRESCALER_A::DIV16
138 }
139 #[doc = "Checks if the value of the field is `DIV32`"]
140 #[inline(always)]
141 pub fn is_div32(&self) -> bool {
142 *self == PRESCALER_A::DIV32
143 }
144 #[doc = "Checks if the value of the field is `DIV64`"]
145 #[inline(always)]
146 pub fn is_div64(&self) -> bool {
147 *self == PRESCALER_A::DIV64
148 }
149 #[doc = "Checks if the value of the field is `DIV128`"]
150 #[inline(always)]
151 pub fn is_div128(&self) -> bool {
152 *self == PRESCALER_A::DIV128
153 }
154 #[doc = "Checks if the value of the field is `DIV256`"]
155 #[inline(always)]
156 pub fn is_div256(&self) -> bool {
157 *self == PRESCALER_A::DIV256
158 }
159 #[doc = "Checks if the value of the field is `DIV512`"]
160 #[inline(always)]
161 pub fn is_div512(&self) -> bool {
162 *self == PRESCALER_A::DIV512
163 }
164 #[doc = "Checks if the value of the field is `DIV1024`"]
165 #[inline(always)]
166 pub fn is_div1024(&self) -> bool {
167 *self == PRESCALER_A::DIV1024
168 }
169 #[doc = "Checks if the value of the field is `DIV2048`"]
170 #[inline(always)]
171 pub fn is_div2048(&self) -> bool {
172 *self == PRESCALER_A::DIV2048
173 }
174 #[doc = "Checks if the value of the field is `DIV4096`"]
175 #[inline(always)]
176 pub fn is_div4096(&self) -> bool {
177 *self == PRESCALER_A::DIV4096
178 }
179 #[doc = "Checks if the value of the field is `DIV8192`"]
180 #[inline(always)]
181 pub fn is_div8192(&self) -> bool {
182 *self == PRESCALER_A::DIV8192
183 }
184 #[doc = "Checks if the value of the field is `DIV16384`"]
185 #[inline(always)]
186 pub fn is_div16384(&self) -> bool {
187 *self == PRESCALER_A::DIV16384
188 }
189 #[doc = "Checks if the value of the field is `DIV32768`"]
190 #[inline(always)]
191 pub fn is_div32768(&self) -> bool {
192 *self == PRESCALER_A::DIV32768
193 }
194}
195#[doc = "Field `PRESCALER` writer - Prescaling Factor"]
196pub type PRESCALER_W<'a, const O: u8> =
197 crate::FieldWriterSafe<'a, u8, CTRLA_SPEC, u8, PRESCALER_A, 4, O>;
198impl<'a, const O: u8> PRESCALER_W<'a, O> {
199 #[doc = "RTC Clock / 1"]
200 #[inline(always)]
201 pub fn div1(self) -> &'a mut W {
202 self.variant(PRESCALER_A::DIV1)
203 }
204 #[doc = "RTC Clock / 2"]
205 #[inline(always)]
206 pub fn div2(self) -> &'a mut W {
207 self.variant(PRESCALER_A::DIV2)
208 }
209 #[doc = "RTC Clock / 4"]
210 #[inline(always)]
211 pub fn div4(self) -> &'a mut W {
212 self.variant(PRESCALER_A::DIV4)
213 }
214 #[doc = "RTC Clock / 8"]
215 #[inline(always)]
216 pub fn div8(self) -> &'a mut W {
217 self.variant(PRESCALER_A::DIV8)
218 }
219 #[doc = "RTC Clock / 16"]
220 #[inline(always)]
221 pub fn div16(self) -> &'a mut W {
222 self.variant(PRESCALER_A::DIV16)
223 }
224 #[doc = "RTC Clock / 32"]
225 #[inline(always)]
226 pub fn div32(self) -> &'a mut W {
227 self.variant(PRESCALER_A::DIV32)
228 }
229 #[doc = "RTC Clock / 64"]
230 #[inline(always)]
231 pub fn div64(self) -> &'a mut W {
232 self.variant(PRESCALER_A::DIV64)
233 }
234 #[doc = "RTC Clock / 128"]
235 #[inline(always)]
236 pub fn div128(self) -> &'a mut W {
237 self.variant(PRESCALER_A::DIV128)
238 }
239 #[doc = "RTC Clock / 256"]
240 #[inline(always)]
241 pub fn div256(self) -> &'a mut W {
242 self.variant(PRESCALER_A::DIV256)
243 }
244 #[doc = "RTC Clock / 512"]
245 #[inline(always)]
246 pub fn div512(self) -> &'a mut W {
247 self.variant(PRESCALER_A::DIV512)
248 }
249 #[doc = "RTC Clock / 1024"]
250 #[inline(always)]
251 pub fn div1024(self) -> &'a mut W {
252 self.variant(PRESCALER_A::DIV1024)
253 }
254 #[doc = "RTC Clock / 2048"]
255 #[inline(always)]
256 pub fn div2048(self) -> &'a mut W {
257 self.variant(PRESCALER_A::DIV2048)
258 }
259 #[doc = "RTC Clock / 4096"]
260 #[inline(always)]
261 pub fn div4096(self) -> &'a mut W {
262 self.variant(PRESCALER_A::DIV4096)
263 }
264 #[doc = "RTC Clock / 8192"]
265 #[inline(always)]
266 pub fn div8192(self) -> &'a mut W {
267 self.variant(PRESCALER_A::DIV8192)
268 }
269 #[doc = "RTC Clock / 16384"]
270 #[inline(always)]
271 pub fn div16384(self) -> &'a mut W {
272 self.variant(PRESCALER_A::DIV16384)
273 }
274 #[doc = "RTC Clock / 32768"]
275 #[inline(always)]
276 pub fn div32768(self) -> &'a mut W {
277 self.variant(PRESCALER_A::DIV32768)
278 }
279}
280#[doc = "Field `RUNSTDBY` reader - Run In Standby"]
281pub type RUNSTDBY_R = crate::BitReader<bool>;
282#[doc = "Field `RUNSTDBY` writer - Run In Standby"]
283pub type RUNSTDBY_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
284impl R {
285 #[doc = "Bit 0 - Enable"]
286 #[inline(always)]
287 pub fn rtcen(&self) -> RTCEN_R {
288 RTCEN_R::new((self.bits & 1) != 0)
289 }
290 #[doc = "Bit 2 - Correction enable"]
291 #[inline(always)]
292 pub fn corren(&self) -> CORREN_R {
293 CORREN_R::new(((self.bits >> 2) & 1) != 0)
294 }
295 #[doc = "Bits 3:6 - Prescaling Factor"]
296 #[inline(always)]
297 pub fn prescaler(&self) -> PRESCALER_R {
298 PRESCALER_R::new((self.bits >> 3) & 0x0f)
299 }
300 #[doc = "Bit 7 - Run In Standby"]
301 #[inline(always)]
302 pub fn runstdby(&self) -> RUNSTDBY_R {
303 RUNSTDBY_R::new(((self.bits >> 7) & 1) != 0)
304 }
305}
306impl W {
307 #[doc = "Bit 0 - Enable"]
308 #[inline(always)]
309 #[must_use]
310 pub fn rtcen(&mut self) -> RTCEN_W<0> {
311 RTCEN_W::new(self)
312 }
313 #[doc = "Bit 2 - Correction enable"]
314 #[inline(always)]
315 #[must_use]
316 pub fn corren(&mut self) -> CORREN_W<2> {
317 CORREN_W::new(self)
318 }
319 #[doc = "Bits 3:6 - Prescaling Factor"]
320 #[inline(always)]
321 #[must_use]
322 pub fn prescaler(&mut self) -> PRESCALER_W<3> {
323 PRESCALER_W::new(self)
324 }
325 #[doc = "Bit 7 - Run In Standby"]
326 #[inline(always)]
327 #[must_use]
328 pub fn runstdby(&mut self) -> RUNSTDBY_W<7> {
329 RUNSTDBY_W::new(self)
330 }
331 #[doc = "Writes raw bits to the register."]
332 #[inline(always)]
333 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
334 self.0.bits(bits);
335 self
336 }
337}
338#[doc = "Control A\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 [ctrla](index.html) module"]
339pub struct CTRLA_SPEC;
340impl crate::RegisterSpec for CTRLA_SPEC {
341 type Ux = u8;
342}
343#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
344impl crate::Readable for CTRLA_SPEC {
345 type Reader = R;
346}
347#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
348impl crate::Writable for CTRLA_SPEC {
349 type Writer = W;
350 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
351 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
352}
353#[doc = "`reset()` method sets CTRLA to value 0"]
354impl crate::Resettable for CTRLA_SPEC {
355 const RESET_VALUE: Self::Ux = 0;
356}