efm32gg11b/emu/
em4ctrl.rs

1#[doc = "Reader of register EM4CTRL"]
2pub type R = crate::R<u32, super::EM4CTRL>;
3#[doc = "Writer for register EM4CTRL"]
4pub type W = crate::W<u32, super::EM4CTRL>;
5#[doc = "Register EM4CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::EM4CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type { 0 }
10}
11#[doc = "Reader of field `EM4STATE`"]
12pub type EM4STATE_R = crate::R<bool, bool>;
13#[doc = "Write proxy for field `EM4STATE`"]
14pub struct EM4STATE_W<'a> {
15    w: &'a mut W,
16}
17impl<'a> EM4STATE_W<'a> {
18    #[doc = r"Sets the field bit"]
19    #[inline(always)]
20    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
21    #[doc = r"Clears the field bit"]
22    #[inline(always)]
23    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
24    #[doc = r"Writes raw bits to the field"]
25    #[inline(always)]
26    pub fn bit(self, value: bool) -> &'a mut W {
27        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
28        self.w
29    }
30}
31#[doc = "Reader of field `RETAINLFRCO`"]
32pub type RETAINLFRCO_R = crate::R<bool, bool>;
33#[doc = "Write proxy for field `RETAINLFRCO`"]
34pub struct RETAINLFRCO_W<'a> {
35    w: &'a mut W,
36}
37impl<'a> RETAINLFRCO_W<'a> {
38    #[doc = r"Sets the field bit"]
39    #[inline(always)]
40    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
41    #[doc = r"Clears the field bit"]
42    #[inline(always)]
43    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub fn bit(self, value: bool) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
48        self.w
49    }
50}
51#[doc = "Reader of field `RETAINLFXO`"]
52pub type RETAINLFXO_R = crate::R<bool, bool>;
53#[doc = "Write proxy for field `RETAINLFXO`"]
54pub struct RETAINLFXO_W<'a> {
55    w: &'a mut W,
56}
57impl<'a> RETAINLFXO_W<'a> {
58    #[doc = r"Sets the field bit"]
59    #[inline(always)]
60    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
61    #[doc = r"Clears the field bit"]
62    #[inline(always)]
63    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
64    #[doc = r"Writes raw bits to the field"]
65    #[inline(always)]
66    pub fn bit(self, value: bool) -> &'a mut W {
67        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
68        self.w
69    }
70}
71#[doc = "Reader of field `RETAINULFRCO`"]
72pub type RETAINULFRCO_R = crate::R<bool, bool>;
73#[doc = "Write proxy for field `RETAINULFRCO`"]
74pub struct RETAINULFRCO_W<'a> {
75    w: &'a mut W,
76}
77impl<'a> RETAINULFRCO_W<'a> {
78    #[doc = r"Sets the field bit"]
79    #[inline(always)]
80    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
81    #[doc = r"Clears the field bit"]
82    #[inline(always)]
83    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
84    #[doc = r"Writes raw bits to the field"]
85    #[inline(always)]
86    pub fn bit(self, value: bool) -> &'a mut W {
87        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
88        self.w
89    }
90}
91#[doc = "EM4 IO Retention Disable\n\nValue on reset: 0"]
92#[derive(Clone, Copy, Debug, PartialEq)]
93#[repr(u8)]
94pub enum EM4IORETMODE_A {
95    #[doc = "0: No Retention: Pads enter reset state when entering EM4"]
96    DISABLE = 0,
97    #[doc = "1: Retention through EM4: Pads enter reset state when exiting EM4"]
98    EM4EXIT = 1,
99    #[doc = "2: Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
100    SWUNLATCH = 2,
101}
102impl From<EM4IORETMODE_A> for u8 {
103    #[inline(always)]
104    fn from(variant: EM4IORETMODE_A) -> Self { variant as _ }
105}
106#[doc = "Reader of field `EM4IORETMODE`"]
107pub type EM4IORETMODE_R = crate::R<u8, EM4IORETMODE_A>;
108impl EM4IORETMODE_R {
109    #[doc = r"Get enumerated values variant"]
110    #[inline(always)]
111    pub fn variant(&self) -> crate::Variant<u8, EM4IORETMODE_A> {
112        use crate::Variant::*;
113        match self.bits {
114            0 => Val(EM4IORETMODE_A::DISABLE),
115            1 => Val(EM4IORETMODE_A::EM4EXIT),
116            2 => Val(EM4IORETMODE_A::SWUNLATCH),
117            i => Res(i),
118        }
119    }
120    #[doc = "Checks if the value of the field is `DISABLE`"]
121    #[inline(always)]
122    pub fn is_disable(&self) -> bool { *self == EM4IORETMODE_A::DISABLE }
123    #[doc = "Checks if the value of the field is `EM4EXIT`"]
124    #[inline(always)]
125    pub fn is_em4exit(&self) -> bool { *self == EM4IORETMODE_A::EM4EXIT }
126    #[doc = "Checks if the value of the field is `SWUNLATCH`"]
127    #[inline(always)]
128    pub fn is_swunlatch(&self) -> bool { *self == EM4IORETMODE_A::SWUNLATCH }
129}
130#[doc = "Write proxy for field `EM4IORETMODE`"]
131pub struct EM4IORETMODE_W<'a> {
132    w: &'a mut W,
133}
134impl<'a> EM4IORETMODE_W<'a> {
135    #[doc = r"Writes `variant` to the field"]
136    #[inline(always)]
137    pub fn variant(self, variant: EM4IORETMODE_A) -> &'a mut W {
138        unsafe { self.bits(variant.into()) }
139    }
140    #[doc = "No Retention: Pads enter reset state when entering EM4"]
141    #[inline(always)]
142    pub fn disable(self) -> &'a mut W { self.variant(EM4IORETMODE_A::DISABLE) }
143    #[doc = "Retention through EM4: Pads enter reset state when exiting EM4"]
144    #[inline(always)]
145    pub fn em4exit(self) -> &'a mut W { self.variant(EM4IORETMODE_A::EM4EXIT) }
146    #[doc = "Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
147    #[inline(always)]
148    pub fn swunlatch(self) -> &'a mut W { self.variant(EM4IORETMODE_A::SWUNLATCH) }
149    #[doc = r"Writes raw bits to the field"]
150    #[inline(always)]
151    pub unsafe fn bits(self, value: u8) -> &'a mut W {
152        self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
153        self.w
154    }
155}
156#[doc = "Write proxy for field `EM4ENTRY`"]
157pub struct EM4ENTRY_W<'a> {
158    w: &'a mut W,
159}
160impl<'a> EM4ENTRY_W<'a> {
161    #[doc = r"Writes raw bits to the field"]
162    #[inline(always)]
163    pub unsafe fn bits(self, value: u8) -> &'a mut W {
164        self.w.bits = (self.w.bits & !(0x03 << 16)) | (((value as u32) & 0x03) << 16);
165        self.w
166    }
167}
168impl R {
169    #[doc = "Bit 0 - Energy Mode 4 State"]
170    #[inline(always)]
171    pub fn em4state(&self) -> EM4STATE_R { EM4STATE_R::new((self.bits & 0x01) != 0) }
172    #[doc = "Bit 1 - LFRCO Retain During EM4"]
173    #[inline(always)]
174    pub fn retainlfrco(&self) -> RETAINLFRCO_R {
175        RETAINLFRCO_R::new(((self.bits >> 1) & 0x01) != 0)
176    }
177    #[doc = "Bit 2 - LFXO Retain During EM4"]
178    #[inline(always)]
179    pub fn retainlfxo(&self) -> RETAINLFXO_R { RETAINLFXO_R::new(((self.bits >> 2) & 0x01) != 0) }
180    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
181    #[inline(always)]
182    pub fn retainulfrco(&self) -> RETAINULFRCO_R {
183        RETAINULFRCO_R::new(((self.bits >> 3) & 0x01) != 0)
184    }
185    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
186    #[inline(always)]
187    pub fn em4ioretmode(&self) -> EM4IORETMODE_R {
188        EM4IORETMODE_R::new(((self.bits >> 4) & 0x03) as u8)
189    }
190}
191impl W {
192    #[doc = "Bit 0 - Energy Mode 4 State"]
193    #[inline(always)]
194    pub fn em4state(&mut self) -> EM4STATE_W { EM4STATE_W { w: self } }
195    #[doc = "Bit 1 - LFRCO Retain During EM4"]
196    #[inline(always)]
197    pub fn retainlfrco(&mut self) -> RETAINLFRCO_W { RETAINLFRCO_W { w: self } }
198    #[doc = "Bit 2 - LFXO Retain During EM4"]
199    #[inline(always)]
200    pub fn retainlfxo(&mut self) -> RETAINLFXO_W { RETAINLFXO_W { w: self } }
201    #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
202    #[inline(always)]
203    pub fn retainulfrco(&mut self) -> RETAINULFRCO_W { RETAINULFRCO_W { w: self } }
204    #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
205    #[inline(always)]
206    pub fn em4ioretmode(&mut self) -> EM4IORETMODE_W { EM4IORETMODE_W { w: self } }
207    #[doc = "Bits 16:17 - Energy Mode 4 Entry"]
208    #[inline(always)]
209    pub fn em4entry(&mut self) -> EM4ENTRY_W { EM4ENTRY_W { w: self } }
210}