saml10e16a/rtc/mode1/
ctrla.rs1#[doc = "Reader of register CTRLA"]
2pub type R = crate::R<u16, super::CTRLA>;
3#[doc = "Writer for register CTRLA"]
4pub type W = crate::W<u16, super::CTRLA>;
5#[doc = "Register CTRLA `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRLA {
7 type Type = u16;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Reader of field `SWRST`"]
14pub type SWRST_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `SWRST`"]
16pub struct SWRST_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> SWRST_W<'a> {
20 #[doc = r"Sets the field bit"]
21 #[inline(always)]
22 pub fn set_bit(self) -> &'a mut W {
23 self.bit(true)
24 }
25 #[doc = r"Clears the field bit"]
26 #[inline(always)]
27 pub fn clear_bit(self) -> &'a mut W {
28 self.bit(false)
29 }
30 #[doc = r"Writes raw bits to the field"]
31 #[inline(always)]
32 pub fn bit(self, value: bool) -> &'a mut W {
33 self.w.bits = (self.w.bits & !0x01) | ((value as u16) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `ENABLE`"]
38pub type ENABLE_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `ENABLE`"]
40pub struct ENABLE_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> ENABLE_W<'a> {
44 #[doc = r"Sets the field bit"]
45 #[inline(always)]
46 pub fn set_bit(self) -> &'a mut W {
47 self.bit(true)
48 }
49 #[doc = r"Clears the field bit"]
50 #[inline(always)]
51 pub fn clear_bit(self) -> &'a mut W {
52 self.bit(false)
53 }
54 #[doc = r"Writes raw bits to the field"]
55 #[inline(always)]
56 pub fn bit(self, value: bool) -> &'a mut W {
57 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u16) & 0x01) << 1);
58 self.w
59 }
60}
61#[doc = "Possible values of the field `MODE`"]
62#[derive(Clone, Copy, Debug, PartialEq)]
63pub enum MODE_A {
64 #[doc = "Mode 0: 32-bit Counter"]
65 COUNT32,
66 #[doc = "Mode 1: 16-bit Counter"]
67 COUNT16,
68 #[doc = "Mode 2: Clock/Calendar"]
69 CLOCK,
70}
71impl crate::ToBits<u8> for MODE_A {
72 #[inline(always)]
73 fn _bits(&self) -> u8 {
74 match *self {
75 MODE_A::COUNT32 => 0,
76 MODE_A::COUNT16 => 1,
77 MODE_A::CLOCK => 2,
78 }
79 }
80}
81#[doc = "Reader of field `MODE`"]
82pub type MODE_R = crate::R<u8, MODE_A>;
83impl MODE_R {
84 #[doc = r"Get enumerated values variant"]
85 #[inline(always)]
86 pub fn variant(&self) -> crate::Variant<u8, MODE_A> {
87 use crate::Variant::*;
88 match self.bits {
89 0 => Val(MODE_A::COUNT32),
90 1 => Val(MODE_A::COUNT16),
91 2 => Val(MODE_A::CLOCK),
92 i => Res(i),
93 }
94 }
95 #[doc = "Checks if the value of the field is `COUNT32`"]
96 #[inline(always)]
97 pub fn is_count32(&self) -> bool {
98 *self == MODE_A::COUNT32
99 }
100 #[doc = "Checks if the value of the field is `COUNT16`"]
101 #[inline(always)]
102 pub fn is_count16(&self) -> bool {
103 *self == MODE_A::COUNT16
104 }
105 #[doc = "Checks if the value of the field is `CLOCK`"]
106 #[inline(always)]
107 pub fn is_clock(&self) -> bool {
108 *self == MODE_A::CLOCK
109 }
110}
111#[doc = "Write proxy for field `MODE`"]
112pub struct MODE_W<'a> {
113 w: &'a mut W,
114}
115impl<'a> MODE_W<'a> {
116 #[doc = r"Writes `variant` to the field"]
117 #[inline(always)]
118 pub fn variant(self, variant: MODE_A) -> &'a mut W {
119 use crate::ToBits;
120 unsafe { self.bits(variant._bits()) }
121 }
122 #[doc = "Mode 0: 32-bit Counter"]
123 #[inline(always)]
124 pub fn count32(self) -> &'a mut W {
125 self.variant(MODE_A::COUNT32)
126 }
127 #[doc = "Mode 1: 16-bit Counter"]
128 #[inline(always)]
129 pub fn count16(self) -> &'a mut W {
130 self.variant(MODE_A::COUNT16)
131 }
132 #[doc = "Mode 2: Clock/Calendar"]
133 #[inline(always)]
134 pub fn clock(self) -> &'a mut W {
135 self.variant(MODE_A::CLOCK)
136 }
137 #[doc = r"Writes raw bits to the field"]
138 #[inline(always)]
139 pub unsafe fn bits(self, value: u8) -> &'a mut W {
140 self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u16) & 0x03) << 2);
141 self.w
142 }
143}
144#[doc = "Possible values of the field `PRESCALER`"]
145#[derive(Clone, Copy, Debug, PartialEq)]
146pub enum PRESCALER_A {
147 #[doc = "CLK_RTC_CNT = GCLK_RTC/1"]
148 OFF,
149 #[doc = "CLK_RTC_CNT = GCLK_RTC/1"]
150 DIV1,
151 #[doc = "CLK_RTC_CNT = GCLK_RTC/2"]
152 DIV2,
153 #[doc = "CLK_RTC_CNT = GCLK_RTC/4"]
154 DIV4,
155 #[doc = "CLK_RTC_CNT = GCLK_RTC/8"]
156 DIV8,
157 #[doc = "CLK_RTC_CNT = GCLK_RTC/16"]
158 DIV16,
159 #[doc = "CLK_RTC_CNT = GCLK_RTC/32"]
160 DIV32,
161 #[doc = "CLK_RTC_CNT = GCLK_RTC/64"]
162 DIV64,
163 #[doc = "CLK_RTC_CNT = GCLK_RTC/128"]
164 DIV128,
165 #[doc = "CLK_RTC_CNT = GCLK_RTC/256"]
166 DIV256,
167 #[doc = "CLK_RTC_CNT = GCLK_RTC/512"]
168 DIV512,
169 #[doc = "CLK_RTC_CNT = GCLK_RTC/1024"]
170 DIV1024,
171}
172impl crate::ToBits<u8> for PRESCALER_A {
173 #[inline(always)]
174 fn _bits(&self) -> u8 {
175 match *self {
176 PRESCALER_A::OFF => 0,
177 PRESCALER_A::DIV1 => 1,
178 PRESCALER_A::DIV2 => 2,
179 PRESCALER_A::DIV4 => 3,
180 PRESCALER_A::DIV8 => 4,
181 PRESCALER_A::DIV16 => 5,
182 PRESCALER_A::DIV32 => 6,
183 PRESCALER_A::DIV64 => 7,
184 PRESCALER_A::DIV128 => 8,
185 PRESCALER_A::DIV256 => 9,
186 PRESCALER_A::DIV512 => 10,
187 PRESCALER_A::DIV1024 => 11,
188 }
189 }
190}
191#[doc = "Reader of field `PRESCALER`"]
192pub type PRESCALER_R = crate::R<u8, PRESCALER_A>;
193impl PRESCALER_R {
194 #[doc = r"Get enumerated values variant"]
195 #[inline(always)]
196 pub fn variant(&self) -> crate::Variant<u8, PRESCALER_A> {
197 use crate::Variant::*;
198 match self.bits {
199 0 => Val(PRESCALER_A::OFF),
200 1 => Val(PRESCALER_A::DIV1),
201 2 => Val(PRESCALER_A::DIV2),
202 3 => Val(PRESCALER_A::DIV4),
203 4 => Val(PRESCALER_A::DIV8),
204 5 => Val(PRESCALER_A::DIV16),
205 6 => Val(PRESCALER_A::DIV32),
206 7 => Val(PRESCALER_A::DIV64),
207 8 => Val(PRESCALER_A::DIV128),
208 9 => Val(PRESCALER_A::DIV256),
209 10 => Val(PRESCALER_A::DIV512),
210 11 => Val(PRESCALER_A::DIV1024),
211 i => Res(i),
212 }
213 }
214 #[doc = "Checks if the value of the field is `OFF`"]
215 #[inline(always)]
216 pub fn is_off(&self) -> bool {
217 *self == PRESCALER_A::OFF
218 }
219 #[doc = "Checks if the value of the field is `DIV1`"]
220 #[inline(always)]
221 pub fn is_div1(&self) -> bool {
222 *self == PRESCALER_A::DIV1
223 }
224 #[doc = "Checks if the value of the field is `DIV2`"]
225 #[inline(always)]
226 pub fn is_div2(&self) -> bool {
227 *self == PRESCALER_A::DIV2
228 }
229 #[doc = "Checks if the value of the field is `DIV4`"]
230 #[inline(always)]
231 pub fn is_div4(&self) -> bool {
232 *self == PRESCALER_A::DIV4
233 }
234 #[doc = "Checks if the value of the field is `DIV8`"]
235 #[inline(always)]
236 pub fn is_div8(&self) -> bool {
237 *self == PRESCALER_A::DIV8
238 }
239 #[doc = "Checks if the value of the field is `DIV16`"]
240 #[inline(always)]
241 pub fn is_div16(&self) -> bool {
242 *self == PRESCALER_A::DIV16
243 }
244 #[doc = "Checks if the value of the field is `DIV32`"]
245 #[inline(always)]
246 pub fn is_div32(&self) -> bool {
247 *self == PRESCALER_A::DIV32
248 }
249 #[doc = "Checks if the value of the field is `DIV64`"]
250 #[inline(always)]
251 pub fn is_div64(&self) -> bool {
252 *self == PRESCALER_A::DIV64
253 }
254 #[doc = "Checks if the value of the field is `DIV128`"]
255 #[inline(always)]
256 pub fn is_div128(&self) -> bool {
257 *self == PRESCALER_A::DIV128
258 }
259 #[doc = "Checks if the value of the field is `DIV256`"]
260 #[inline(always)]
261 pub fn is_div256(&self) -> bool {
262 *self == PRESCALER_A::DIV256
263 }
264 #[doc = "Checks if the value of the field is `DIV512`"]
265 #[inline(always)]
266 pub fn is_div512(&self) -> bool {
267 *self == PRESCALER_A::DIV512
268 }
269 #[doc = "Checks if the value of the field is `DIV1024`"]
270 #[inline(always)]
271 pub fn is_div1024(&self) -> bool {
272 *self == PRESCALER_A::DIV1024
273 }
274}
275#[doc = "Write proxy for field `PRESCALER`"]
276pub struct PRESCALER_W<'a> {
277 w: &'a mut W,
278}
279impl<'a> PRESCALER_W<'a> {
280 #[doc = r"Writes `variant` to the field"]
281 #[inline(always)]
282 pub fn variant(self, variant: PRESCALER_A) -> &'a mut W {
283 use crate::ToBits;
284 unsafe { self.bits(variant._bits()) }
285 }
286 #[doc = "CLK_RTC_CNT = GCLK_RTC/1"]
287 #[inline(always)]
288 pub fn off(self) -> &'a mut W {
289 self.variant(PRESCALER_A::OFF)
290 }
291 #[doc = "CLK_RTC_CNT = GCLK_RTC/1"]
292 #[inline(always)]
293 pub fn div1(self) -> &'a mut W {
294 self.variant(PRESCALER_A::DIV1)
295 }
296 #[doc = "CLK_RTC_CNT = GCLK_RTC/2"]
297 #[inline(always)]
298 pub fn div2(self) -> &'a mut W {
299 self.variant(PRESCALER_A::DIV2)
300 }
301 #[doc = "CLK_RTC_CNT = GCLK_RTC/4"]
302 #[inline(always)]
303 pub fn div4(self) -> &'a mut W {
304 self.variant(PRESCALER_A::DIV4)
305 }
306 #[doc = "CLK_RTC_CNT = GCLK_RTC/8"]
307 #[inline(always)]
308 pub fn div8(self) -> &'a mut W {
309 self.variant(PRESCALER_A::DIV8)
310 }
311 #[doc = "CLK_RTC_CNT = GCLK_RTC/16"]
312 #[inline(always)]
313 pub fn div16(self) -> &'a mut W {
314 self.variant(PRESCALER_A::DIV16)
315 }
316 #[doc = "CLK_RTC_CNT = GCLK_RTC/32"]
317 #[inline(always)]
318 pub fn div32(self) -> &'a mut W {
319 self.variant(PRESCALER_A::DIV32)
320 }
321 #[doc = "CLK_RTC_CNT = GCLK_RTC/64"]
322 #[inline(always)]
323 pub fn div64(self) -> &'a mut W {
324 self.variant(PRESCALER_A::DIV64)
325 }
326 #[doc = "CLK_RTC_CNT = GCLK_RTC/128"]
327 #[inline(always)]
328 pub fn div128(self) -> &'a mut W {
329 self.variant(PRESCALER_A::DIV128)
330 }
331 #[doc = "CLK_RTC_CNT = GCLK_RTC/256"]
332 #[inline(always)]
333 pub fn div256(self) -> &'a mut W {
334 self.variant(PRESCALER_A::DIV256)
335 }
336 #[doc = "CLK_RTC_CNT = GCLK_RTC/512"]
337 #[inline(always)]
338 pub fn div512(self) -> &'a mut W {
339 self.variant(PRESCALER_A::DIV512)
340 }
341 #[doc = "CLK_RTC_CNT = GCLK_RTC/1024"]
342 #[inline(always)]
343 pub fn div1024(self) -> &'a mut W {
344 self.variant(PRESCALER_A::DIV1024)
345 }
346 #[doc = r"Writes raw bits to the field"]
347 #[inline(always)]
348 pub unsafe fn bits(self, value: u8) -> &'a mut W {
349 self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u16) & 0x0f) << 8);
350 self.w
351 }
352}
353#[doc = "Reader of field `GPTRST`"]
354pub type GPTRST_R = crate::R<bool, bool>;
355#[doc = "Write proxy for field `GPTRST`"]
356pub struct GPTRST_W<'a> {
357 w: &'a mut W,
358}
359impl<'a> GPTRST_W<'a> {
360 #[doc = r"Sets the field bit"]
361 #[inline(always)]
362 pub fn set_bit(self) -> &'a mut W {
363 self.bit(true)
364 }
365 #[doc = r"Clears the field bit"]
366 #[inline(always)]
367 pub fn clear_bit(self) -> &'a mut W {
368 self.bit(false)
369 }
370 #[doc = r"Writes raw bits to the field"]
371 #[inline(always)]
372 pub fn bit(self, value: bool) -> &'a mut W {
373 self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u16) & 0x01) << 14);
374 self.w
375 }
376}
377#[doc = "Reader of field `COUNTSYNC`"]
378pub type COUNTSYNC_R = crate::R<bool, bool>;
379#[doc = "Write proxy for field `COUNTSYNC`"]
380pub struct COUNTSYNC_W<'a> {
381 w: &'a mut W,
382}
383impl<'a> COUNTSYNC_W<'a> {
384 #[doc = r"Sets the field bit"]
385 #[inline(always)]
386 pub fn set_bit(self) -> &'a mut W {
387 self.bit(true)
388 }
389 #[doc = r"Clears the field bit"]
390 #[inline(always)]
391 pub fn clear_bit(self) -> &'a mut W {
392 self.bit(false)
393 }
394 #[doc = r"Writes raw bits to the field"]
395 #[inline(always)]
396 pub fn bit(self, value: bool) -> &'a mut W {
397 self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u16) & 0x01) << 15);
398 self.w
399 }
400}
401impl R {
402 #[doc = "Bit 0 - Software Reset"]
403 #[inline(always)]
404 pub fn swrst(&self) -> SWRST_R {
405 SWRST_R::new((self.bits & 0x01) != 0)
406 }
407 #[doc = "Bit 1 - Enable"]
408 #[inline(always)]
409 pub fn enable(&self) -> ENABLE_R {
410 ENABLE_R::new(((self.bits >> 1) & 0x01) != 0)
411 }
412 #[doc = "Bits 2:3 - Operating Mode"]
413 #[inline(always)]
414 pub fn mode(&self) -> MODE_R {
415 MODE_R::new(((self.bits >> 2) & 0x03) as u8)
416 }
417 #[doc = "Bits 8:11 - Prescaler"]
418 #[inline(always)]
419 pub fn prescaler(&self) -> PRESCALER_R {
420 PRESCALER_R::new(((self.bits >> 8) & 0x0f) as u8)
421 }
422 #[doc = "Bit 14 - GP Registers Reset On Tamper Enable"]
423 #[inline(always)]
424 pub fn gptrst(&self) -> GPTRST_R {
425 GPTRST_R::new(((self.bits >> 14) & 0x01) != 0)
426 }
427 #[doc = "Bit 15 - Count Read Synchronization Enable"]
428 #[inline(always)]
429 pub fn countsync(&self) -> COUNTSYNC_R {
430 COUNTSYNC_R::new(((self.bits >> 15) & 0x01) != 0)
431 }
432}
433impl W {
434 #[doc = "Bit 0 - Software Reset"]
435 #[inline(always)]
436 pub fn swrst(&mut self) -> SWRST_W {
437 SWRST_W { w: self }
438 }
439 #[doc = "Bit 1 - Enable"]
440 #[inline(always)]
441 pub fn enable(&mut self) -> ENABLE_W {
442 ENABLE_W { w: self }
443 }
444 #[doc = "Bits 2:3 - Operating Mode"]
445 #[inline(always)]
446 pub fn mode(&mut self) -> MODE_W {
447 MODE_W { w: self }
448 }
449 #[doc = "Bits 8:11 - Prescaler"]
450 #[inline(always)]
451 pub fn prescaler(&mut self) -> PRESCALER_W {
452 PRESCALER_W { w: self }
453 }
454 #[doc = "Bit 14 - GP Registers Reset On Tamper Enable"]
455 #[inline(always)]
456 pub fn gptrst(&mut self) -> GPTRST_W {
457 GPTRST_W { w: self }
458 }
459 #[doc = "Bit 15 - Count Read Synchronization Enable"]
460 #[inline(always)]
461 pub fn countsync(&mut self) -> COUNTSYNC_W {
462 COUNTSYNC_W { w: self }
463 }
464}