atsamd21e18a/wdt/
ewctrl.rs

1#[doc = "Reader of register EWCTRL"]
2pub type R = crate::R<u8, super::EWCTRL>;
3#[doc = "Writer for register EWCTRL"]
4pub type W = crate::W<u8, super::EWCTRL>;
5#[doc = "Register EWCTRL `reset()`'s with value 0x0b"]
6impl crate::ResetValue for super::EWCTRL {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x0b
11    }
12}
13#[doc = "Early Warning Interrupt Time Offset\n\nValue on reset: 11"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum EWOFFSET_A {
17    #[doc = "0: 8 clock cycles"]
18    _8 = 0,
19    #[doc = "1: 16 clock cycles"]
20    _16 = 1,
21    #[doc = "2: 32 clock cycles"]
22    _32 = 2,
23    #[doc = "3: 64 clock cycles"]
24    _64 = 3,
25    #[doc = "4: 128 clock cycles"]
26    _128 = 4,
27    #[doc = "5: 256 clock cycles"]
28    _256 = 5,
29    #[doc = "6: 512 clock cycles"]
30    _512 = 6,
31    #[doc = "7: 1024 clock cycles"]
32    _1K = 7,
33    #[doc = "8: 2048 clock cycles"]
34    _2K = 8,
35    #[doc = "9: 4096 clock cycles"]
36    _4K = 9,
37    #[doc = "10: 8192 clock cycles"]
38    _8K = 10,
39    #[doc = "11: 16384 clock cycles"]
40    _16K = 11,
41}
42impl From<EWOFFSET_A> for u8 {
43    #[inline(always)]
44    fn from(variant: EWOFFSET_A) -> Self {
45        variant as _
46    }
47}
48#[doc = "Reader of field `EWOFFSET`"]
49pub type EWOFFSET_R = crate::R<u8, EWOFFSET_A>;
50impl EWOFFSET_R {
51    #[doc = r"Get enumerated values variant"]
52    #[inline(always)]
53    pub fn variant(&self) -> crate::Variant<u8, EWOFFSET_A> {
54        use crate::Variant::*;
55        match self.bits {
56            0 => Val(EWOFFSET_A::_8),
57            1 => Val(EWOFFSET_A::_16),
58            2 => Val(EWOFFSET_A::_32),
59            3 => Val(EWOFFSET_A::_64),
60            4 => Val(EWOFFSET_A::_128),
61            5 => Val(EWOFFSET_A::_256),
62            6 => Val(EWOFFSET_A::_512),
63            7 => Val(EWOFFSET_A::_1K),
64            8 => Val(EWOFFSET_A::_2K),
65            9 => Val(EWOFFSET_A::_4K),
66            10 => Val(EWOFFSET_A::_8K),
67            11 => Val(EWOFFSET_A::_16K),
68            i => Res(i),
69        }
70    }
71    #[doc = "Checks if the value of the field is `_8`"]
72    #[inline(always)]
73    pub fn is_8(&self) -> bool {
74        *self == EWOFFSET_A::_8
75    }
76    #[doc = "Checks if the value of the field is `_16`"]
77    #[inline(always)]
78    pub fn is_16(&self) -> bool {
79        *self == EWOFFSET_A::_16
80    }
81    #[doc = "Checks if the value of the field is `_32`"]
82    #[inline(always)]
83    pub fn is_32(&self) -> bool {
84        *self == EWOFFSET_A::_32
85    }
86    #[doc = "Checks if the value of the field is `_64`"]
87    #[inline(always)]
88    pub fn is_64(&self) -> bool {
89        *self == EWOFFSET_A::_64
90    }
91    #[doc = "Checks if the value of the field is `_128`"]
92    #[inline(always)]
93    pub fn is_128(&self) -> bool {
94        *self == EWOFFSET_A::_128
95    }
96    #[doc = "Checks if the value of the field is `_256`"]
97    #[inline(always)]
98    pub fn is_256(&self) -> bool {
99        *self == EWOFFSET_A::_256
100    }
101    #[doc = "Checks if the value of the field is `_512`"]
102    #[inline(always)]
103    pub fn is_512(&self) -> bool {
104        *self == EWOFFSET_A::_512
105    }
106    #[doc = "Checks if the value of the field is `_1K`"]
107    #[inline(always)]
108    pub fn is_1k(&self) -> bool {
109        *self == EWOFFSET_A::_1K
110    }
111    #[doc = "Checks if the value of the field is `_2K`"]
112    #[inline(always)]
113    pub fn is_2k(&self) -> bool {
114        *self == EWOFFSET_A::_2K
115    }
116    #[doc = "Checks if the value of the field is `_4K`"]
117    #[inline(always)]
118    pub fn is_4k(&self) -> bool {
119        *self == EWOFFSET_A::_4K
120    }
121    #[doc = "Checks if the value of the field is `_8K`"]
122    #[inline(always)]
123    pub fn is_8k(&self) -> bool {
124        *self == EWOFFSET_A::_8K
125    }
126    #[doc = "Checks if the value of the field is `_16K`"]
127    #[inline(always)]
128    pub fn is_16k(&self) -> bool {
129        *self == EWOFFSET_A::_16K
130    }
131}
132#[doc = "Write proxy for field `EWOFFSET`"]
133pub struct EWOFFSET_W<'a> {
134    w: &'a mut W,
135}
136impl<'a> EWOFFSET_W<'a> {
137    #[doc = r"Writes `variant` to the field"]
138    #[inline(always)]
139    pub fn variant(self, variant: EWOFFSET_A) -> &'a mut W {
140        unsafe { self.bits(variant.into()) }
141    }
142    #[doc = "8 clock cycles"]
143    #[inline(always)]
144    pub fn _8(self) -> &'a mut W {
145        self.variant(EWOFFSET_A::_8)
146    }
147    #[doc = "16 clock cycles"]
148    #[inline(always)]
149    pub fn _16(self) -> &'a mut W {
150        self.variant(EWOFFSET_A::_16)
151    }
152    #[doc = "32 clock cycles"]
153    #[inline(always)]
154    pub fn _32(self) -> &'a mut W {
155        self.variant(EWOFFSET_A::_32)
156    }
157    #[doc = "64 clock cycles"]
158    #[inline(always)]
159    pub fn _64(self) -> &'a mut W {
160        self.variant(EWOFFSET_A::_64)
161    }
162    #[doc = "128 clock cycles"]
163    #[inline(always)]
164    pub fn _128(self) -> &'a mut W {
165        self.variant(EWOFFSET_A::_128)
166    }
167    #[doc = "256 clock cycles"]
168    #[inline(always)]
169    pub fn _256(self) -> &'a mut W {
170        self.variant(EWOFFSET_A::_256)
171    }
172    #[doc = "512 clock cycles"]
173    #[inline(always)]
174    pub fn _512(self) -> &'a mut W {
175        self.variant(EWOFFSET_A::_512)
176    }
177    #[doc = "1024 clock cycles"]
178    #[inline(always)]
179    pub fn _1k(self) -> &'a mut W {
180        self.variant(EWOFFSET_A::_1K)
181    }
182    #[doc = "2048 clock cycles"]
183    #[inline(always)]
184    pub fn _2k(self) -> &'a mut W {
185        self.variant(EWOFFSET_A::_2K)
186    }
187    #[doc = "4096 clock cycles"]
188    #[inline(always)]
189    pub fn _4k(self) -> &'a mut W {
190        self.variant(EWOFFSET_A::_4K)
191    }
192    #[doc = "8192 clock cycles"]
193    #[inline(always)]
194    pub fn _8k(self) -> &'a mut W {
195        self.variant(EWOFFSET_A::_8K)
196    }
197    #[doc = "16384 clock cycles"]
198    #[inline(always)]
199    pub fn _16k(self) -> &'a mut W {
200        self.variant(EWOFFSET_A::_16K)
201    }
202    #[doc = r"Writes raw bits to the field"]
203    #[inline(always)]
204    pub unsafe fn bits(self, value: u8) -> &'a mut W {
205        self.w.bits = (self.w.bits & !0x0f) | ((value as u8) & 0x0f);
206        self.w
207    }
208}
209impl R {
210    #[doc = "Bits 0:3 - Early Warning Interrupt Time Offset"]
211    #[inline(always)]
212    pub fn ewoffset(&self) -> EWOFFSET_R {
213        EWOFFSET_R::new((self.bits & 0x0f) as u8)
214    }
215}
216impl W {
217    #[doc = "Bits 0:3 - Early Warning Interrupt Time Offset"]
218    #[inline(always)]
219    pub fn ewoffset(&mut self) -> EWOFFSET_W {
220        EWOFFSET_W { w: self }
221    }
222}