efm32gg11b110_pac/wdog1/
ctrl.rs

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 = "Field `EN` reader - Watchdog Timer Enable"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - Watchdog Timer Enable"]
40pub type EN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
41#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
42pub type DEBUGRUN_R = crate::BitReader<bool>;
43#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
44pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 1>;
45#[doc = "Field `EM2RUN` reader - Energy Mode 2 Run Enable"]
46pub type EM2RUN_R = crate::BitReader<bool>;
47#[doc = "Field `EM2RUN` writer - Energy Mode 2 Run Enable"]
48pub type EM2RUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 2>;
49#[doc = "Field `EM3RUN` reader - Energy Mode 3 Run Enable"]
50pub type EM3RUN_R = crate::BitReader<bool>;
51#[doc = "Field `EM3RUN` writer - Energy Mode 3 Run Enable"]
52pub type EM3RUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 3>;
53#[doc = "Field `LOCK` reader - Configuration Lock"]
54pub type LOCK_R = crate::BitReader<bool>;
55#[doc = "Field `LOCK` writer - Configuration Lock"]
56pub type LOCK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 4>;
57#[doc = "Field `EM4BLOCK` reader - Energy Mode 4 Block"]
58pub type EM4BLOCK_R = crate::BitReader<bool>;
59#[doc = "Field `EM4BLOCK` writer - Energy Mode 4 Block"]
60pub type EM4BLOCK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 5>;
61#[doc = "Field `SWOSCBLOCK` reader - Software Oscillator Disable Block"]
62pub type SWOSCBLOCK_R = crate::BitReader<bool>;
63#[doc = "Field `SWOSCBLOCK` writer - Software Oscillator Disable Block"]
64pub type SWOSCBLOCK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 6>;
65#[doc = "Field `PERSEL` reader - Watchdog Timeout Period Select"]
66pub type PERSEL_R = crate::FieldReader<u8, u8>;
67#[doc = "Field `PERSEL` writer - Watchdog Timeout Period Select"]
68pub type PERSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 4, 8>;
69#[doc = "Watchdog Clock Select\n\nValue on reset: 0"]
70#[derive(Clone, Copy, Debug, PartialEq)]
71#[repr(u8)]
72pub enum CLKSEL_A {
73    #[doc = "0: ULFRCO"]
74    ULFRCO = 0,
75    #[doc = "1: LFRCO"]
76    LFRCO = 1,
77    #[doc = "2: LFXO"]
78    LFXO = 2,
79    #[doc = "3: HFCORECLK"]
80    HFCORECLK = 3,
81}
82impl From<CLKSEL_A> for u8 {
83    #[inline(always)]
84    fn from(variant: CLKSEL_A) -> Self {
85        variant as _
86    }
87}
88#[doc = "Field `CLKSEL` reader - Watchdog Clock Select"]
89pub type CLKSEL_R = crate::FieldReader<u8, CLKSEL_A>;
90impl CLKSEL_R {
91    #[doc = "Get enumerated values variant"]
92    #[inline(always)]
93    pub fn variant(&self) -> CLKSEL_A {
94        match self.bits {
95            0 => CLKSEL_A::ULFRCO,
96            1 => CLKSEL_A::LFRCO,
97            2 => CLKSEL_A::LFXO,
98            3 => CLKSEL_A::HFCORECLK,
99            _ => unreachable!(),
100        }
101    }
102    #[doc = "Checks if the value of the field is `ULFRCO`"]
103    #[inline(always)]
104    pub fn is_ulfrco(&self) -> bool {
105        *self == CLKSEL_A::ULFRCO
106    }
107    #[doc = "Checks if the value of the field is `LFRCO`"]
108    #[inline(always)]
109    pub fn is_lfrco(&self) -> bool {
110        *self == CLKSEL_A::LFRCO
111    }
112    #[doc = "Checks if the value of the field is `LFXO`"]
113    #[inline(always)]
114    pub fn is_lfxo(&self) -> bool {
115        *self == CLKSEL_A::LFXO
116    }
117    #[doc = "Checks if the value of the field is `HFCORECLK`"]
118    #[inline(always)]
119    pub fn is_hfcoreclk(&self) -> bool {
120        *self == CLKSEL_A::HFCORECLK
121    }
122}
123#[doc = "Field `CLKSEL` writer - Watchdog Clock Select"]
124pub type CLKSEL_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, CLKSEL_A, 2, 12>;
125impl<'a> CLKSEL_W<'a> {
126    #[doc = "ULFRCO"]
127    #[inline(always)]
128    pub fn ulfrco(self) -> &'a mut W {
129        self.variant(CLKSEL_A::ULFRCO)
130    }
131    #[doc = "LFRCO"]
132    #[inline(always)]
133    pub fn lfrco(self) -> &'a mut W {
134        self.variant(CLKSEL_A::LFRCO)
135    }
136    #[doc = "LFXO"]
137    #[inline(always)]
138    pub fn lfxo(self) -> &'a mut W {
139        self.variant(CLKSEL_A::LFXO)
140    }
141    #[doc = "HFCORECLK"]
142    #[inline(always)]
143    pub fn hfcoreclk(self) -> &'a mut W {
144        self.variant(CLKSEL_A::HFCORECLK)
145    }
146}
147#[doc = "Field `WARNSEL` reader - Watchdog Timeout Period Select"]
148pub type WARNSEL_R = crate::FieldReader<u8, u8>;
149#[doc = "Field `WARNSEL` writer - Watchdog Timeout Period Select"]
150pub type WARNSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 2, 16>;
151#[doc = "Field `WINSEL` reader - Watchdog Illegal Window Select"]
152pub type WINSEL_R = crate::FieldReader<u8, u8>;
153#[doc = "Field `WINSEL` writer - Watchdog Illegal Window Select"]
154pub type WINSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 3, 24>;
155#[doc = "Field `CLRSRC` reader - Watchdog Clear Source"]
156pub type CLRSRC_R = crate::BitReader<bool>;
157#[doc = "Field `CLRSRC` writer - Watchdog Clear Source"]
158pub type CLRSRC_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 30>;
159#[doc = "Field `WDOGRSTDIS` reader - Watchdog Reset Disable"]
160pub type WDOGRSTDIS_R = crate::BitReader<bool>;
161#[doc = "Field `WDOGRSTDIS` writer - Watchdog Reset Disable"]
162pub type WDOGRSTDIS_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 31>;
163impl R {
164    #[doc = "Bit 0 - Watchdog Timer Enable"]
165    #[inline(always)]
166    pub fn en(&self) -> EN_R {
167        EN_R::new((self.bits & 1) != 0)
168    }
169    #[doc = "Bit 1 - Debug Mode Run Enable"]
170    #[inline(always)]
171    pub fn debugrun(&self) -> DEBUGRUN_R {
172        DEBUGRUN_R::new(((self.bits >> 1) & 1) != 0)
173    }
174    #[doc = "Bit 2 - Energy Mode 2 Run Enable"]
175    #[inline(always)]
176    pub fn em2run(&self) -> EM2RUN_R {
177        EM2RUN_R::new(((self.bits >> 2) & 1) != 0)
178    }
179    #[doc = "Bit 3 - Energy Mode 3 Run Enable"]
180    #[inline(always)]
181    pub fn em3run(&self) -> EM3RUN_R {
182        EM3RUN_R::new(((self.bits >> 3) & 1) != 0)
183    }
184    #[doc = "Bit 4 - Configuration Lock"]
185    #[inline(always)]
186    pub fn lock(&self) -> LOCK_R {
187        LOCK_R::new(((self.bits >> 4) & 1) != 0)
188    }
189    #[doc = "Bit 5 - Energy Mode 4 Block"]
190    #[inline(always)]
191    pub fn em4block(&self) -> EM4BLOCK_R {
192        EM4BLOCK_R::new(((self.bits >> 5) & 1) != 0)
193    }
194    #[doc = "Bit 6 - Software Oscillator Disable Block"]
195    #[inline(always)]
196    pub fn swoscblock(&self) -> SWOSCBLOCK_R {
197        SWOSCBLOCK_R::new(((self.bits >> 6) & 1) != 0)
198    }
199    #[doc = "Bits 8:11 - Watchdog Timeout Period Select"]
200    #[inline(always)]
201    pub fn persel(&self) -> PERSEL_R {
202        PERSEL_R::new(((self.bits >> 8) & 0x0f) as u8)
203    }
204    #[doc = "Bits 12:13 - Watchdog Clock Select"]
205    #[inline(always)]
206    pub fn clksel(&self) -> CLKSEL_R {
207        CLKSEL_R::new(((self.bits >> 12) & 3) as u8)
208    }
209    #[doc = "Bits 16:17 - Watchdog Timeout Period Select"]
210    #[inline(always)]
211    pub fn warnsel(&self) -> WARNSEL_R {
212        WARNSEL_R::new(((self.bits >> 16) & 3) as u8)
213    }
214    #[doc = "Bits 24:26 - Watchdog Illegal Window Select"]
215    #[inline(always)]
216    pub fn winsel(&self) -> WINSEL_R {
217        WINSEL_R::new(((self.bits >> 24) & 7) as u8)
218    }
219    #[doc = "Bit 30 - Watchdog Clear Source"]
220    #[inline(always)]
221    pub fn clrsrc(&self) -> CLRSRC_R {
222        CLRSRC_R::new(((self.bits >> 30) & 1) != 0)
223    }
224    #[doc = "Bit 31 - Watchdog Reset Disable"]
225    #[inline(always)]
226    pub fn wdogrstdis(&self) -> WDOGRSTDIS_R {
227        WDOGRSTDIS_R::new(((self.bits >> 31) & 1) != 0)
228    }
229}
230impl W {
231    #[doc = "Bit 0 - Watchdog Timer Enable"]
232    #[inline(always)]
233    pub fn en(&mut self) -> EN_W {
234        EN_W::new(self)
235    }
236    #[doc = "Bit 1 - Debug Mode Run Enable"]
237    #[inline(always)]
238    pub fn debugrun(&mut self) -> DEBUGRUN_W {
239        DEBUGRUN_W::new(self)
240    }
241    #[doc = "Bit 2 - Energy Mode 2 Run Enable"]
242    #[inline(always)]
243    pub fn em2run(&mut self) -> EM2RUN_W {
244        EM2RUN_W::new(self)
245    }
246    #[doc = "Bit 3 - Energy Mode 3 Run Enable"]
247    #[inline(always)]
248    pub fn em3run(&mut self) -> EM3RUN_W {
249        EM3RUN_W::new(self)
250    }
251    #[doc = "Bit 4 - Configuration Lock"]
252    #[inline(always)]
253    pub fn lock(&mut self) -> LOCK_W {
254        LOCK_W::new(self)
255    }
256    #[doc = "Bit 5 - Energy Mode 4 Block"]
257    #[inline(always)]
258    pub fn em4block(&mut self) -> EM4BLOCK_W {
259        EM4BLOCK_W::new(self)
260    }
261    #[doc = "Bit 6 - Software Oscillator Disable Block"]
262    #[inline(always)]
263    pub fn swoscblock(&mut self) -> SWOSCBLOCK_W {
264        SWOSCBLOCK_W::new(self)
265    }
266    #[doc = "Bits 8:11 - Watchdog Timeout Period Select"]
267    #[inline(always)]
268    pub fn persel(&mut self) -> PERSEL_W {
269        PERSEL_W::new(self)
270    }
271    #[doc = "Bits 12:13 - Watchdog Clock Select"]
272    #[inline(always)]
273    pub fn clksel(&mut self) -> CLKSEL_W {
274        CLKSEL_W::new(self)
275    }
276    #[doc = "Bits 16:17 - Watchdog Timeout Period Select"]
277    #[inline(always)]
278    pub fn warnsel(&mut self) -> WARNSEL_W {
279        WARNSEL_W::new(self)
280    }
281    #[doc = "Bits 24:26 - Watchdog Illegal Window Select"]
282    #[inline(always)]
283    pub fn winsel(&mut self) -> WINSEL_W {
284        WINSEL_W::new(self)
285    }
286    #[doc = "Bit 30 - Watchdog Clear Source"]
287    #[inline(always)]
288    pub fn clrsrc(&mut self) -> CLRSRC_W {
289        CLRSRC_W::new(self)
290    }
291    #[doc = "Bit 31 - Watchdog Reset Disable"]
292    #[inline(always)]
293    pub fn wdogrstdis(&mut self) -> WDOGRSTDIS_W {
294        WDOGRSTDIS_W::new(self)
295    }
296    #[doc = "Writes raw bits to the register."]
297    #[inline(always)]
298    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
299        self.0.bits(bits);
300        self
301    }
302}
303#[doc = "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"]
304pub struct CTRL_SPEC;
305impl crate::RegisterSpec for CTRL_SPEC {
306    type Ux = u32;
307}
308#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
309impl crate::Readable for CTRL_SPEC {
310    type Reader = R;
311}
312#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
313impl crate::Writable for CTRL_SPEC {
314    type Writer = W;
315}
316#[doc = "`reset()` method sets CTRL to value 0x0f00"]
317impl crate::Resettable for CTRL_SPEC {
318    #[inline(always)]
319    fn reset_value() -> Self::Ux {
320        0x0f00
321    }
322}