efm32g230_pac/wdog/
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}
80impl From<CLKSEL_A> for u8 {
81    #[inline(always)]
82    fn from(variant: CLKSEL_A) -> Self {
83        variant as _
84    }
85}
86#[doc = "Field `CLKSEL` reader - Watchdog Clock Select"]
87pub type CLKSEL_R = crate::FieldReader<u8, CLKSEL_A>;
88impl CLKSEL_R {
89    #[doc = "Get enumerated values variant"]
90    #[inline(always)]
91    pub fn variant(&self) -> Option<CLKSEL_A> {
92        match self.bits {
93            0 => Some(CLKSEL_A::ULFRCO),
94            1 => Some(CLKSEL_A::LFRCO),
95            2 => Some(CLKSEL_A::LFXO),
96            _ => None,
97        }
98    }
99    #[doc = "Checks if the value of the field is `ULFRCO`"]
100    #[inline(always)]
101    pub fn is_ulfrco(&self) -> bool {
102        *self == CLKSEL_A::ULFRCO
103    }
104    #[doc = "Checks if the value of the field is `LFRCO`"]
105    #[inline(always)]
106    pub fn is_lfrco(&self) -> bool {
107        *self == CLKSEL_A::LFRCO
108    }
109    #[doc = "Checks if the value of the field is `LFXO`"]
110    #[inline(always)]
111    pub fn is_lfxo(&self) -> bool {
112        *self == CLKSEL_A::LFXO
113    }
114}
115#[doc = "Field `CLKSEL` writer - Watchdog Clock Select"]
116pub type CLKSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLKSEL_A, 2, 12>;
117impl<'a> CLKSEL_W<'a> {
118    #[doc = "ULFRCO"]
119    #[inline(always)]
120    pub fn ulfrco(self) -> &'a mut W {
121        self.variant(CLKSEL_A::ULFRCO)
122    }
123    #[doc = "LFRCO"]
124    #[inline(always)]
125    pub fn lfrco(self) -> &'a mut W {
126        self.variant(CLKSEL_A::LFRCO)
127    }
128    #[doc = "LFXO"]
129    #[inline(always)]
130    pub fn lfxo(self) -> &'a mut W {
131        self.variant(CLKSEL_A::LFXO)
132    }
133}
134impl R {
135    #[doc = "Bit 0 - Watchdog Timer Enable"]
136    #[inline(always)]
137    pub fn en(&self) -> EN_R {
138        EN_R::new((self.bits & 1) != 0)
139    }
140    #[doc = "Bit 1 - Debug Mode Run Enable"]
141    #[inline(always)]
142    pub fn debugrun(&self) -> DEBUGRUN_R {
143        DEBUGRUN_R::new(((self.bits >> 1) & 1) != 0)
144    }
145    #[doc = "Bit 2 - Energy Mode 2 Run Enable"]
146    #[inline(always)]
147    pub fn em2run(&self) -> EM2RUN_R {
148        EM2RUN_R::new(((self.bits >> 2) & 1) != 0)
149    }
150    #[doc = "Bit 3 - Energy Mode 3 Run Enable"]
151    #[inline(always)]
152    pub fn em3run(&self) -> EM3RUN_R {
153        EM3RUN_R::new(((self.bits >> 3) & 1) != 0)
154    }
155    #[doc = "Bit 4 - Configuration lock"]
156    #[inline(always)]
157    pub fn lock(&self) -> LOCK_R {
158        LOCK_R::new(((self.bits >> 4) & 1) != 0)
159    }
160    #[doc = "Bit 5 - Energy Mode 4 Block"]
161    #[inline(always)]
162    pub fn em4block(&self) -> EM4BLOCK_R {
163        EM4BLOCK_R::new(((self.bits >> 5) & 1) != 0)
164    }
165    #[doc = "Bit 6 - Software Oscillator Disable Block"]
166    #[inline(always)]
167    pub fn swoscblock(&self) -> SWOSCBLOCK_R {
168        SWOSCBLOCK_R::new(((self.bits >> 6) & 1) != 0)
169    }
170    #[doc = "Bits 8:11 - Watchdog Timeout Period Select"]
171    #[inline(always)]
172    pub fn persel(&self) -> PERSEL_R {
173        PERSEL_R::new(((self.bits >> 8) & 0x0f) as u8)
174    }
175    #[doc = "Bits 12:13 - Watchdog Clock Select"]
176    #[inline(always)]
177    pub fn clksel(&self) -> CLKSEL_R {
178        CLKSEL_R::new(((self.bits >> 12) & 3) as u8)
179    }
180}
181impl W {
182    #[doc = "Bit 0 - Watchdog Timer Enable"]
183    #[inline(always)]
184    pub fn en(&mut self) -> EN_W {
185        EN_W::new(self)
186    }
187    #[doc = "Bit 1 - Debug Mode Run Enable"]
188    #[inline(always)]
189    pub fn debugrun(&mut self) -> DEBUGRUN_W {
190        DEBUGRUN_W::new(self)
191    }
192    #[doc = "Bit 2 - Energy Mode 2 Run Enable"]
193    #[inline(always)]
194    pub fn em2run(&mut self) -> EM2RUN_W {
195        EM2RUN_W::new(self)
196    }
197    #[doc = "Bit 3 - Energy Mode 3 Run Enable"]
198    #[inline(always)]
199    pub fn em3run(&mut self) -> EM3RUN_W {
200        EM3RUN_W::new(self)
201    }
202    #[doc = "Bit 4 - Configuration lock"]
203    #[inline(always)]
204    pub fn lock(&mut self) -> LOCK_W {
205        LOCK_W::new(self)
206    }
207    #[doc = "Bit 5 - Energy Mode 4 Block"]
208    #[inline(always)]
209    pub fn em4block(&mut self) -> EM4BLOCK_W {
210        EM4BLOCK_W::new(self)
211    }
212    #[doc = "Bit 6 - Software Oscillator Disable Block"]
213    #[inline(always)]
214    pub fn swoscblock(&mut self) -> SWOSCBLOCK_W {
215        SWOSCBLOCK_W::new(self)
216    }
217    #[doc = "Bits 8:11 - Watchdog Timeout Period Select"]
218    #[inline(always)]
219    pub fn persel(&mut self) -> PERSEL_W {
220        PERSEL_W::new(self)
221    }
222    #[doc = "Bits 12:13 - Watchdog Clock Select"]
223    #[inline(always)]
224    pub fn clksel(&mut self) -> CLKSEL_W {
225        CLKSEL_W::new(self)
226    }
227    #[doc = "Writes raw bits to the register."]
228    #[inline(always)]
229    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
230        self.0.bits(bits);
231        self
232    }
233}
234#[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"]
235pub struct CTRL_SPEC;
236impl crate::RegisterSpec for CTRL_SPEC {
237    type Ux = u32;
238}
239#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
240impl crate::Readable for CTRL_SPEC {
241    type Reader = R;
242}
243#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
244impl crate::Writable for CTRL_SPEC {
245    type Writer = W;
246}
247#[doc = "`reset()` method sets CTRL to value 0x0f00"]
248impl crate::Resettable for CTRL_SPEC {
249    #[inline(always)]
250    fn reset_value() -> Self::Ux {
251        0x0f00
252    }
253}