d1_pac/timer/
wdog_mode.rs1#[doc = "Register `wdog_mode` reader"]
2pub type R = crate::R<WDOG_MODE_SPEC>;
3#[doc = "Register `wdog_mode` writer"]
4pub type W = crate::W<WDOG_MODE_SPEC>;
5#[doc = "Field `wdog_en` reader - Watchdog Enable"]
6pub type WDOG_EN_R = crate::BitReader<WDOG_EN_A>;
7#[doc = "Watchdog Enable\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum WDOG_EN_A {
10 #[doc = "0: `0`"]
11 NO_EFFECT = 0,
12 #[doc = "1: `1`"]
13 ENABLE = 1,
14}
15impl From<WDOG_EN_A> for bool {
16 #[inline(always)]
17 fn from(variant: WDOG_EN_A) -> Self {
18 variant as u8 != 0
19 }
20}
21impl WDOG_EN_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> WDOG_EN_A {
25 match self.bits {
26 false => WDOG_EN_A::NO_EFFECT,
27 true => WDOG_EN_A::ENABLE,
28 }
29 }
30 #[doc = "`0`"]
31 #[inline(always)]
32 pub fn is_no_effect(&self) -> bool {
33 *self == WDOG_EN_A::NO_EFFECT
34 }
35 #[doc = "`1`"]
36 #[inline(always)]
37 pub fn is_enable(&self) -> bool {
38 *self == WDOG_EN_A::ENABLE
39 }
40}
41#[doc = "Field `wdog_en` writer - Watchdog Enable"]
42pub type WDOG_EN_W<'a, REG> = crate::BitWriter<'a, REG, WDOG_EN_A>;
43impl<'a, REG> WDOG_EN_W<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "`0`"]
48 #[inline(always)]
49 pub fn no_effect(self) -> &'a mut crate::W<REG> {
50 self.variant(WDOG_EN_A::NO_EFFECT)
51 }
52 #[doc = "`1`"]
53 #[inline(always)]
54 pub fn enable(self) -> &'a mut crate::W<REG> {
55 self.variant(WDOG_EN_A::ENABLE)
56 }
57}
58#[doc = "Field `wdog_intv_value` reader - Watchdog Interval Value"]
59pub type WDOG_INTV_VALUE_R = crate::FieldReader<WDOG_INTV_VALUE_A>;
60#[doc = "Watchdog Interval Value\n\nValue on reset: 0"]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62#[repr(u8)]
63pub enum WDOG_INTV_VALUE_A {
64 #[doc = "0: `0`"]
65 C16000 = 0,
66 #[doc = "1: `1`"]
67 C32000 = 1,
68 #[doc = "2: `10`"]
69 C64000 = 2,
70 #[doc = "3: `11`"]
71 C96000 = 3,
72 #[doc = "4: `100`"]
73 C128000 = 4,
74 #[doc = "5: `101`"]
75 C160000 = 5,
76 #[doc = "6: `110`"]
77 C192000 = 6,
78 #[doc = "7: `111`"]
79 C256000 = 7,
80 #[doc = "8: `1000`"]
81 C320000 = 8,
82 #[doc = "9: `1001`"]
83 C384000 = 9,
84 #[doc = "10: `1010`"]
85 C448000 = 10,
86 #[doc = "11: `1011`"]
87 C512000 = 11,
88}
89impl From<WDOG_INTV_VALUE_A> for u8 {
90 #[inline(always)]
91 fn from(variant: WDOG_INTV_VALUE_A) -> Self {
92 variant as _
93 }
94}
95impl crate::FieldSpec for WDOG_INTV_VALUE_A {
96 type Ux = u8;
97}
98impl WDOG_INTV_VALUE_R {
99 #[doc = "Get enumerated values variant"]
100 #[inline(always)]
101 pub const fn variant(&self) -> Option<WDOG_INTV_VALUE_A> {
102 match self.bits {
103 0 => Some(WDOG_INTV_VALUE_A::C16000),
104 1 => Some(WDOG_INTV_VALUE_A::C32000),
105 2 => Some(WDOG_INTV_VALUE_A::C64000),
106 3 => Some(WDOG_INTV_VALUE_A::C96000),
107 4 => Some(WDOG_INTV_VALUE_A::C128000),
108 5 => Some(WDOG_INTV_VALUE_A::C160000),
109 6 => Some(WDOG_INTV_VALUE_A::C192000),
110 7 => Some(WDOG_INTV_VALUE_A::C256000),
111 8 => Some(WDOG_INTV_VALUE_A::C320000),
112 9 => Some(WDOG_INTV_VALUE_A::C384000),
113 10 => Some(WDOG_INTV_VALUE_A::C448000),
114 11 => Some(WDOG_INTV_VALUE_A::C512000),
115 _ => None,
116 }
117 }
118 #[doc = "`0`"]
119 #[inline(always)]
120 pub fn is_c16000(&self) -> bool {
121 *self == WDOG_INTV_VALUE_A::C16000
122 }
123 #[doc = "`1`"]
124 #[inline(always)]
125 pub fn is_c32000(&self) -> bool {
126 *self == WDOG_INTV_VALUE_A::C32000
127 }
128 #[doc = "`10`"]
129 #[inline(always)]
130 pub fn is_c64000(&self) -> bool {
131 *self == WDOG_INTV_VALUE_A::C64000
132 }
133 #[doc = "`11`"]
134 #[inline(always)]
135 pub fn is_c96000(&self) -> bool {
136 *self == WDOG_INTV_VALUE_A::C96000
137 }
138 #[doc = "`100`"]
139 #[inline(always)]
140 pub fn is_c128000(&self) -> bool {
141 *self == WDOG_INTV_VALUE_A::C128000
142 }
143 #[doc = "`101`"]
144 #[inline(always)]
145 pub fn is_c160000(&self) -> bool {
146 *self == WDOG_INTV_VALUE_A::C160000
147 }
148 #[doc = "`110`"]
149 #[inline(always)]
150 pub fn is_c192000(&self) -> bool {
151 *self == WDOG_INTV_VALUE_A::C192000
152 }
153 #[doc = "`111`"]
154 #[inline(always)]
155 pub fn is_c256000(&self) -> bool {
156 *self == WDOG_INTV_VALUE_A::C256000
157 }
158 #[doc = "`1000`"]
159 #[inline(always)]
160 pub fn is_c320000(&self) -> bool {
161 *self == WDOG_INTV_VALUE_A::C320000
162 }
163 #[doc = "`1001`"]
164 #[inline(always)]
165 pub fn is_c384000(&self) -> bool {
166 *self == WDOG_INTV_VALUE_A::C384000
167 }
168 #[doc = "`1010`"]
169 #[inline(always)]
170 pub fn is_c448000(&self) -> bool {
171 *self == WDOG_INTV_VALUE_A::C448000
172 }
173 #[doc = "`1011`"]
174 #[inline(always)]
175 pub fn is_c512000(&self) -> bool {
176 *self == WDOG_INTV_VALUE_A::C512000
177 }
178}
179#[doc = "Field `wdog_intv_value` writer - Watchdog Interval Value"]
180pub type WDOG_INTV_VALUE_W<'a, REG> = crate::FieldWriter<'a, REG, 4, WDOG_INTV_VALUE_A>;
181impl<'a, REG> WDOG_INTV_VALUE_W<'a, REG>
182where
183 REG: crate::Writable + crate::RegisterSpec,
184 REG::Ux: From<u8>,
185{
186 #[doc = "`0`"]
187 #[inline(always)]
188 pub fn c16000(self) -> &'a mut crate::W<REG> {
189 self.variant(WDOG_INTV_VALUE_A::C16000)
190 }
191 #[doc = "`1`"]
192 #[inline(always)]
193 pub fn c32000(self) -> &'a mut crate::W<REG> {
194 self.variant(WDOG_INTV_VALUE_A::C32000)
195 }
196 #[doc = "`10`"]
197 #[inline(always)]
198 pub fn c64000(self) -> &'a mut crate::W<REG> {
199 self.variant(WDOG_INTV_VALUE_A::C64000)
200 }
201 #[doc = "`11`"]
202 #[inline(always)]
203 pub fn c96000(self) -> &'a mut crate::W<REG> {
204 self.variant(WDOG_INTV_VALUE_A::C96000)
205 }
206 #[doc = "`100`"]
207 #[inline(always)]
208 pub fn c128000(self) -> &'a mut crate::W<REG> {
209 self.variant(WDOG_INTV_VALUE_A::C128000)
210 }
211 #[doc = "`101`"]
212 #[inline(always)]
213 pub fn c160000(self) -> &'a mut crate::W<REG> {
214 self.variant(WDOG_INTV_VALUE_A::C160000)
215 }
216 #[doc = "`110`"]
217 #[inline(always)]
218 pub fn c192000(self) -> &'a mut crate::W<REG> {
219 self.variant(WDOG_INTV_VALUE_A::C192000)
220 }
221 #[doc = "`111`"]
222 #[inline(always)]
223 pub fn c256000(self) -> &'a mut crate::W<REG> {
224 self.variant(WDOG_INTV_VALUE_A::C256000)
225 }
226 #[doc = "`1000`"]
227 #[inline(always)]
228 pub fn c320000(self) -> &'a mut crate::W<REG> {
229 self.variant(WDOG_INTV_VALUE_A::C320000)
230 }
231 #[doc = "`1001`"]
232 #[inline(always)]
233 pub fn c384000(self) -> &'a mut crate::W<REG> {
234 self.variant(WDOG_INTV_VALUE_A::C384000)
235 }
236 #[doc = "`1010`"]
237 #[inline(always)]
238 pub fn c448000(self) -> &'a mut crate::W<REG> {
239 self.variant(WDOG_INTV_VALUE_A::C448000)
240 }
241 #[doc = "`1011`"]
242 #[inline(always)]
243 pub fn c512000(self) -> &'a mut crate::W<REG> {
244 self.variant(WDOG_INTV_VALUE_A::C512000)
245 }
246}
247#[doc = "Field `key_field` writer - Key Field"]
248pub type KEY_FIELD_W<'a, REG> = crate::FieldWriter<'a, REG, 16, u16>;
249impl R {
250 #[doc = "Bit 0 - Watchdog Enable"]
251 #[inline(always)]
252 pub fn wdog_en(&self) -> WDOG_EN_R {
253 WDOG_EN_R::new((self.bits & 1) != 0)
254 }
255 #[doc = "Bits 4:7 - Watchdog Interval Value"]
256 #[inline(always)]
257 pub fn wdog_intv_value(&self) -> WDOG_INTV_VALUE_R {
258 WDOG_INTV_VALUE_R::new(((self.bits >> 4) & 0x0f) as u8)
259 }
260}
261impl W {
262 #[doc = "Bit 0 - Watchdog Enable"]
263 #[inline(always)]
264 #[must_use]
265 pub fn wdog_en(&mut self) -> WDOG_EN_W<WDOG_MODE_SPEC> {
266 WDOG_EN_W::new(self, 0)
267 }
268 #[doc = "Bits 4:7 - Watchdog Interval Value"]
269 #[inline(always)]
270 #[must_use]
271 pub fn wdog_intv_value(&mut self) -> WDOG_INTV_VALUE_W<WDOG_MODE_SPEC> {
272 WDOG_INTV_VALUE_W::new(self, 4)
273 }
274 #[doc = "Bits 16:31 - Key Field"]
275 #[inline(always)]
276 #[must_use]
277 pub fn key_field(&mut self) -> KEY_FIELD_W<WDOG_MODE_SPEC> {
278 KEY_FIELD_W::new(self, 16)
279 }
280 #[doc = r" Writes raw bits to the register."]
281 #[doc = r""]
282 #[doc = r" # Safety"]
283 #[doc = r""]
284 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
285 #[inline(always)]
286 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
287 self.bits = bits;
288 self
289 }
290}
291#[doc = "Watchdog Mode Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`wdog_mode::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`wdog_mode::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
292pub struct WDOG_MODE_SPEC;
293impl crate::RegisterSpec for WDOG_MODE_SPEC {
294 type Ux = u32;
295}
296#[doc = "`read()` method returns [`wdog_mode::R`](R) reader structure"]
297impl crate::Readable for WDOG_MODE_SPEC {}
298#[doc = "`write(|w| ..)` method takes [`wdog_mode::W`](W) writer structure"]
299impl crate::Writable for WDOG_MODE_SPEC {
300 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
301 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
302}
303#[doc = "`reset()` method sets wdog_mode to value 0"]
304impl crate::Resettable for WDOG_MODE_SPEC {
305 const RESET_VALUE: Self::Ux = 0;
306}