efm32gg_pac/efm32gg230/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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 4, O>;
69#[doc = "Field `CLKSEL` reader - Watchdog Clock Select"]
70pub type CLKSEL_R = crate::FieldReader<u8, CLKSEL_A>;
71#[doc = "Watchdog Clock Select\n\nValue on reset: 0"]
72#[derive(Clone, Copy, Debug, PartialEq, Eq)]
73#[repr(u8)]
74pub enum CLKSEL_A {
75    #[doc = "0: ULFRCO"]
76    ULFRCO = 0,
77    #[doc = "1: LFRCO"]
78    LFRCO = 1,
79    #[doc = "2: LFXO"]
80    LFXO = 2,
81}
82impl From<CLKSEL_A> for u8 {
83    #[inline(always)]
84    fn from(variant: CLKSEL_A) -> Self {
85        variant as _
86    }
87}
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, const O: u8> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, CLKSEL_A, 2, O>;
117impl<'a, const O: u8> CLKSEL_W<'a, O> {
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    #[must_use]
185    pub fn en(&mut self) -> EN_W<0> {
186        EN_W::new(self)
187    }
188    #[doc = "Bit 1 - Debug Mode Run Enable"]
189    #[inline(always)]
190    #[must_use]
191    pub fn debugrun(&mut self) -> DEBUGRUN_W<1> {
192        DEBUGRUN_W::new(self)
193    }
194    #[doc = "Bit 2 - Energy Mode 2 Run Enable"]
195    #[inline(always)]
196    #[must_use]
197    pub fn em2run(&mut self) -> EM2RUN_W<2> {
198        EM2RUN_W::new(self)
199    }
200    #[doc = "Bit 3 - Energy Mode 3 Run Enable"]
201    #[inline(always)]
202    #[must_use]
203    pub fn em3run(&mut self) -> EM3RUN_W<3> {
204        EM3RUN_W::new(self)
205    }
206    #[doc = "Bit 4 - Configuration lock"]
207    #[inline(always)]
208    #[must_use]
209    pub fn lock(&mut self) -> LOCK_W<4> {
210        LOCK_W::new(self)
211    }
212    #[doc = "Bit 5 - Energy Mode 4 Block"]
213    #[inline(always)]
214    #[must_use]
215    pub fn em4block(&mut self) -> EM4BLOCK_W<5> {
216        EM4BLOCK_W::new(self)
217    }
218    #[doc = "Bit 6 - Software Oscillator Disable Block"]
219    #[inline(always)]
220    #[must_use]
221    pub fn swoscblock(&mut self) -> SWOSCBLOCK_W<6> {
222        SWOSCBLOCK_W::new(self)
223    }
224    #[doc = "Bits 8:11 - Watchdog Timeout Period Select"]
225    #[inline(always)]
226    #[must_use]
227    pub fn persel(&mut self) -> PERSEL_W<8> {
228        PERSEL_W::new(self)
229    }
230    #[doc = "Bits 12:13 - Watchdog Clock Select"]
231    #[inline(always)]
232    #[must_use]
233    pub fn clksel(&mut self) -> CLKSEL_W<12> {
234        CLKSEL_W::new(self)
235    }
236    #[doc = "Writes raw bits to the register."]
237    #[inline(always)]
238    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
239        self.0.bits(bits);
240        self
241    }
242}
243#[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"]
244pub struct CTRL_SPEC;
245impl crate::RegisterSpec for CTRL_SPEC {
246    type Ux = u32;
247}
248#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
249impl crate::Readable for CTRL_SPEC {
250    type Reader = R;
251}
252#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
253impl crate::Writable for CTRL_SPEC {
254    type Writer = W;
255    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
256    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
257}
258#[doc = "`reset()` method sets CTRL to value 0x0f00"]
259impl crate::Resettable for CTRL_SPEC {
260    const RESET_VALUE: Self::Ux = 0x0f00;
261}