1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Select the self wake-up timer clock source. Remark: This bit only has an effect if the SEL_EXTCLK bit is not set.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum CLKSEL_A {
40 #[doc = "0: Divided IRC clock. This clock runs at 750 kHz and provides time-out periods of up to approximately 95 minutes in 1.33 us increments. Remark: This clock is not available in not available in Deep-sleep, power-down, deep power-down modes. Do not select this option if the timer is to be used to wake up from one of these modes."]
41 DIVIDED_IRC_CLOCK = 0,
42 #[doc = "1: This is the (nominally) 10 kHz clock and provides time-out periods of up to approximately 119 hours in 100 us increments. The accuracy of this clock is limited to +/- 40 % over temperature and processing. Remark: This clock is available in all power modes. Prior to use, the low-power oscillator must be enabled. The oscillator must also be set to remain active in Deep power-down if needed."]
43 LOW_POWER_CLOCK = 1,
44}
45impl From<CLKSEL_A> for bool {
46 #[inline(always)]
47 fn from(variant: CLKSEL_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `CLKSEL` reader - Select the self wake-up timer clock source. Remark: This bit only has an effect if the SEL_EXTCLK bit is not set."]
52pub struct CLKSEL_R(crate::FieldReader<bool, CLKSEL_A>);
53impl CLKSEL_R {
54 pub(crate) fn new(bits: bool) -> Self {
55 CLKSEL_R(crate::FieldReader::new(bits))
56 }
57 #[doc = r"Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> CLKSEL_A {
60 match self.bits {
61 false => CLKSEL_A::DIVIDED_IRC_CLOCK,
62 true => CLKSEL_A::LOW_POWER_CLOCK,
63 }
64 }
65 #[doc = "Checks if the value of the field is `DIVIDED_IRC_CLOCK`"]
66 #[inline(always)]
67 pub fn is_divided_irc_clock(&self) -> bool {
68 **self == CLKSEL_A::DIVIDED_IRC_CLOCK
69 }
70 #[doc = "Checks if the value of the field is `LOW_POWER_CLOCK`"]
71 #[inline(always)]
72 pub fn is_low_power_clock(&self) -> bool {
73 **self == CLKSEL_A::LOW_POWER_CLOCK
74 }
75}
76impl core::ops::Deref for CLKSEL_R {
77 type Target = crate::FieldReader<bool, CLKSEL_A>;
78 #[inline(always)]
79 fn deref(&self) -> &Self::Target {
80 &self.0
81 }
82}
83#[doc = "Field `CLKSEL` writer - Select the self wake-up timer clock source. Remark: This bit only has an effect if the SEL_EXTCLK bit is not set."]
84pub struct CLKSEL_W<'a> {
85 w: &'a mut W,
86}
87impl<'a> CLKSEL_W<'a> {
88 #[doc = r"Writes `variant` to the field"]
89 #[inline(always)]
90 pub fn variant(self, variant: CLKSEL_A) -> &'a mut W {
91 self.bit(variant.into())
92 }
93 #[doc = "Divided IRC clock. This clock runs at 750 kHz and provides time-out periods of up to approximately 95 minutes in 1.33 us increments. Remark: This clock is not available in not available in Deep-sleep, power-down, deep power-down modes. Do not select this option if the timer is to be used to wake up from one of these modes."]
94 #[inline(always)]
95 pub fn divided_irc_clock(self) -> &'a mut W {
96 self.variant(CLKSEL_A::DIVIDED_IRC_CLOCK)
97 }
98 #[doc = "This is the (nominally) 10 kHz clock and provides time-out periods of up to approximately 119 hours in 100 us increments. The accuracy of this clock is limited to +/- 40 % over temperature and processing. Remark: This clock is available in all power modes. Prior to use, the low-power oscillator must be enabled. The oscillator must also be set to remain active in Deep power-down if needed."]
99 #[inline(always)]
100 pub fn low_power_clock(self) -> &'a mut W {
101 self.variant(CLKSEL_A::LOW_POWER_CLOCK)
102 }
103 #[doc = r"Sets the field bit"]
104 #[inline(always)]
105 pub fn set_bit(self) -> &'a mut W {
106 self.bit(true)
107 }
108 #[doc = r"Clears the field bit"]
109 #[inline(always)]
110 pub fn clear_bit(self) -> &'a mut W {
111 self.bit(false)
112 }
113 #[doc = r"Writes raw bits to the field"]
114 #[inline(always)]
115 pub fn bit(self, value: bool) -> &'a mut W {
116 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
117 self.w
118 }
119}
120#[doc = "Wake-up or alarm timer flag.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum ALARMFLAG_A {
123 #[doc = "0: No time-out. The self wake-up timer has not timed out. Writing a 0 to has no effect."]
124 NO_TIME_OUT = 0,
125 #[doc = "1: Time-out. The self wake-up timer has timed out. This flag generates an interrupt request which can wake up the part from any reduced power mode including Deep power-down if the clock source is the low power oscillator. Writing a 1 clears this status bit."]
126 TIME_OUT = 1,
127}
128impl From<ALARMFLAG_A> for bool {
129 #[inline(always)]
130 fn from(variant: ALARMFLAG_A) -> Self {
131 variant as u8 != 0
132 }
133}
134#[doc = "Field `ALARMFLAG` reader - Wake-up or alarm timer flag."]
135pub struct ALARMFLAG_R(crate::FieldReader<bool, ALARMFLAG_A>);
136impl ALARMFLAG_R {
137 pub(crate) fn new(bits: bool) -> Self {
138 ALARMFLAG_R(crate::FieldReader::new(bits))
139 }
140 #[doc = r"Get enumerated values variant"]
141 #[inline(always)]
142 pub fn variant(&self) -> ALARMFLAG_A {
143 match self.bits {
144 false => ALARMFLAG_A::NO_TIME_OUT,
145 true => ALARMFLAG_A::TIME_OUT,
146 }
147 }
148 #[doc = "Checks if the value of the field is `NO_TIME_OUT`"]
149 #[inline(always)]
150 pub fn is_no_time_out(&self) -> bool {
151 **self == ALARMFLAG_A::NO_TIME_OUT
152 }
153 #[doc = "Checks if the value of the field is `TIME_OUT`"]
154 #[inline(always)]
155 pub fn is_time_out(&self) -> bool {
156 **self == ALARMFLAG_A::TIME_OUT
157 }
158}
159impl core::ops::Deref for ALARMFLAG_R {
160 type Target = crate::FieldReader<bool, ALARMFLAG_A>;
161 #[inline(always)]
162 fn deref(&self) -> &Self::Target {
163 &self.0
164 }
165}
166#[doc = "Field `ALARMFLAG` writer - Wake-up or alarm timer flag."]
167pub struct ALARMFLAG_W<'a> {
168 w: &'a mut W,
169}
170impl<'a> ALARMFLAG_W<'a> {
171 #[doc = r"Writes `variant` to the field"]
172 #[inline(always)]
173 pub fn variant(self, variant: ALARMFLAG_A) -> &'a mut W {
174 self.bit(variant.into())
175 }
176 #[doc = "No time-out. The self wake-up timer has not timed out. Writing a 0 to has no effect."]
177 #[inline(always)]
178 pub fn no_time_out(self) -> &'a mut W {
179 self.variant(ALARMFLAG_A::NO_TIME_OUT)
180 }
181 #[doc = "Time-out. The self wake-up timer has timed out. This flag generates an interrupt request which can wake up the part from any reduced power mode including Deep power-down if the clock source is the low power oscillator. Writing a 1 clears this status bit."]
182 #[inline(always)]
183 pub fn time_out(self) -> &'a mut W {
184 self.variant(ALARMFLAG_A::TIME_OUT)
185 }
186 #[doc = r"Sets the field bit"]
187 #[inline(always)]
188 pub fn set_bit(self) -> &'a mut W {
189 self.bit(true)
190 }
191 #[doc = r"Clears the field bit"]
192 #[inline(always)]
193 pub fn clear_bit(self) -> &'a mut W {
194 self.bit(false)
195 }
196 #[doc = r"Writes raw bits to the field"]
197 #[inline(always)]
198 pub fn bit(self, value: bool) -> &'a mut W {
199 self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
200 self.w
201 }
202}
203#[doc = "Clears the self wake-up timer.\n\nValue on reset: 0"]
204#[derive(Clone, Copy, Debug, PartialEq)]
205pub enum CLEARCTR_A {
206 #[doc = "0: No effect. Reading this bit always returns 0."]
207 NO_EFFECT = 0,
208 #[doc = "1: Clear the counter. Counting is halted until a new count value is loaded."]
209 CLEAR_THE_COUNTER = 1,
210}
211impl From<CLEARCTR_A> for bool {
212 #[inline(always)]
213 fn from(variant: CLEARCTR_A) -> Self {
214 variant as u8 != 0
215 }
216}
217#[doc = "Field `CLEARCTR` reader - Clears the self wake-up timer."]
218pub struct CLEARCTR_R(crate::FieldReader<bool, CLEARCTR_A>);
219impl CLEARCTR_R {
220 pub(crate) fn new(bits: bool) -> Self {
221 CLEARCTR_R(crate::FieldReader::new(bits))
222 }
223 #[doc = r"Get enumerated values variant"]
224 #[inline(always)]
225 pub fn variant(&self) -> CLEARCTR_A {
226 match self.bits {
227 false => CLEARCTR_A::NO_EFFECT,
228 true => CLEARCTR_A::CLEAR_THE_COUNTER,
229 }
230 }
231 #[doc = "Checks if the value of the field is `NO_EFFECT`"]
232 #[inline(always)]
233 pub fn is_no_effect(&self) -> bool {
234 **self == CLEARCTR_A::NO_EFFECT
235 }
236 #[doc = "Checks if the value of the field is `CLEAR_THE_COUNTER`"]
237 #[inline(always)]
238 pub fn is_clear_the_counter(&self) -> bool {
239 **self == CLEARCTR_A::CLEAR_THE_COUNTER
240 }
241}
242impl core::ops::Deref for CLEARCTR_R {
243 type Target = crate::FieldReader<bool, CLEARCTR_A>;
244 #[inline(always)]
245 fn deref(&self) -> &Self::Target {
246 &self.0
247 }
248}
249#[doc = "Field `CLEARCTR` writer - Clears the self wake-up timer."]
250pub struct CLEARCTR_W<'a> {
251 w: &'a mut W,
252}
253impl<'a> CLEARCTR_W<'a> {
254 #[doc = r"Writes `variant` to the field"]
255 #[inline(always)]
256 pub fn variant(self, variant: CLEARCTR_A) -> &'a mut W {
257 self.bit(variant.into())
258 }
259 #[doc = "No effect. Reading this bit always returns 0."]
260 #[inline(always)]
261 pub fn no_effect(self) -> &'a mut W {
262 self.variant(CLEARCTR_A::NO_EFFECT)
263 }
264 #[doc = "Clear the counter. Counting is halted until a new count value is loaded."]
265 #[inline(always)]
266 pub fn clear_the_counter(self) -> &'a mut W {
267 self.variant(CLEARCTR_A::CLEAR_THE_COUNTER)
268 }
269 #[doc = r"Sets the field bit"]
270 #[inline(always)]
271 pub fn set_bit(self) -> &'a mut W {
272 self.bit(true)
273 }
274 #[doc = r"Clears the field bit"]
275 #[inline(always)]
276 pub fn clear_bit(self) -> &'a mut W {
277 self.bit(false)
278 }
279 #[doc = r"Writes raw bits to the field"]
280 #[inline(always)]
281 pub fn bit(self, value: bool) -> &'a mut W {
282 self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
283 self.w
284 }
285}
286#[doc = "Select external or internal clock source for the self wake-up timer. The internal clock source is selected by the CLKSEL bit in this register if SET_EXTCLK is set to internal.\n\nValue on reset: 0"]
287#[derive(Clone, Copy, Debug, PartialEq)]
288pub enum SEL_EXTCLK_A {
289 #[doc = "0: Internal. The clock source is the internal clock selected by the CLKSEL bit."]
290 INTERNAL = 0,
291 #[doc = "1: External. The self wake-up timer uses the external WKTCLKIN pin."]
292 EXTERNAL = 1,
293}
294impl From<SEL_EXTCLK_A> for bool {
295 #[inline(always)]
296 fn from(variant: SEL_EXTCLK_A) -> Self {
297 variant as u8 != 0
298 }
299}
300#[doc = "Field `SEL_EXTCLK` reader - Select external or internal clock source for the self wake-up timer. The internal clock source is selected by the CLKSEL bit in this register if SET_EXTCLK is set to internal."]
301pub struct SEL_EXTCLK_R(crate::FieldReader<bool, SEL_EXTCLK_A>);
302impl SEL_EXTCLK_R {
303 pub(crate) fn new(bits: bool) -> Self {
304 SEL_EXTCLK_R(crate::FieldReader::new(bits))
305 }
306 #[doc = r"Get enumerated values variant"]
307 #[inline(always)]
308 pub fn variant(&self) -> SEL_EXTCLK_A {
309 match self.bits {
310 false => SEL_EXTCLK_A::INTERNAL,
311 true => SEL_EXTCLK_A::EXTERNAL,
312 }
313 }
314 #[doc = "Checks if the value of the field is `INTERNAL`"]
315 #[inline(always)]
316 pub fn is_internal(&self) -> bool {
317 **self == SEL_EXTCLK_A::INTERNAL
318 }
319 #[doc = "Checks if the value of the field is `EXTERNAL`"]
320 #[inline(always)]
321 pub fn is_external(&self) -> bool {
322 **self == SEL_EXTCLK_A::EXTERNAL
323 }
324}
325impl core::ops::Deref for SEL_EXTCLK_R {
326 type Target = crate::FieldReader<bool, SEL_EXTCLK_A>;
327 #[inline(always)]
328 fn deref(&self) -> &Self::Target {
329 &self.0
330 }
331}
332#[doc = "Field `SEL_EXTCLK` writer - Select external or internal clock source for the self wake-up timer. The internal clock source is selected by the CLKSEL bit in this register if SET_EXTCLK is set to internal."]
333pub struct SEL_EXTCLK_W<'a> {
334 w: &'a mut W,
335}
336impl<'a> SEL_EXTCLK_W<'a> {
337 #[doc = r"Writes `variant` to the field"]
338 #[inline(always)]
339 pub fn variant(self, variant: SEL_EXTCLK_A) -> &'a mut W {
340 self.bit(variant.into())
341 }
342 #[doc = "Internal. The clock source is the internal clock selected by the CLKSEL bit."]
343 #[inline(always)]
344 pub fn internal(self) -> &'a mut W {
345 self.variant(SEL_EXTCLK_A::INTERNAL)
346 }
347 #[doc = "External. The self wake-up timer uses the external WKTCLKIN pin."]
348 #[inline(always)]
349 pub fn external(self) -> &'a mut W {
350 self.variant(SEL_EXTCLK_A::EXTERNAL)
351 }
352 #[doc = r"Sets the field bit"]
353 #[inline(always)]
354 pub fn set_bit(self) -> &'a mut W {
355 self.bit(true)
356 }
357 #[doc = r"Clears the field bit"]
358 #[inline(always)]
359 pub fn clear_bit(self) -> &'a mut W {
360 self.bit(false)
361 }
362 #[doc = r"Writes raw bits to the field"]
363 #[inline(always)]
364 pub fn bit(self, value: bool) -> &'a mut W {
365 self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
366 self.w
367 }
368}
369impl R {
370 #[doc = "Bit 0 - Select the self wake-up timer clock source. Remark: This bit only has an effect if the SEL_EXTCLK bit is not set."]
371 #[inline(always)]
372 pub fn clksel(&self) -> CLKSEL_R {
373 CLKSEL_R::new((self.bits & 0x01) != 0)
374 }
375 #[doc = "Bit 1 - Wake-up or alarm timer flag."]
376 #[inline(always)]
377 pub fn alarmflag(&self) -> ALARMFLAG_R {
378 ALARMFLAG_R::new(((self.bits >> 1) & 0x01) != 0)
379 }
380 #[doc = "Bit 2 - Clears the self wake-up timer."]
381 #[inline(always)]
382 pub fn clearctr(&self) -> CLEARCTR_R {
383 CLEARCTR_R::new(((self.bits >> 2) & 0x01) != 0)
384 }
385 #[doc = "Bit 3 - Select external or internal clock source for the self wake-up timer. The internal clock source is selected by the CLKSEL bit in this register if SET_EXTCLK is set to internal."]
386 #[inline(always)]
387 pub fn sel_extclk(&self) -> SEL_EXTCLK_R {
388 SEL_EXTCLK_R::new(((self.bits >> 3) & 0x01) != 0)
389 }
390}
391impl W {
392 #[doc = "Bit 0 - Select the self wake-up timer clock source. Remark: This bit only has an effect if the SEL_EXTCLK bit is not set."]
393 #[inline(always)]
394 pub fn clksel(&mut self) -> CLKSEL_W {
395 CLKSEL_W { w: self }
396 }
397 #[doc = "Bit 1 - Wake-up or alarm timer flag."]
398 #[inline(always)]
399 pub fn alarmflag(&mut self) -> ALARMFLAG_W {
400 ALARMFLAG_W { w: self }
401 }
402 #[doc = "Bit 2 - Clears the self wake-up timer."]
403 #[inline(always)]
404 pub fn clearctr(&mut self) -> CLEARCTR_W {
405 CLEARCTR_W { w: self }
406 }
407 #[doc = "Bit 3 - Select external or internal clock source for the self wake-up timer. The internal clock source is selected by the CLKSEL bit in this register if SET_EXTCLK is set to internal."]
408 #[inline(always)]
409 pub fn sel_extclk(&mut self) -> SEL_EXTCLK_W {
410 SEL_EXTCLK_W { w: self }
411 }
412 #[doc = "Writes raw bits to the register."]
413 #[inline(always)]
414 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
415 self.0.bits(bits);
416 self
417 }
418}
419#[doc = "Self wake-up timer 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 [ctrl](index.html) module"]
420pub struct CTRL_SPEC;
421impl crate::RegisterSpec for CTRL_SPEC {
422 type Ux = u32;
423}
424#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
425impl crate::Readable for CTRL_SPEC {
426 type Reader = R;
427}
428#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
429impl crate::Writable for CTRL_SPEC {
430 type Writer = W;
431}
432#[doc = "`reset()` method sets CTRL to value 0"]
433impl crate::Resettable for CTRL_SPEC {
434 #[inline(always)]
435 fn reset_value() -> Self::Ux {
436 0
437 }
438}