efm32jg12b_pac/efm32jg12b500/emu/
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 `EM2BLOCK` reader - Energy Mode 2 Block"]
38pub type EM2BLOCK_R = crate::BitReader<bool>;
39#[doc = "Field `EM2BLOCK` writer - Energy Mode 2 Block"]
40pub type EM2BLOCK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
41#[doc = "Field `EM2BODDIS` reader - Disable BOD in EM2"]
42pub type EM2BODDIS_R = crate::BitReader<bool>;
43#[doc = "Field `EM2BODDIS` writer - Disable BOD in EM2"]
44pub type EM2BODDIS_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
45#[doc = "Field `EM01LD` reader - Reserved for internal use. Do not change."]
46pub type EM01LD_R = crate::BitReader<bool>;
47#[doc = "Field `EM01LD` writer - Reserved for internal use. Do not change."]
48pub type EM01LD_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
49#[doc = "Field `EM23VSCALEAUTOWSEN` reader - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
50pub type EM23VSCALEAUTOWSEN_R = crate::BitReader<bool>;
51#[doc = "Field `EM23VSCALEAUTOWSEN` writer - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
52pub type EM23VSCALEAUTOWSEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
53#[doc = "Field `EM23VSCALE` reader - EM23 Voltage Scale"]
54pub type EM23VSCALE_R = crate::FieldReader<u8, EM23VSCALE_A>;
55#[doc = "EM23 Voltage Scale\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum EM23VSCALE_A {
59    #[doc = "0: Voltage Scale Level 2"]
60    VSCALE2 = 0,
61    #[doc = "2: Voltage Scale Level 0"]
62    VSCALE0 = 2,
63    #[doc = "3: RESV"]
64    RESV = 3,
65}
66impl From<EM23VSCALE_A> for u8 {
67    #[inline(always)]
68    fn from(variant: EM23VSCALE_A) -> Self {
69        variant as _
70    }
71}
72impl EM23VSCALE_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<EM23VSCALE_A> {
76        match self.bits {
77            0 => Some(EM23VSCALE_A::VSCALE2),
78            2 => Some(EM23VSCALE_A::VSCALE0),
79            3 => Some(EM23VSCALE_A::RESV),
80            _ => None,
81        }
82    }
83    #[doc = "Checks if the value of the field is `VSCALE2`"]
84    #[inline(always)]
85    pub fn is_vscale2(&self) -> bool {
86        *self == EM23VSCALE_A::VSCALE2
87    }
88    #[doc = "Checks if the value of the field is `VSCALE0`"]
89    #[inline(always)]
90    pub fn is_vscale0(&self) -> bool {
91        *self == EM23VSCALE_A::VSCALE0
92    }
93    #[doc = "Checks if the value of the field is `RESV`"]
94    #[inline(always)]
95    pub fn is_resv(&self) -> bool {
96        *self == EM23VSCALE_A::RESV
97    }
98}
99#[doc = "Field `EM23VSCALE` writer - EM23 Voltage Scale"]
100pub type EM23VSCALE_W<'a, const O: u8> =
101    crate::FieldWriter<'a, u32, CTRL_SPEC, u8, EM23VSCALE_A, 2, O>;
102impl<'a, const O: u8> EM23VSCALE_W<'a, O> {
103    #[doc = "Voltage Scale Level 2"]
104    #[inline(always)]
105    pub fn vscale2(self) -> &'a mut W {
106        self.variant(EM23VSCALE_A::VSCALE2)
107    }
108    #[doc = "Voltage Scale Level 0"]
109    #[inline(always)]
110    pub fn vscale0(self) -> &'a mut W {
111        self.variant(EM23VSCALE_A::VSCALE0)
112    }
113    #[doc = "RESV"]
114    #[inline(always)]
115    pub fn resv(self) -> &'a mut W {
116        self.variant(EM23VSCALE_A::RESV)
117    }
118}
119#[doc = "Field `EM4HVSCALE` reader - EM4H Voltage Scale"]
120pub type EM4HVSCALE_R = crate::FieldReader<u8, EM4HVSCALE_A>;
121#[doc = "EM4H Voltage Scale\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123#[repr(u8)]
124pub enum EM4HVSCALE_A {
125    #[doc = "0: Voltage Scale Level 2"]
126    VSCALE2 = 0,
127    #[doc = "2: Voltage Scale Level 0"]
128    VSCALE0 = 2,
129    #[doc = "3: RESV"]
130    RESV = 3,
131}
132impl From<EM4HVSCALE_A> for u8 {
133    #[inline(always)]
134    fn from(variant: EM4HVSCALE_A) -> Self {
135        variant as _
136    }
137}
138impl EM4HVSCALE_R {
139    #[doc = "Get enumerated values variant"]
140    #[inline(always)]
141    pub fn variant(&self) -> Option<EM4HVSCALE_A> {
142        match self.bits {
143            0 => Some(EM4HVSCALE_A::VSCALE2),
144            2 => Some(EM4HVSCALE_A::VSCALE0),
145            3 => Some(EM4HVSCALE_A::RESV),
146            _ => None,
147        }
148    }
149    #[doc = "Checks if the value of the field is `VSCALE2`"]
150    #[inline(always)]
151    pub fn is_vscale2(&self) -> bool {
152        *self == EM4HVSCALE_A::VSCALE2
153    }
154    #[doc = "Checks if the value of the field is `VSCALE0`"]
155    #[inline(always)]
156    pub fn is_vscale0(&self) -> bool {
157        *self == EM4HVSCALE_A::VSCALE0
158    }
159    #[doc = "Checks if the value of the field is `RESV`"]
160    #[inline(always)]
161    pub fn is_resv(&self) -> bool {
162        *self == EM4HVSCALE_A::RESV
163    }
164}
165#[doc = "Field `EM4HVSCALE` writer - EM4H Voltage Scale"]
166pub type EM4HVSCALE_W<'a, const O: u8> =
167    crate::FieldWriter<'a, u32, CTRL_SPEC, u8, EM4HVSCALE_A, 2, O>;
168impl<'a, const O: u8> EM4HVSCALE_W<'a, O> {
169    #[doc = "Voltage Scale Level 2"]
170    #[inline(always)]
171    pub fn vscale2(self) -> &'a mut W {
172        self.variant(EM4HVSCALE_A::VSCALE2)
173    }
174    #[doc = "Voltage Scale Level 0"]
175    #[inline(always)]
176    pub fn vscale0(self) -> &'a mut W {
177        self.variant(EM4HVSCALE_A::VSCALE0)
178    }
179    #[doc = "RESV"]
180    #[inline(always)]
181    pub fn resv(self) -> &'a mut W {
182        self.variant(EM4HVSCALE_A::RESV)
183    }
184}
185impl R {
186    #[doc = "Bit 1 - Energy Mode 2 Block"]
187    #[inline(always)]
188    pub fn em2block(&self) -> EM2BLOCK_R {
189        EM2BLOCK_R::new(((self.bits >> 1) & 1) != 0)
190    }
191    #[doc = "Bit 2 - Disable BOD in EM2"]
192    #[inline(always)]
193    pub fn em2boddis(&self) -> EM2BODDIS_R {
194        EM2BODDIS_R::new(((self.bits >> 2) & 1) != 0)
195    }
196    #[doc = "Bit 3 - Reserved for internal use. Do not change."]
197    #[inline(always)]
198    pub fn em01ld(&self) -> EM01LD_R {
199        EM01LD_R::new(((self.bits >> 3) & 1) != 0)
200    }
201    #[doc = "Bit 4 - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
202    #[inline(always)]
203    pub fn em23vscaleautowsen(&self) -> EM23VSCALEAUTOWSEN_R {
204        EM23VSCALEAUTOWSEN_R::new(((self.bits >> 4) & 1) != 0)
205    }
206    #[doc = "Bits 8:9 - EM23 Voltage Scale"]
207    #[inline(always)]
208    pub fn em23vscale(&self) -> EM23VSCALE_R {
209        EM23VSCALE_R::new(((self.bits >> 8) & 3) as u8)
210    }
211    #[doc = "Bits 16:17 - EM4H Voltage Scale"]
212    #[inline(always)]
213    pub fn em4hvscale(&self) -> EM4HVSCALE_R {
214        EM4HVSCALE_R::new(((self.bits >> 16) & 3) as u8)
215    }
216}
217impl W {
218    #[doc = "Bit 1 - Energy Mode 2 Block"]
219    #[inline(always)]
220    #[must_use]
221    pub fn em2block(&mut self) -> EM2BLOCK_W<1> {
222        EM2BLOCK_W::new(self)
223    }
224    #[doc = "Bit 2 - Disable BOD in EM2"]
225    #[inline(always)]
226    #[must_use]
227    pub fn em2boddis(&mut self) -> EM2BODDIS_W<2> {
228        EM2BODDIS_W::new(self)
229    }
230    #[doc = "Bit 3 - Reserved for internal use. Do not change."]
231    #[inline(always)]
232    #[must_use]
233    pub fn em01ld(&mut self) -> EM01LD_W<3> {
234        EM01LD_W::new(self)
235    }
236    #[doc = "Bit 4 - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
237    #[inline(always)]
238    #[must_use]
239    pub fn em23vscaleautowsen(&mut self) -> EM23VSCALEAUTOWSEN_W<4> {
240        EM23VSCALEAUTOWSEN_W::new(self)
241    }
242    #[doc = "Bits 8:9 - EM23 Voltage Scale"]
243    #[inline(always)]
244    #[must_use]
245    pub fn em23vscale(&mut self) -> EM23VSCALE_W<8> {
246        EM23VSCALE_W::new(self)
247    }
248    #[doc = "Bits 16:17 - EM4H Voltage Scale"]
249    #[inline(always)]
250    #[must_use]
251    pub fn em4hvscale(&mut self) -> EM4HVSCALE_W<16> {
252        EM4HVSCALE_W::new(self)
253    }
254    #[doc = "Writes raw bits to the register."]
255    #[inline(always)]
256    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
257        self.0.bits(bits);
258        self
259    }
260}
261#[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"]
262pub struct CTRL_SPEC;
263impl crate::RegisterSpec for CTRL_SPEC {
264    type Ux = u32;
265}
266#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
267impl crate::Readable for CTRL_SPEC {
268    type Reader = R;
269}
270#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
271impl crate::Writable for CTRL_SPEC {
272    type Writer = W;
273    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
274    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
275}
276#[doc = "`reset()` method sets CTRL to value 0"]
277impl crate::Resettable for CTRL_SPEC {
278    const RESET_VALUE: Self::Ux = 0;
279}