avr_device/devices/atmega4809/wdt/
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 `PERIOD` reader - Period"]
38pub type PERIOD_R = crate::FieldReader<u8, PERIOD_A>;
39#[doc = "Period\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum PERIOD_A {
43 #[doc = "0: Off"]
44 OFF = 0,
45 #[doc = "1: 8 cycles (8ms)"]
46 _8CLK = 1,
47 #[doc = "2: 16 cycles (16ms)"]
48 _16CLK = 2,
49 #[doc = "3: 32 cycles (32ms)"]
50 _32CLK = 3,
51 #[doc = "4: 64 cycles (64ms)"]
52 _64CLK = 4,
53 #[doc = "5: 128 cycles (0.128s)"]
54 _128CLK = 5,
55 #[doc = "6: 256 cycles (0.256s)"]
56 _256CLK = 6,
57 #[doc = "7: 512 cycles (0.512s)"]
58 _512CLK = 7,
59 #[doc = "8: 1K cycles (1.0s)"]
60 _1KCLK = 8,
61 #[doc = "9: 2K cycles (2.0s)"]
62 _2KCLK = 9,
63 #[doc = "10: 4K cycles (4.1s)"]
64 _4KCLK = 10,
65 #[doc = "11: 8K cycles (8.2s)"]
66 _8KCLK = 11,
67}
68impl From<PERIOD_A> for u8 {
69 #[inline(always)]
70 fn from(variant: PERIOD_A) -> Self {
71 variant as _
72 }
73}
74impl PERIOD_R {
75 #[doc = "Get enumerated values variant"]
76 #[inline(always)]
77 pub fn variant(&self) -> Option<PERIOD_A> {
78 match self.bits {
79 0 => Some(PERIOD_A::OFF),
80 1 => Some(PERIOD_A::_8CLK),
81 2 => Some(PERIOD_A::_16CLK),
82 3 => Some(PERIOD_A::_32CLK),
83 4 => Some(PERIOD_A::_64CLK),
84 5 => Some(PERIOD_A::_128CLK),
85 6 => Some(PERIOD_A::_256CLK),
86 7 => Some(PERIOD_A::_512CLK),
87 8 => Some(PERIOD_A::_1KCLK),
88 9 => Some(PERIOD_A::_2KCLK),
89 10 => Some(PERIOD_A::_4KCLK),
90 11 => Some(PERIOD_A::_8KCLK),
91 _ => None,
92 }
93 }
94 #[doc = "Checks if the value of the field is `OFF`"]
95 #[inline(always)]
96 pub fn is_off(&self) -> bool {
97 *self == PERIOD_A::OFF
98 }
99 #[doc = "Checks if the value of the field is `_8CLK`"]
100 #[inline(always)]
101 pub fn is_8clk(&self) -> bool {
102 *self == PERIOD_A::_8CLK
103 }
104 #[doc = "Checks if the value of the field is `_16CLK`"]
105 #[inline(always)]
106 pub fn is_16clk(&self) -> bool {
107 *self == PERIOD_A::_16CLK
108 }
109 #[doc = "Checks if the value of the field is `_32CLK`"]
110 #[inline(always)]
111 pub fn is_32clk(&self) -> bool {
112 *self == PERIOD_A::_32CLK
113 }
114 #[doc = "Checks if the value of the field is `_64CLK`"]
115 #[inline(always)]
116 pub fn is_64clk(&self) -> bool {
117 *self == PERIOD_A::_64CLK
118 }
119 #[doc = "Checks if the value of the field is `_128CLK`"]
120 #[inline(always)]
121 pub fn is_128clk(&self) -> bool {
122 *self == PERIOD_A::_128CLK
123 }
124 #[doc = "Checks if the value of the field is `_256CLK`"]
125 #[inline(always)]
126 pub fn is_256clk(&self) -> bool {
127 *self == PERIOD_A::_256CLK
128 }
129 #[doc = "Checks if the value of the field is `_512CLK`"]
130 #[inline(always)]
131 pub fn is_512clk(&self) -> bool {
132 *self == PERIOD_A::_512CLK
133 }
134 #[doc = "Checks if the value of the field is `_1KCLK`"]
135 #[inline(always)]
136 pub fn is_1kclk(&self) -> bool {
137 *self == PERIOD_A::_1KCLK
138 }
139 #[doc = "Checks if the value of the field is `_2KCLK`"]
140 #[inline(always)]
141 pub fn is_2kclk(&self) -> bool {
142 *self == PERIOD_A::_2KCLK
143 }
144 #[doc = "Checks if the value of the field is `_4KCLK`"]
145 #[inline(always)]
146 pub fn is_4kclk(&self) -> bool {
147 *self == PERIOD_A::_4KCLK
148 }
149 #[doc = "Checks if the value of the field is `_8KCLK`"]
150 #[inline(always)]
151 pub fn is_8kclk(&self) -> bool {
152 *self == PERIOD_A::_8KCLK
153 }
154}
155#[doc = "Field `PERIOD` writer - Period"]
156pub type PERIOD_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLA_SPEC, u8, PERIOD_A, 4, O>;
157impl<'a, const O: u8> PERIOD_W<'a, O> {
158 #[doc = "Off"]
159 #[inline(always)]
160 pub fn off(self) -> &'a mut W {
161 self.variant(PERIOD_A::OFF)
162 }
163 #[doc = "8 cycles (8ms)"]
164 #[inline(always)]
165 pub fn _8clk(self) -> &'a mut W {
166 self.variant(PERIOD_A::_8CLK)
167 }
168 #[doc = "16 cycles (16ms)"]
169 #[inline(always)]
170 pub fn _16clk(self) -> &'a mut W {
171 self.variant(PERIOD_A::_16CLK)
172 }
173 #[doc = "32 cycles (32ms)"]
174 #[inline(always)]
175 pub fn _32clk(self) -> &'a mut W {
176 self.variant(PERIOD_A::_32CLK)
177 }
178 #[doc = "64 cycles (64ms)"]
179 #[inline(always)]
180 pub fn _64clk(self) -> &'a mut W {
181 self.variant(PERIOD_A::_64CLK)
182 }
183 #[doc = "128 cycles (0.128s)"]
184 #[inline(always)]
185 pub fn _128clk(self) -> &'a mut W {
186 self.variant(PERIOD_A::_128CLK)
187 }
188 #[doc = "256 cycles (0.256s)"]
189 #[inline(always)]
190 pub fn _256clk(self) -> &'a mut W {
191 self.variant(PERIOD_A::_256CLK)
192 }
193 #[doc = "512 cycles (0.512s)"]
194 #[inline(always)]
195 pub fn _512clk(self) -> &'a mut W {
196 self.variant(PERIOD_A::_512CLK)
197 }
198 #[doc = "1K cycles (1.0s)"]
199 #[inline(always)]
200 pub fn _1kclk(self) -> &'a mut W {
201 self.variant(PERIOD_A::_1KCLK)
202 }
203 #[doc = "2K cycles (2.0s)"]
204 #[inline(always)]
205 pub fn _2kclk(self) -> &'a mut W {
206 self.variant(PERIOD_A::_2KCLK)
207 }
208 #[doc = "4K cycles (4.1s)"]
209 #[inline(always)]
210 pub fn _4kclk(self) -> &'a mut W {
211 self.variant(PERIOD_A::_4KCLK)
212 }
213 #[doc = "8K cycles (8.2s)"]
214 #[inline(always)]
215 pub fn _8kclk(self) -> &'a mut W {
216 self.variant(PERIOD_A::_8KCLK)
217 }
218}
219#[doc = "Field `WINDOW` reader - Window"]
220pub type WINDOW_R = crate::FieldReader<u8, WINDOW_A>;
221#[doc = "Window\n\nValue on reset: 0"]
222#[derive(Clone, Copy, Debug, PartialEq, Eq)]
223#[repr(u8)]
224pub enum WINDOW_A {
225 #[doc = "0: Off"]
226 OFF = 0,
227 #[doc = "1: 8 cycles (8ms)"]
228 _8CLK = 1,
229 #[doc = "2: 16 cycles (16ms)"]
230 _16CLK = 2,
231 #[doc = "3: 32 cycles (32ms)"]
232 _32CLK = 3,
233 #[doc = "4: 64 cycles (64ms)"]
234 _64CLK = 4,
235 #[doc = "5: 128 cycles (0.128s)"]
236 _128CLK = 5,
237 #[doc = "6: 256 cycles (0.256s)"]
238 _256CLK = 6,
239 #[doc = "7: 512 cycles (0.512s)"]
240 _512CLK = 7,
241 #[doc = "8: 1K cycles (1.0s)"]
242 _1KCLK = 8,
243 #[doc = "9: 2K cycles (2.0s)"]
244 _2KCLK = 9,
245 #[doc = "10: 4K cycles (4.1s)"]
246 _4KCLK = 10,
247 #[doc = "11: 8K cycles (8.2s)"]
248 _8KCLK = 11,
249}
250impl From<WINDOW_A> for u8 {
251 #[inline(always)]
252 fn from(variant: WINDOW_A) -> Self {
253 variant as _
254 }
255}
256impl WINDOW_R {
257 #[doc = "Get enumerated values variant"]
258 #[inline(always)]
259 pub fn variant(&self) -> Option<WINDOW_A> {
260 match self.bits {
261 0 => Some(WINDOW_A::OFF),
262 1 => Some(WINDOW_A::_8CLK),
263 2 => Some(WINDOW_A::_16CLK),
264 3 => Some(WINDOW_A::_32CLK),
265 4 => Some(WINDOW_A::_64CLK),
266 5 => Some(WINDOW_A::_128CLK),
267 6 => Some(WINDOW_A::_256CLK),
268 7 => Some(WINDOW_A::_512CLK),
269 8 => Some(WINDOW_A::_1KCLK),
270 9 => Some(WINDOW_A::_2KCLK),
271 10 => Some(WINDOW_A::_4KCLK),
272 11 => Some(WINDOW_A::_8KCLK),
273 _ => None,
274 }
275 }
276 #[doc = "Checks if the value of the field is `OFF`"]
277 #[inline(always)]
278 pub fn is_off(&self) -> bool {
279 *self == WINDOW_A::OFF
280 }
281 #[doc = "Checks if the value of the field is `_8CLK`"]
282 #[inline(always)]
283 pub fn is_8clk(&self) -> bool {
284 *self == WINDOW_A::_8CLK
285 }
286 #[doc = "Checks if the value of the field is `_16CLK`"]
287 #[inline(always)]
288 pub fn is_16clk(&self) -> bool {
289 *self == WINDOW_A::_16CLK
290 }
291 #[doc = "Checks if the value of the field is `_32CLK`"]
292 #[inline(always)]
293 pub fn is_32clk(&self) -> bool {
294 *self == WINDOW_A::_32CLK
295 }
296 #[doc = "Checks if the value of the field is `_64CLK`"]
297 #[inline(always)]
298 pub fn is_64clk(&self) -> bool {
299 *self == WINDOW_A::_64CLK
300 }
301 #[doc = "Checks if the value of the field is `_128CLK`"]
302 #[inline(always)]
303 pub fn is_128clk(&self) -> bool {
304 *self == WINDOW_A::_128CLK
305 }
306 #[doc = "Checks if the value of the field is `_256CLK`"]
307 #[inline(always)]
308 pub fn is_256clk(&self) -> bool {
309 *self == WINDOW_A::_256CLK
310 }
311 #[doc = "Checks if the value of the field is `_512CLK`"]
312 #[inline(always)]
313 pub fn is_512clk(&self) -> bool {
314 *self == WINDOW_A::_512CLK
315 }
316 #[doc = "Checks if the value of the field is `_1KCLK`"]
317 #[inline(always)]
318 pub fn is_1kclk(&self) -> bool {
319 *self == WINDOW_A::_1KCLK
320 }
321 #[doc = "Checks if the value of the field is `_2KCLK`"]
322 #[inline(always)]
323 pub fn is_2kclk(&self) -> bool {
324 *self == WINDOW_A::_2KCLK
325 }
326 #[doc = "Checks if the value of the field is `_4KCLK`"]
327 #[inline(always)]
328 pub fn is_4kclk(&self) -> bool {
329 *self == WINDOW_A::_4KCLK
330 }
331 #[doc = "Checks if the value of the field is `_8KCLK`"]
332 #[inline(always)]
333 pub fn is_8kclk(&self) -> bool {
334 *self == WINDOW_A::_8KCLK
335 }
336}
337#[doc = "Field `WINDOW` writer - Window"]
338pub type WINDOW_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLA_SPEC, u8, WINDOW_A, 4, O>;
339impl<'a, const O: u8> WINDOW_W<'a, O> {
340 #[doc = "Off"]
341 #[inline(always)]
342 pub fn off(self) -> &'a mut W {
343 self.variant(WINDOW_A::OFF)
344 }
345 #[doc = "8 cycles (8ms)"]
346 #[inline(always)]
347 pub fn _8clk(self) -> &'a mut W {
348 self.variant(WINDOW_A::_8CLK)
349 }
350 #[doc = "16 cycles (16ms)"]
351 #[inline(always)]
352 pub fn _16clk(self) -> &'a mut W {
353 self.variant(WINDOW_A::_16CLK)
354 }
355 #[doc = "32 cycles (32ms)"]
356 #[inline(always)]
357 pub fn _32clk(self) -> &'a mut W {
358 self.variant(WINDOW_A::_32CLK)
359 }
360 #[doc = "64 cycles (64ms)"]
361 #[inline(always)]
362 pub fn _64clk(self) -> &'a mut W {
363 self.variant(WINDOW_A::_64CLK)
364 }
365 #[doc = "128 cycles (0.128s)"]
366 #[inline(always)]
367 pub fn _128clk(self) -> &'a mut W {
368 self.variant(WINDOW_A::_128CLK)
369 }
370 #[doc = "256 cycles (0.256s)"]
371 #[inline(always)]
372 pub fn _256clk(self) -> &'a mut W {
373 self.variant(WINDOW_A::_256CLK)
374 }
375 #[doc = "512 cycles (0.512s)"]
376 #[inline(always)]
377 pub fn _512clk(self) -> &'a mut W {
378 self.variant(WINDOW_A::_512CLK)
379 }
380 #[doc = "1K cycles (1.0s)"]
381 #[inline(always)]
382 pub fn _1kclk(self) -> &'a mut W {
383 self.variant(WINDOW_A::_1KCLK)
384 }
385 #[doc = "2K cycles (2.0s)"]
386 #[inline(always)]
387 pub fn _2kclk(self) -> &'a mut W {
388 self.variant(WINDOW_A::_2KCLK)
389 }
390 #[doc = "4K cycles (4.1s)"]
391 #[inline(always)]
392 pub fn _4kclk(self) -> &'a mut W {
393 self.variant(WINDOW_A::_4KCLK)
394 }
395 #[doc = "8K cycles (8.2s)"]
396 #[inline(always)]
397 pub fn _8kclk(self) -> &'a mut W {
398 self.variant(WINDOW_A::_8KCLK)
399 }
400}
401impl R {
402 #[doc = "Bits 0:3 - Period"]
403 #[inline(always)]
404 pub fn period(&self) -> PERIOD_R {
405 PERIOD_R::new(self.bits & 0x0f)
406 }
407 #[doc = "Bits 4:7 - Window"]
408 #[inline(always)]
409 pub fn window(&self) -> WINDOW_R {
410 WINDOW_R::new((self.bits >> 4) & 0x0f)
411 }
412}
413impl W {
414 #[doc = "Bits 0:3 - Period"]
415 #[inline(always)]
416 #[must_use]
417 pub fn period(&mut self) -> PERIOD_W<0> {
418 PERIOD_W::new(self)
419 }
420 #[doc = "Bits 4:7 - Window"]
421 #[inline(always)]
422 #[must_use]
423 pub fn window(&mut self) -> WINDOW_W<4> {
424 WINDOW_W::new(self)
425 }
426 #[doc = "Writes raw bits to the register."]
427 #[inline(always)]
428 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
429 self.0.bits(bits);
430 self
431 }
432}
433#[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"]
434pub struct CTRLA_SPEC;
435impl crate::RegisterSpec for CTRLA_SPEC {
436 type Ux = u8;
437}
438#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
439impl crate::Readable for CTRLA_SPEC {
440 type Reader = R;
441}
442#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
443impl crate::Writable for CTRLA_SPEC {
444 type Writer = W;
445 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
446 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
447}
448#[doc = "`reset()` method sets CTRLA to value 0"]
449impl crate::Resettable for CTRLA_SPEC {
450 const RESET_VALUE: Self::Ux = 0;
451}