efm32pg12_pac/emu/
ctrl.rs

1#[doc = "Reader of register CTRL"]
2pub type R = crate::R<u32, super::CTRL>;
3#[doc = "Writer for register CTRL"]
4pub type W = crate::W<u32, super::CTRL>;
5#[doc = "Register CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `EM2BLOCK`"]
14pub type EM2BLOCK_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `EM2BLOCK`"]
16pub struct EM2BLOCK_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> EM2BLOCK_W<'a> {
20    #[doc = r"Sets the field bit"]
21    #[inline(always)]
22    pub fn set_bit(self) -> &'a mut W {
23        self.bit(true)
24    }
25    #[doc = r"Clears the field bit"]
26    #[inline(always)]
27    pub fn clear_bit(self) -> &'a mut W {
28        self.bit(false)
29    }
30    #[doc = r"Writes raw bits to the field"]
31    #[inline(always)]
32    pub fn bit(self, value: bool) -> &'a mut W {
33        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
34        self.w
35    }
36}
37#[doc = "Reader of field `EM2BODDIS`"]
38pub type EM2BODDIS_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `EM2BODDIS`"]
40pub struct EM2BODDIS_W<'a> {
41    w: &'a mut W,
42}
43impl<'a> EM2BODDIS_W<'a> {
44    #[doc = r"Sets the field bit"]
45    #[inline(always)]
46    pub fn set_bit(self) -> &'a mut W {
47        self.bit(true)
48    }
49    #[doc = r"Clears the field bit"]
50    #[inline(always)]
51    pub fn clear_bit(self) -> &'a mut W {
52        self.bit(false)
53    }
54    #[doc = r"Writes raw bits to the field"]
55    #[inline(always)]
56    pub fn bit(self, value: bool) -> &'a mut W {
57        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
58        self.w
59    }
60}
61#[doc = "Reader of field `EM01LD`"]
62pub type EM01LD_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `EM01LD`"]
64pub struct EM01LD_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> EM01LD_W<'a> {
68    #[doc = r"Sets the field bit"]
69    #[inline(always)]
70    pub fn set_bit(self) -> &'a mut W {
71        self.bit(true)
72    }
73    #[doc = r"Clears the field bit"]
74    #[inline(always)]
75    pub fn clear_bit(self) -> &'a mut W {
76        self.bit(false)
77    }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
82        self.w
83    }
84}
85#[doc = "Reader of field `EM23VSCALEAUTOWSEN`"]
86pub type EM23VSCALEAUTOWSEN_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `EM23VSCALEAUTOWSEN`"]
88pub struct EM23VSCALEAUTOWSEN_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> EM23VSCALEAUTOWSEN_W<'a> {
92    #[doc = r"Sets the field bit"]
93    #[inline(always)]
94    pub fn set_bit(self) -> &'a mut W {
95        self.bit(true)
96    }
97    #[doc = r"Clears the field bit"]
98    #[inline(always)]
99    pub fn clear_bit(self) -> &'a mut W {
100        self.bit(false)
101    }
102    #[doc = r"Writes raw bits to the field"]
103    #[inline(always)]
104    pub fn bit(self, value: bool) -> &'a mut W {
105        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
106        self.w
107    }
108}
109#[doc = "EM23 Voltage Scale\n\nValue on reset: 0"]
110#[derive(Clone, Copy, Debug, PartialEq)]
111#[repr(u8)]
112pub enum EM23VSCALE_A {
113    #[doc = "0: Voltage Scale Level 2"]
114    VSCALE2 = 0,
115    #[doc = "2: Voltage Scale Level 0"]
116    VSCALE0 = 2,
117    #[doc = "3: RESV"]
118    RESV = 3,
119}
120impl From<EM23VSCALE_A> for u8 {
121    #[inline(always)]
122    fn from(variant: EM23VSCALE_A) -> Self {
123        variant as _
124    }
125}
126#[doc = "Reader of field `EM23VSCALE`"]
127pub type EM23VSCALE_R = crate::R<u8, EM23VSCALE_A>;
128impl EM23VSCALE_R {
129    #[doc = r"Get enumerated values variant"]
130    #[inline(always)]
131    pub fn variant(&self) -> crate::Variant<u8, EM23VSCALE_A> {
132        use crate::Variant::*;
133        match self.bits {
134            0 => Val(EM23VSCALE_A::VSCALE2),
135            2 => Val(EM23VSCALE_A::VSCALE0),
136            3 => Val(EM23VSCALE_A::RESV),
137            i => Res(i),
138        }
139    }
140    #[doc = "Checks if the value of the field is `VSCALE2`"]
141    #[inline(always)]
142    pub fn is_vscale2(&self) -> bool {
143        *self == EM23VSCALE_A::VSCALE2
144    }
145    #[doc = "Checks if the value of the field is `VSCALE0`"]
146    #[inline(always)]
147    pub fn is_vscale0(&self) -> bool {
148        *self == EM23VSCALE_A::VSCALE0
149    }
150    #[doc = "Checks if the value of the field is `RESV`"]
151    #[inline(always)]
152    pub fn is_resv(&self) -> bool {
153        *self == EM23VSCALE_A::RESV
154    }
155}
156#[doc = "Write proxy for field `EM23VSCALE`"]
157pub struct EM23VSCALE_W<'a> {
158    w: &'a mut W,
159}
160impl<'a> EM23VSCALE_W<'a> {
161    #[doc = r"Writes `variant` to the field"]
162    #[inline(always)]
163    pub fn variant(self, variant: EM23VSCALE_A) -> &'a mut W {
164        unsafe { self.bits(variant.into()) }
165    }
166    #[doc = "Voltage Scale Level 2"]
167    #[inline(always)]
168    pub fn vscale2(self) -> &'a mut W {
169        self.variant(EM23VSCALE_A::VSCALE2)
170    }
171    #[doc = "Voltage Scale Level 0"]
172    #[inline(always)]
173    pub fn vscale0(self) -> &'a mut W {
174        self.variant(EM23VSCALE_A::VSCALE0)
175    }
176    #[doc = "RESV"]
177    #[inline(always)]
178    pub fn resv(self) -> &'a mut W {
179        self.variant(EM23VSCALE_A::RESV)
180    }
181    #[doc = r"Writes raw bits to the field"]
182    #[inline(always)]
183    pub unsafe fn bits(self, value: u8) -> &'a mut W {
184        self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
185        self.w
186    }
187}
188#[doc = "EM4H Voltage Scale\n\nValue on reset: 0"]
189#[derive(Clone, Copy, Debug, PartialEq)]
190#[repr(u8)]
191pub enum EM4HVSCALE_A {
192    #[doc = "0: Voltage Scale Level 2"]
193    VSCALE2 = 0,
194    #[doc = "2: Voltage Scale Level 0"]
195    VSCALE0 = 2,
196    #[doc = "3: RESV"]
197    RESV = 3,
198}
199impl From<EM4HVSCALE_A> for u8 {
200    #[inline(always)]
201    fn from(variant: EM4HVSCALE_A) -> Self {
202        variant as _
203    }
204}
205#[doc = "Reader of field `EM4HVSCALE`"]
206pub type EM4HVSCALE_R = crate::R<u8, EM4HVSCALE_A>;
207impl EM4HVSCALE_R {
208    #[doc = r"Get enumerated values variant"]
209    #[inline(always)]
210    pub fn variant(&self) -> crate::Variant<u8, EM4HVSCALE_A> {
211        use crate::Variant::*;
212        match self.bits {
213            0 => Val(EM4HVSCALE_A::VSCALE2),
214            2 => Val(EM4HVSCALE_A::VSCALE0),
215            3 => Val(EM4HVSCALE_A::RESV),
216            i => Res(i),
217        }
218    }
219    #[doc = "Checks if the value of the field is `VSCALE2`"]
220    #[inline(always)]
221    pub fn is_vscale2(&self) -> bool {
222        *self == EM4HVSCALE_A::VSCALE2
223    }
224    #[doc = "Checks if the value of the field is `VSCALE0`"]
225    #[inline(always)]
226    pub fn is_vscale0(&self) -> bool {
227        *self == EM4HVSCALE_A::VSCALE0
228    }
229    #[doc = "Checks if the value of the field is `RESV`"]
230    #[inline(always)]
231    pub fn is_resv(&self) -> bool {
232        *self == EM4HVSCALE_A::RESV
233    }
234}
235#[doc = "Write proxy for field `EM4HVSCALE`"]
236pub struct EM4HVSCALE_W<'a> {
237    w: &'a mut W,
238}
239impl<'a> EM4HVSCALE_W<'a> {
240    #[doc = r"Writes `variant` to the field"]
241    #[inline(always)]
242    pub fn variant(self, variant: EM4HVSCALE_A) -> &'a mut W {
243        unsafe { self.bits(variant.into()) }
244    }
245    #[doc = "Voltage Scale Level 2"]
246    #[inline(always)]
247    pub fn vscale2(self) -> &'a mut W {
248        self.variant(EM4HVSCALE_A::VSCALE2)
249    }
250    #[doc = "Voltage Scale Level 0"]
251    #[inline(always)]
252    pub fn vscale0(self) -> &'a mut W {
253        self.variant(EM4HVSCALE_A::VSCALE0)
254    }
255    #[doc = "RESV"]
256    #[inline(always)]
257    pub fn resv(self) -> &'a mut W {
258        self.variant(EM4HVSCALE_A::RESV)
259    }
260    #[doc = r"Writes raw bits to the field"]
261    #[inline(always)]
262    pub unsafe fn bits(self, value: u8) -> &'a mut W {
263        self.w.bits = (self.w.bits & !(0x03 << 16)) | (((value as u32) & 0x03) << 16);
264        self.w
265    }
266}
267impl R {
268    #[doc = "Bit 1 - Energy Mode 2 Block"]
269    #[inline(always)]
270    pub fn em2block(&self) -> EM2BLOCK_R {
271        EM2BLOCK_R::new(((self.bits >> 1) & 0x01) != 0)
272    }
273    #[doc = "Bit 2 - Disable BOD in EM2"]
274    #[inline(always)]
275    pub fn em2boddis(&self) -> EM2BODDIS_R {
276        EM2BODDIS_R::new(((self.bits >> 2) & 0x01) != 0)
277    }
278    #[doc = "Bit 3 - Reserved for internal use. Do not change."]
279    #[inline(always)]
280    pub fn em01ld(&self) -> EM01LD_R {
281        EM01LD_R::new(((self.bits >> 3) & 0x01) != 0)
282    }
283    #[doc = "Bit 4 - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
284    #[inline(always)]
285    pub fn em23vscaleautowsen(&self) -> EM23VSCALEAUTOWSEN_R {
286        EM23VSCALEAUTOWSEN_R::new(((self.bits >> 4) & 0x01) != 0)
287    }
288    #[doc = "Bits 8:9 - EM23 Voltage Scale"]
289    #[inline(always)]
290    pub fn em23vscale(&self) -> EM23VSCALE_R {
291        EM23VSCALE_R::new(((self.bits >> 8) & 0x03) as u8)
292    }
293    #[doc = "Bits 16:17 - EM4H Voltage Scale"]
294    #[inline(always)]
295    pub fn em4hvscale(&self) -> EM4HVSCALE_R {
296        EM4HVSCALE_R::new(((self.bits >> 16) & 0x03) as u8)
297    }
298}
299impl W {
300    #[doc = "Bit 1 - Energy Mode 2 Block"]
301    #[inline(always)]
302    pub fn em2block(&mut self) -> EM2BLOCK_W {
303        EM2BLOCK_W { w: self }
304    }
305    #[doc = "Bit 2 - Disable BOD in EM2"]
306    #[inline(always)]
307    pub fn em2boddis(&mut self) -> EM2BODDIS_W {
308        EM2BODDIS_W { w: self }
309    }
310    #[doc = "Bit 3 - Reserved for internal use. Do not change."]
311    #[inline(always)]
312    pub fn em01ld(&mut self) -> EM01LD_W {
313        EM01LD_W { w: self }
314    }
315    #[doc = "Bit 4 - Automatically Configures Flash and Frequency to Wakeup From EM2 or EM3 at Low Voltage"]
316    #[inline(always)]
317    pub fn em23vscaleautowsen(&mut self) -> EM23VSCALEAUTOWSEN_W {
318        EM23VSCALEAUTOWSEN_W { w: self }
319    }
320    #[doc = "Bits 8:9 - EM23 Voltage Scale"]
321    #[inline(always)]
322    pub fn em23vscale(&mut self) -> EM23VSCALE_W {
323        EM23VSCALE_W { w: self }
324    }
325    #[doc = "Bits 16:17 - EM4H Voltage Scale"]
326    #[inline(always)]
327    pub fn em4hvscale(&mut self) -> EM4HVSCALE_W {
328        EM4HVSCALE_W { w: self }
329    }
330}