efm32pg12_pac/emu/
em4ctrl.rs1#[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 {
10 0
11 }
12}
13#[doc = "Reader of field `EM4STATE`"]
14pub type EM4STATE_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `EM4STATE`"]
16pub struct EM4STATE_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> EM4STATE_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) | ((value as u32) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `RETAINLFRCO`"]
38pub type RETAINLFRCO_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `RETAINLFRCO`"]
40pub struct RETAINLFRCO_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> RETAINLFRCO_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 << 1)) | (((value as u32) & 0x01) << 1);
58 self.w
59 }
60}
61#[doc = "Reader of field `RETAINLFXO`"]
62pub type RETAINLFXO_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `RETAINLFXO`"]
64pub struct RETAINLFXO_W<'a> {
65 w: &'a mut W,
66}
67impl<'a> RETAINLFXO_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 << 2)) | (((value as u32) & 0x01) << 2);
82 self.w
83 }
84}
85#[doc = "Reader of field `RETAINULFRCO`"]
86pub type RETAINULFRCO_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `RETAINULFRCO`"]
88pub struct RETAINULFRCO_W<'a> {
89 w: &'a mut W,
90}
91impl<'a> RETAINULFRCO_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 << 3)) | (((value as u32) & 0x01) << 3);
106 self.w
107 }
108}
109#[doc = "EM4 IO Retention Disable\n\nValue on reset: 0"]
110#[derive(Clone, Copy, Debug, PartialEq)]
111#[repr(u8)]
112pub enum EM4IORETMODE_A {
113 #[doc = "0: No Retention: Pads enter reset state when entering EM4"]
114 DISABLE = 0,
115 #[doc = "1: Retention through EM4: Pads enter reset state when exiting EM4"]
116 EM4EXIT = 1,
117 #[doc = "2: Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
118 SWUNLATCH = 2,
119}
120impl From<EM4IORETMODE_A> for u8 {
121 #[inline(always)]
122 fn from(variant: EM4IORETMODE_A) -> Self {
123 variant as _
124 }
125}
126#[doc = "Reader of field `EM4IORETMODE`"]
127pub type EM4IORETMODE_R = crate::R<u8, EM4IORETMODE_A>;
128impl EM4IORETMODE_R {
129 #[doc = r"Get enumerated values variant"]
130 #[inline(always)]
131 pub fn variant(&self) -> crate::Variant<u8, EM4IORETMODE_A> {
132 use crate::Variant::*;
133 match self.bits {
134 0 => Val(EM4IORETMODE_A::DISABLE),
135 1 => Val(EM4IORETMODE_A::EM4EXIT),
136 2 => Val(EM4IORETMODE_A::SWUNLATCH),
137 i => Res(i),
138 }
139 }
140 #[doc = "Checks if the value of the field is `DISABLE`"]
141 #[inline(always)]
142 pub fn is_disable(&self) -> bool {
143 *self == EM4IORETMODE_A::DISABLE
144 }
145 #[doc = "Checks if the value of the field is `EM4EXIT`"]
146 #[inline(always)]
147 pub fn is_em4exit(&self) -> bool {
148 *self == EM4IORETMODE_A::EM4EXIT
149 }
150 #[doc = "Checks if the value of the field is `SWUNLATCH`"]
151 #[inline(always)]
152 pub fn is_swunlatch(&self) -> bool {
153 *self == EM4IORETMODE_A::SWUNLATCH
154 }
155}
156#[doc = "Write proxy for field `EM4IORETMODE`"]
157pub struct EM4IORETMODE_W<'a> {
158 w: &'a mut W,
159}
160impl<'a> EM4IORETMODE_W<'a> {
161 #[doc = r"Writes `variant` to the field"]
162 #[inline(always)]
163 pub fn variant(self, variant: EM4IORETMODE_A) -> &'a mut W {
164 unsafe { self.bits(variant.into()) }
165 }
166 #[doc = "No Retention: Pads enter reset state when entering EM4"]
167 #[inline(always)]
168 pub fn disable(self) -> &'a mut W {
169 self.variant(EM4IORETMODE_A::DISABLE)
170 }
171 #[doc = "Retention through EM4: Pads enter reset state when exiting EM4"]
172 #[inline(always)]
173 pub fn em4exit(self) -> &'a mut W {
174 self.variant(EM4IORETMODE_A::EM4EXIT)
175 }
176 #[doc = "Retention through EM4 and Wakeup: software writes UNLATCH register to remove retention"]
177 #[inline(always)]
178 pub fn swunlatch(self) -> &'a mut W {
179 self.variant(EM4IORETMODE_A::SWUNLATCH)
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 << 4)) | (((value as u32) & 0x03) << 4);
185 self.w
186 }
187}
188#[doc = "Write proxy for field `EM4ENTRY`"]
189pub struct EM4ENTRY_W<'a> {
190 w: &'a mut W,
191}
192impl<'a> EM4ENTRY_W<'a> {
193 #[doc = r"Writes raw bits to the field"]
194 #[inline(always)]
195 pub unsafe fn bits(self, value: u8) -> &'a mut W {
196 self.w.bits = (self.w.bits & !(0x03 << 16)) | (((value as u32) & 0x03) << 16);
197 self.w
198 }
199}
200impl R {
201 #[doc = "Bit 0 - Energy Mode 4 State"]
202 #[inline(always)]
203 pub fn em4state(&self) -> EM4STATE_R {
204 EM4STATE_R::new((self.bits & 0x01) != 0)
205 }
206 #[doc = "Bit 1 - LFRCO Retain During EM4"]
207 #[inline(always)]
208 pub fn retainlfrco(&self) -> RETAINLFRCO_R {
209 RETAINLFRCO_R::new(((self.bits >> 1) & 0x01) != 0)
210 }
211 #[doc = "Bit 2 - LFXO Retain During EM4"]
212 #[inline(always)]
213 pub fn retainlfxo(&self) -> RETAINLFXO_R {
214 RETAINLFXO_R::new(((self.bits >> 2) & 0x01) != 0)
215 }
216 #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
217 #[inline(always)]
218 pub fn retainulfrco(&self) -> RETAINULFRCO_R {
219 RETAINULFRCO_R::new(((self.bits >> 3) & 0x01) != 0)
220 }
221 #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
222 #[inline(always)]
223 pub fn em4ioretmode(&self) -> EM4IORETMODE_R {
224 EM4IORETMODE_R::new(((self.bits >> 4) & 0x03) as u8)
225 }
226}
227impl W {
228 #[doc = "Bit 0 - Energy Mode 4 State"]
229 #[inline(always)]
230 pub fn em4state(&mut self) -> EM4STATE_W {
231 EM4STATE_W { w: self }
232 }
233 #[doc = "Bit 1 - LFRCO Retain During EM4"]
234 #[inline(always)]
235 pub fn retainlfrco(&mut self) -> RETAINLFRCO_W {
236 RETAINLFRCO_W { w: self }
237 }
238 #[doc = "Bit 2 - LFXO Retain During EM4"]
239 #[inline(always)]
240 pub fn retainlfxo(&mut self) -> RETAINLFXO_W {
241 RETAINLFXO_W { w: self }
242 }
243 #[doc = "Bit 3 - ULFRCO Retain During EM4S"]
244 #[inline(always)]
245 pub fn retainulfrco(&mut self) -> RETAINULFRCO_W {
246 RETAINULFRCO_W { w: self }
247 }
248 #[doc = "Bits 4:5 - EM4 IO Retention Disable"]
249 #[inline(always)]
250 pub fn em4ioretmode(&mut self) -> EM4IORETMODE_W {
251 EM4IORETMODE_W { w: self }
252 }
253 #[doc = "Bits 16:17 - Energy Mode 4 Entry"]
254 #[inline(always)]
255 pub fn em4entry(&mut self) -> EM4ENTRY_W {
256 EM4ENTRY_W { w: self }
257 }
258}