ra2e1/wdt/
wdtcr.rs

1#[doc = "Register `WDTCR` reader"]
2pub struct R(crate::R<WDTCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<WDTCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<WDTCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<WDTCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `WDTCR` writer"]
17pub struct W(crate::W<WDTCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<WDTCR_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<WDTCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<WDTCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TOPS` reader - Timeout Period Select"]
38pub type TOPS_R = crate::FieldReader<u8, TOPS_A>;
39#[doc = "Timeout Period Select\n\nValue on reset: 3"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum TOPS_A {
43    #[doc = "0: 1024 cycles (0x03FF)"]
44    _00 = 0,
45    #[doc = "1: 4096 cycles (0x0FFF)"]
46    _01 = 1,
47    #[doc = "2: 8192 cycles (0x1FFF)"]
48    _10 = 2,
49    #[doc = "3: 16384 cycles (0x3FFF)"]
50    _11 = 3,
51}
52impl From<TOPS_A> for u8 {
53    #[inline(always)]
54    fn from(variant: TOPS_A) -> Self {
55        variant as _
56    }
57}
58impl TOPS_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> TOPS_A {
62        match self.bits {
63            0 => TOPS_A::_00,
64            1 => TOPS_A::_01,
65            2 => TOPS_A::_10,
66            3 => TOPS_A::_11,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_00`"]
71    #[inline(always)]
72    pub fn is_00(&self) -> bool {
73        *self == TOPS_A::_00
74    }
75    #[doc = "Checks if the value of the field is `_01`"]
76    #[inline(always)]
77    pub fn is_01(&self) -> bool {
78        *self == TOPS_A::_01
79    }
80    #[doc = "Checks if the value of the field is `_10`"]
81    #[inline(always)]
82    pub fn is_10(&self) -> bool {
83        *self == TOPS_A::_10
84    }
85    #[doc = "Checks if the value of the field is `_11`"]
86    #[inline(always)]
87    pub fn is_11(&self) -> bool {
88        *self == TOPS_A::_11
89    }
90}
91#[doc = "Field `TOPS` writer - Timeout Period Select"]
92pub type TOPS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u16, WDTCR_SPEC, u8, TOPS_A, 2, O>;
93impl<'a, const O: u8> TOPS_W<'a, O> {
94    #[doc = "1024 cycles (0x03FF)"]
95    #[inline(always)]
96    pub fn _00(self) -> &'a mut W {
97        self.variant(TOPS_A::_00)
98    }
99    #[doc = "4096 cycles (0x0FFF)"]
100    #[inline(always)]
101    pub fn _01(self) -> &'a mut W {
102        self.variant(TOPS_A::_01)
103    }
104    #[doc = "8192 cycles (0x1FFF)"]
105    #[inline(always)]
106    pub fn _10(self) -> &'a mut W {
107        self.variant(TOPS_A::_10)
108    }
109    #[doc = "16384 cycles (0x3FFF)"]
110    #[inline(always)]
111    pub fn _11(self) -> &'a mut W {
112        self.variant(TOPS_A::_11)
113    }
114}
115#[doc = "Field `CKS` reader - Clock Division Ratio Select"]
116pub type CKS_R = crate::FieldReader<u8, CKS_A>;
117#[doc = "Clock Division Ratio Select\n\nValue on reset: 15"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119#[repr(u8)]
120pub enum CKS_A {
121    #[doc = "1: PCLKB/4"]
122    _0X1 = 1,
123    #[doc = "4: PCLKB/64"]
124    _0X4 = 4,
125    #[doc = "15: PCLKB/128"]
126    _0X_F = 15,
127    #[doc = "6: PCLKB/512"]
128    _0X6 = 6,
129    #[doc = "7: PCLKB/2048"]
130    _0X7 = 7,
131    #[doc = "8: PCLKB/8192"]
132    _0X8 = 8,
133}
134impl From<CKS_A> for u8 {
135    #[inline(always)]
136    fn from(variant: CKS_A) -> Self {
137        variant as _
138    }
139}
140impl CKS_R {
141    #[doc = "Get enumerated values variant"]
142    #[inline(always)]
143    pub fn variant(&self) -> Option<CKS_A> {
144        match self.bits {
145            1 => Some(CKS_A::_0X1),
146            4 => Some(CKS_A::_0X4),
147            15 => Some(CKS_A::_0X_F),
148            6 => Some(CKS_A::_0X6),
149            7 => Some(CKS_A::_0X7),
150            8 => Some(CKS_A::_0X8),
151            _ => None,
152        }
153    }
154    #[doc = "Checks if the value of the field is `_0X1`"]
155    #[inline(always)]
156    pub fn is_0x1(&self) -> bool {
157        *self == CKS_A::_0X1
158    }
159    #[doc = "Checks if the value of the field is `_0X4`"]
160    #[inline(always)]
161    pub fn is_0x4(&self) -> bool {
162        *self == CKS_A::_0X4
163    }
164    #[doc = "Checks if the value of the field is `_0X_F`"]
165    #[inline(always)]
166    pub fn is_0x_f(&self) -> bool {
167        *self == CKS_A::_0X_F
168    }
169    #[doc = "Checks if the value of the field is `_0X6`"]
170    #[inline(always)]
171    pub fn is_0x6(&self) -> bool {
172        *self == CKS_A::_0X6
173    }
174    #[doc = "Checks if the value of the field is `_0X7`"]
175    #[inline(always)]
176    pub fn is_0x7(&self) -> bool {
177        *self == CKS_A::_0X7
178    }
179    #[doc = "Checks if the value of the field is `_0X8`"]
180    #[inline(always)]
181    pub fn is_0x8(&self) -> bool {
182        *self == CKS_A::_0X8
183    }
184}
185#[doc = "Field `CKS` writer - Clock Division Ratio Select"]
186pub type CKS_W<'a, const O: u8> = crate::FieldWriter<'a, u16, WDTCR_SPEC, u8, CKS_A, 4, O>;
187impl<'a, const O: u8> CKS_W<'a, O> {
188    #[doc = "PCLKB/4"]
189    #[inline(always)]
190    pub fn _0x1(self) -> &'a mut W {
191        self.variant(CKS_A::_0X1)
192    }
193    #[doc = "PCLKB/64"]
194    #[inline(always)]
195    pub fn _0x4(self) -> &'a mut W {
196        self.variant(CKS_A::_0X4)
197    }
198    #[doc = "PCLKB/128"]
199    #[inline(always)]
200    pub fn _0x_f(self) -> &'a mut W {
201        self.variant(CKS_A::_0X_F)
202    }
203    #[doc = "PCLKB/512"]
204    #[inline(always)]
205    pub fn _0x6(self) -> &'a mut W {
206        self.variant(CKS_A::_0X6)
207    }
208    #[doc = "PCLKB/2048"]
209    #[inline(always)]
210    pub fn _0x7(self) -> &'a mut W {
211        self.variant(CKS_A::_0X7)
212    }
213    #[doc = "PCLKB/8192"]
214    #[inline(always)]
215    pub fn _0x8(self) -> &'a mut W {
216        self.variant(CKS_A::_0X8)
217    }
218}
219#[doc = "Field `RPES` reader - Window End Position Select"]
220pub type RPES_R = crate::FieldReader<u8, RPES_A>;
221#[doc = "Window End Position Select\n\nValue on reset: 3"]
222#[derive(Clone, Copy, Debug, PartialEq, Eq)]
223#[repr(u8)]
224pub enum RPES_A {
225    #[doc = "0: 75%"]
226    _00 = 0,
227    #[doc = "1: 50%"]
228    _01 = 1,
229    #[doc = "2: 25%"]
230    _10 = 2,
231    #[doc = "3: 0% (do not specify window end position)."]
232    _11 = 3,
233}
234impl From<RPES_A> for u8 {
235    #[inline(always)]
236    fn from(variant: RPES_A) -> Self {
237        variant as _
238    }
239}
240impl RPES_R {
241    #[doc = "Get enumerated values variant"]
242    #[inline(always)]
243    pub fn variant(&self) -> RPES_A {
244        match self.bits {
245            0 => RPES_A::_00,
246            1 => RPES_A::_01,
247            2 => RPES_A::_10,
248            3 => RPES_A::_11,
249            _ => unreachable!(),
250        }
251    }
252    #[doc = "Checks if the value of the field is `_00`"]
253    #[inline(always)]
254    pub fn is_00(&self) -> bool {
255        *self == RPES_A::_00
256    }
257    #[doc = "Checks if the value of the field is `_01`"]
258    #[inline(always)]
259    pub fn is_01(&self) -> bool {
260        *self == RPES_A::_01
261    }
262    #[doc = "Checks if the value of the field is `_10`"]
263    #[inline(always)]
264    pub fn is_10(&self) -> bool {
265        *self == RPES_A::_10
266    }
267    #[doc = "Checks if the value of the field is `_11`"]
268    #[inline(always)]
269    pub fn is_11(&self) -> bool {
270        *self == RPES_A::_11
271    }
272}
273#[doc = "Field `RPES` writer - Window End Position Select"]
274pub type RPES_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u16, WDTCR_SPEC, u8, RPES_A, 2, O>;
275impl<'a, const O: u8> RPES_W<'a, O> {
276    #[doc = "75%"]
277    #[inline(always)]
278    pub fn _00(self) -> &'a mut W {
279        self.variant(RPES_A::_00)
280    }
281    #[doc = "50%"]
282    #[inline(always)]
283    pub fn _01(self) -> &'a mut W {
284        self.variant(RPES_A::_01)
285    }
286    #[doc = "25%"]
287    #[inline(always)]
288    pub fn _10(self) -> &'a mut W {
289        self.variant(RPES_A::_10)
290    }
291    #[doc = "0% (do not specify window end position)."]
292    #[inline(always)]
293    pub fn _11(self) -> &'a mut W {
294        self.variant(RPES_A::_11)
295    }
296}
297#[doc = "Field `RPSS` reader - Window Start Position Select"]
298pub type RPSS_R = crate::FieldReader<u8, RPSS_A>;
299#[doc = "Window Start Position Select\n\nValue on reset: 3"]
300#[derive(Clone, Copy, Debug, PartialEq, Eq)]
301#[repr(u8)]
302pub enum RPSS_A {
303    #[doc = "0: 25%"]
304    _00 = 0,
305    #[doc = "1: 50%"]
306    _01 = 1,
307    #[doc = "2: 75%"]
308    _10 = 2,
309    #[doc = "3: 100% (do not specify window start position)."]
310    _11 = 3,
311}
312impl From<RPSS_A> for u8 {
313    #[inline(always)]
314    fn from(variant: RPSS_A) -> Self {
315        variant as _
316    }
317}
318impl RPSS_R {
319    #[doc = "Get enumerated values variant"]
320    #[inline(always)]
321    pub fn variant(&self) -> RPSS_A {
322        match self.bits {
323            0 => RPSS_A::_00,
324            1 => RPSS_A::_01,
325            2 => RPSS_A::_10,
326            3 => RPSS_A::_11,
327            _ => unreachable!(),
328        }
329    }
330    #[doc = "Checks if the value of the field is `_00`"]
331    #[inline(always)]
332    pub fn is_00(&self) -> bool {
333        *self == RPSS_A::_00
334    }
335    #[doc = "Checks if the value of the field is `_01`"]
336    #[inline(always)]
337    pub fn is_01(&self) -> bool {
338        *self == RPSS_A::_01
339    }
340    #[doc = "Checks if the value of the field is `_10`"]
341    #[inline(always)]
342    pub fn is_10(&self) -> bool {
343        *self == RPSS_A::_10
344    }
345    #[doc = "Checks if the value of the field is `_11`"]
346    #[inline(always)]
347    pub fn is_11(&self) -> bool {
348        *self == RPSS_A::_11
349    }
350}
351#[doc = "Field `RPSS` writer - Window Start Position Select"]
352pub type RPSS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u16, WDTCR_SPEC, u8, RPSS_A, 2, O>;
353impl<'a, const O: u8> RPSS_W<'a, O> {
354    #[doc = "25%"]
355    #[inline(always)]
356    pub fn _00(self) -> &'a mut W {
357        self.variant(RPSS_A::_00)
358    }
359    #[doc = "50%"]
360    #[inline(always)]
361    pub fn _01(self) -> &'a mut W {
362        self.variant(RPSS_A::_01)
363    }
364    #[doc = "75%"]
365    #[inline(always)]
366    pub fn _10(self) -> &'a mut W {
367        self.variant(RPSS_A::_10)
368    }
369    #[doc = "100% (do not specify window start position)."]
370    #[inline(always)]
371    pub fn _11(self) -> &'a mut W {
372        self.variant(RPSS_A::_11)
373    }
374}
375impl R {
376    #[doc = "Bits 0:1 - Timeout Period Select"]
377    #[inline(always)]
378    pub fn tops(&self) -> TOPS_R {
379        TOPS_R::new((self.bits & 3) as u8)
380    }
381    #[doc = "Bits 4:7 - Clock Division Ratio Select"]
382    #[inline(always)]
383    pub fn cks(&self) -> CKS_R {
384        CKS_R::new(((self.bits >> 4) & 0x0f) as u8)
385    }
386    #[doc = "Bits 8:9 - Window End Position Select"]
387    #[inline(always)]
388    pub fn rpes(&self) -> RPES_R {
389        RPES_R::new(((self.bits >> 8) & 3) as u8)
390    }
391    #[doc = "Bits 12:13 - Window Start Position Select"]
392    #[inline(always)]
393    pub fn rpss(&self) -> RPSS_R {
394        RPSS_R::new(((self.bits >> 12) & 3) as u8)
395    }
396}
397impl W {
398    #[doc = "Bits 0:1 - Timeout Period Select"]
399    #[inline(always)]
400    #[must_use]
401    pub fn tops(&mut self) -> TOPS_W<0> {
402        TOPS_W::new(self)
403    }
404    #[doc = "Bits 4:7 - Clock Division Ratio Select"]
405    #[inline(always)]
406    #[must_use]
407    pub fn cks(&mut self) -> CKS_W<4> {
408        CKS_W::new(self)
409    }
410    #[doc = "Bits 8:9 - Window End Position Select"]
411    #[inline(always)]
412    #[must_use]
413    pub fn rpes(&mut self) -> RPES_W<8> {
414        RPES_W::new(self)
415    }
416    #[doc = "Bits 12:13 - Window Start Position Select"]
417    #[inline(always)]
418    #[must_use]
419    pub fn rpss(&mut self) -> RPSS_W<12> {
420        RPSS_W::new(self)
421    }
422    #[doc = "Writes raw bits to the register."]
423    #[inline(always)]
424    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
425        self.0.bits(bits);
426        self
427    }
428}
429#[doc = "WDT 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 [wdtcr](index.html) module"]
430pub struct WDTCR_SPEC;
431impl crate::RegisterSpec for WDTCR_SPEC {
432    type Ux = u16;
433}
434#[doc = "`read()` method returns [wdtcr::R](R) reader structure"]
435impl crate::Readable for WDTCR_SPEC {
436    type Reader = R;
437}
438#[doc = "`write(|w| ..)` method takes [wdtcr::W](W) writer structure"]
439impl crate::Writable for WDTCR_SPEC {
440    type Writer = W;
441    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
442    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
443}
444#[doc = "`reset()` method sets WDTCR to value 0x33f3"]
445impl crate::Resettable for WDTCR_SPEC {
446    const RESET_VALUE: Self::Ux = 0x33f3;
447}