efm32pg_pac/efm32pg1b200/cmu/
hfxoctrl.rs1#[doc = "Register `HFXOCTRL` reader"]
2pub struct R(crate::R<HFXOCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<HFXOCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<HFXOCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<HFXOCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `HFXOCTRL` writer"]
17pub struct W(crate::W<HFXOCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<HFXOCTRL_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<HFXOCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<HFXOCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `MODE` reader - HFXO Mode"]
38pub type MODE_R = crate::BitReader<bool>;
39#[doc = "Field `MODE` writer - HFXO Mode"]
40pub type MODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
41#[doc = "Field `PEAKDETSHUNTOPTMODE` reader - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
42pub type PEAKDETSHUNTOPTMODE_R = crate::FieldReader<u8, PEAKDETSHUNTOPTMODE_A>;
43#[doc = "HFXO Automatic Peak Detection and Shunt Current Optimization Mode\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum PEAKDETSHUNTOPTMODE_A {
47 #[doc = "0: Automatic control of HFXO peak detection and shunt optimization sequences. CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can also be used."]
48 AUTOCMD = 0,
49 #[doc = "1: CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can be used to trigger peak detection and shunt optimization sequences."]
50 CMD = 1,
51 #[doc = "2: CMU_HFXOSTEADYSTATECTRL IBTRIMXOCORE, REGISH, REGSELILOW, and PEAKDETEN are under full software control and are allowed to be changed once HFXO is ready."]
52 MANUAL = 2,
53}
54impl From<PEAKDETSHUNTOPTMODE_A> for u8 {
55 #[inline(always)]
56 fn from(variant: PEAKDETSHUNTOPTMODE_A) -> Self {
57 variant as _
58 }
59}
60impl PEAKDETSHUNTOPTMODE_R {
61 #[doc = "Get enumerated values variant"]
62 #[inline(always)]
63 pub fn variant(&self) -> Option<PEAKDETSHUNTOPTMODE_A> {
64 match self.bits {
65 0 => Some(PEAKDETSHUNTOPTMODE_A::AUTOCMD),
66 1 => Some(PEAKDETSHUNTOPTMODE_A::CMD),
67 2 => Some(PEAKDETSHUNTOPTMODE_A::MANUAL),
68 _ => None,
69 }
70 }
71 #[doc = "Checks if the value of the field is `AUTOCMD`"]
72 #[inline(always)]
73 pub fn is_autocmd(&self) -> bool {
74 *self == PEAKDETSHUNTOPTMODE_A::AUTOCMD
75 }
76 #[doc = "Checks if the value of the field is `CMD`"]
77 #[inline(always)]
78 pub fn is_cmd(&self) -> bool {
79 *self == PEAKDETSHUNTOPTMODE_A::CMD
80 }
81 #[doc = "Checks if the value of the field is `MANUAL`"]
82 #[inline(always)]
83 pub fn is_manual(&self) -> bool {
84 *self == PEAKDETSHUNTOPTMODE_A::MANUAL
85 }
86}
87#[doc = "Field `PEAKDETSHUNTOPTMODE` writer - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
88pub type PEAKDETSHUNTOPTMODE_W<'a, const O: u8> =
89 crate::FieldWriter<'a, u32, HFXOCTRL_SPEC, u8, PEAKDETSHUNTOPTMODE_A, 2, O>;
90impl<'a, const O: u8> PEAKDETSHUNTOPTMODE_W<'a, O> {
91 #[doc = "Automatic control of HFXO peak detection and shunt optimization sequences. CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can also be used."]
92 #[inline(always)]
93 pub fn autocmd(self) -> &'a mut W {
94 self.variant(PEAKDETSHUNTOPTMODE_A::AUTOCMD)
95 }
96 #[doc = "CMU_CMD HFXOPEAKDETSTART and HFXOSHUNTOPTSTART can be used to trigger peak detection and shunt optimization sequences."]
97 #[inline(always)]
98 pub fn cmd(self) -> &'a mut W {
99 self.variant(PEAKDETSHUNTOPTMODE_A::CMD)
100 }
101 #[doc = "CMU_HFXOSTEADYSTATECTRL IBTRIMXOCORE, REGISH, REGSELILOW, and PEAKDETEN are under full software control and are allowed to be changed once HFXO is ready."]
102 #[inline(always)]
103 pub fn manual(self) -> &'a mut W {
104 self.variant(PEAKDETSHUNTOPTMODE_A::MANUAL)
105 }
106}
107#[doc = "Field `LOWPOWER` reader - Low Power Mode Control"]
108pub type LOWPOWER_R = crate::BitReader<bool>;
109#[doc = "Field `LOWPOWER` writer - Low Power Mode Control"]
110pub type LOWPOWER_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
111#[doc = "Field `XTI2GND` reader - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
112pub type XTI2GND_R = crate::BitReader<bool>;
113#[doc = "Field `XTI2GND` writer - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
114pub type XTI2GND_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
115#[doc = "Field `XTO2GND` reader - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
116pub type XTO2GND_R = crate::BitReader<bool>;
117#[doc = "Field `XTO2GND` writer - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
118pub type XTO2GND_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
119#[doc = "Field `LFTIMEOUT` reader - HFXO Low Frequency Timeout"]
120pub type LFTIMEOUT_R = crate::FieldReader<u8, LFTIMEOUT_A>;
121#[doc = "HFXO Low Frequency Timeout\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123#[repr(u8)]
124pub enum LFTIMEOUT_A {
125 #[doc = "0: Timeout period of 0 cycles (disabled)"]
126 _0CYCLES = 0,
127 #[doc = "1: Timeout period of 2 cycles"]
128 _2CYCLES = 1,
129 #[doc = "2: Timeout period of 4 cycles"]
130 _4CYCLES = 2,
131 #[doc = "3: Timeout period of 16 cycles"]
132 _16CYCLES = 3,
133 #[doc = "4: Timeout period of 32 cycles"]
134 _32CYCLES = 4,
135 #[doc = "5: Timeout period of 64 cycles"]
136 _64CYCLES = 5,
137 #[doc = "6: Timeout period of 1024 cycles"]
138 _1KCYCLES = 6,
139 #[doc = "7: Timeout period of 4096 cycles"]
140 _4KCYCLES = 7,
141}
142impl From<LFTIMEOUT_A> for u8 {
143 #[inline(always)]
144 fn from(variant: LFTIMEOUT_A) -> Self {
145 variant as _
146 }
147}
148impl LFTIMEOUT_R {
149 #[doc = "Get enumerated values variant"]
150 #[inline(always)]
151 pub fn variant(&self) -> LFTIMEOUT_A {
152 match self.bits {
153 0 => LFTIMEOUT_A::_0CYCLES,
154 1 => LFTIMEOUT_A::_2CYCLES,
155 2 => LFTIMEOUT_A::_4CYCLES,
156 3 => LFTIMEOUT_A::_16CYCLES,
157 4 => LFTIMEOUT_A::_32CYCLES,
158 5 => LFTIMEOUT_A::_64CYCLES,
159 6 => LFTIMEOUT_A::_1KCYCLES,
160 7 => LFTIMEOUT_A::_4KCYCLES,
161 _ => unreachable!(),
162 }
163 }
164 #[doc = "Checks if the value of the field is `_0CYCLES`"]
165 #[inline(always)]
166 pub fn is_0cycles(&self) -> bool {
167 *self == LFTIMEOUT_A::_0CYCLES
168 }
169 #[doc = "Checks if the value of the field is `_2CYCLES`"]
170 #[inline(always)]
171 pub fn is_2cycles(&self) -> bool {
172 *self == LFTIMEOUT_A::_2CYCLES
173 }
174 #[doc = "Checks if the value of the field is `_4CYCLES`"]
175 #[inline(always)]
176 pub fn is_4cycles(&self) -> bool {
177 *self == LFTIMEOUT_A::_4CYCLES
178 }
179 #[doc = "Checks if the value of the field is `_16CYCLES`"]
180 #[inline(always)]
181 pub fn is_16cycles(&self) -> bool {
182 *self == LFTIMEOUT_A::_16CYCLES
183 }
184 #[doc = "Checks if the value of the field is `_32CYCLES`"]
185 #[inline(always)]
186 pub fn is_32cycles(&self) -> bool {
187 *self == LFTIMEOUT_A::_32CYCLES
188 }
189 #[doc = "Checks if the value of the field is `_64CYCLES`"]
190 #[inline(always)]
191 pub fn is_64cycles(&self) -> bool {
192 *self == LFTIMEOUT_A::_64CYCLES
193 }
194 #[doc = "Checks if the value of the field is `_1KCYCLES`"]
195 #[inline(always)]
196 pub fn is_1kcycles(&self) -> bool {
197 *self == LFTIMEOUT_A::_1KCYCLES
198 }
199 #[doc = "Checks if the value of the field is `_4KCYCLES`"]
200 #[inline(always)]
201 pub fn is_4kcycles(&self) -> bool {
202 *self == LFTIMEOUT_A::_4KCYCLES
203 }
204}
205#[doc = "Field `LFTIMEOUT` writer - HFXO Low Frequency Timeout"]
206pub type LFTIMEOUT_W<'a, const O: u8> =
207 crate::FieldWriterSafe<'a, u32, HFXOCTRL_SPEC, u8, LFTIMEOUT_A, 3, O>;
208impl<'a, const O: u8> LFTIMEOUT_W<'a, O> {
209 #[doc = "Timeout period of 0 cycles (disabled)"]
210 #[inline(always)]
211 pub fn _0cycles(self) -> &'a mut W {
212 self.variant(LFTIMEOUT_A::_0CYCLES)
213 }
214 #[doc = "Timeout period of 2 cycles"]
215 #[inline(always)]
216 pub fn _2cycles(self) -> &'a mut W {
217 self.variant(LFTIMEOUT_A::_2CYCLES)
218 }
219 #[doc = "Timeout period of 4 cycles"]
220 #[inline(always)]
221 pub fn _4cycles(self) -> &'a mut W {
222 self.variant(LFTIMEOUT_A::_4CYCLES)
223 }
224 #[doc = "Timeout period of 16 cycles"]
225 #[inline(always)]
226 pub fn _16cycles(self) -> &'a mut W {
227 self.variant(LFTIMEOUT_A::_16CYCLES)
228 }
229 #[doc = "Timeout period of 32 cycles"]
230 #[inline(always)]
231 pub fn _32cycles(self) -> &'a mut W {
232 self.variant(LFTIMEOUT_A::_32CYCLES)
233 }
234 #[doc = "Timeout period of 64 cycles"]
235 #[inline(always)]
236 pub fn _64cycles(self) -> &'a mut W {
237 self.variant(LFTIMEOUT_A::_64CYCLES)
238 }
239 #[doc = "Timeout period of 1024 cycles"]
240 #[inline(always)]
241 pub fn _1kcycles(self) -> &'a mut W {
242 self.variant(LFTIMEOUT_A::_1KCYCLES)
243 }
244 #[doc = "Timeout period of 4096 cycles"]
245 #[inline(always)]
246 pub fn _4kcycles(self) -> &'a mut W {
247 self.variant(LFTIMEOUT_A::_4KCYCLES)
248 }
249}
250#[doc = "Field `AUTOSTARTEM0EM1` reader - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
251pub type AUTOSTARTEM0EM1_R = crate::BitReader<bool>;
252#[doc = "Field `AUTOSTARTEM0EM1` writer - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
253pub type AUTOSTARTEM0EM1_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
254#[doc = "Field `AUTOSTARTSELEM0EM1` reader - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
255pub type AUTOSTARTSELEM0EM1_R = crate::BitReader<bool>;
256#[doc = "Field `AUTOSTARTSELEM0EM1` writer - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
257pub type AUTOSTARTSELEM0EM1_W<'a, const O: u8> = crate::BitWriter<'a, u32, HFXOCTRL_SPEC, bool, O>;
258impl R {
259 #[doc = "Bit 0 - HFXO Mode"]
260 #[inline(always)]
261 pub fn mode(&self) -> MODE_R {
262 MODE_R::new((self.bits & 1) != 0)
263 }
264 #[doc = "Bits 4:5 - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
265 #[inline(always)]
266 pub fn peakdetshuntoptmode(&self) -> PEAKDETSHUNTOPTMODE_R {
267 PEAKDETSHUNTOPTMODE_R::new(((self.bits >> 4) & 3) as u8)
268 }
269 #[doc = "Bit 8 - Low Power Mode Control"]
270 #[inline(always)]
271 pub fn lowpower(&self) -> LOWPOWER_R {
272 LOWPOWER_R::new(((self.bits >> 8) & 1) != 0)
273 }
274 #[doc = "Bit 9 - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
275 #[inline(always)]
276 pub fn xti2gnd(&self) -> XTI2GND_R {
277 XTI2GND_R::new(((self.bits >> 9) & 1) != 0)
278 }
279 #[doc = "Bit 10 - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
280 #[inline(always)]
281 pub fn xto2gnd(&self) -> XTO2GND_R {
282 XTO2GND_R::new(((self.bits >> 10) & 1) != 0)
283 }
284 #[doc = "Bits 24:26 - HFXO Low Frequency Timeout"]
285 #[inline(always)]
286 pub fn lftimeout(&self) -> LFTIMEOUT_R {
287 LFTIMEOUT_R::new(((self.bits >> 24) & 7) as u8)
288 }
289 #[doc = "Bit 28 - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
290 #[inline(always)]
291 pub fn autostartem0em1(&self) -> AUTOSTARTEM0EM1_R {
292 AUTOSTARTEM0EM1_R::new(((self.bits >> 28) & 1) != 0)
293 }
294 #[doc = "Bit 29 - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
295 #[inline(always)]
296 pub fn autostartselem0em1(&self) -> AUTOSTARTSELEM0EM1_R {
297 AUTOSTARTSELEM0EM1_R::new(((self.bits >> 29) & 1) != 0)
298 }
299}
300impl W {
301 #[doc = "Bit 0 - HFXO Mode"]
302 #[inline(always)]
303 #[must_use]
304 pub fn mode(&mut self) -> MODE_W<0> {
305 MODE_W::new(self)
306 }
307 #[doc = "Bits 4:5 - HFXO Automatic Peak Detection and Shunt Current Optimization Mode"]
308 #[inline(always)]
309 #[must_use]
310 pub fn peakdetshuntoptmode(&mut self) -> PEAKDETSHUNTOPTMODE_W<4> {
311 PEAKDETSHUNTOPTMODE_W::new(self)
312 }
313 #[doc = "Bit 8 - Low Power Mode Control"]
314 #[inline(always)]
315 #[must_use]
316 pub fn lowpower(&mut self) -> LOWPOWER_W<8> {
317 LOWPOWER_W::new(self)
318 }
319 #[doc = "Bit 9 - Clamp HFXTAL_N Pin to Ground When HFXO Oscillator is Off"]
320 #[inline(always)]
321 #[must_use]
322 pub fn xti2gnd(&mut self) -> XTI2GND_W<9> {
323 XTI2GND_W::new(self)
324 }
325 #[doc = "Bit 10 - Clamp HFXTAL_P Pin to Ground When HFXO Oscillator is Off"]
326 #[inline(always)]
327 #[must_use]
328 pub fn xto2gnd(&mut self) -> XTO2GND_W<10> {
329 XTO2GND_W::new(self)
330 }
331 #[doc = "Bits 24:26 - HFXO Low Frequency Timeout"]
332 #[inline(always)]
333 #[must_use]
334 pub fn lftimeout(&mut self) -> LFTIMEOUT_W<24> {
335 LFTIMEOUT_W::new(self)
336 }
337 #[doc = "Bit 28 - Automatically Start of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
338 #[inline(always)]
339 #[must_use]
340 pub fn autostartem0em1(&mut self) -> AUTOSTARTEM0EM1_W<28> {
341 AUTOSTARTEM0EM1_W::new(self)
342 }
343 #[doc = "Bit 29 - Automatically Start and Select of HFXO Upon EM0/EM1 Entry From EM2/EM3"]
344 #[inline(always)]
345 #[must_use]
346 pub fn autostartselem0em1(&mut self) -> AUTOSTARTSELEM0EM1_W<29> {
347 AUTOSTARTSELEM0EM1_W::new(self)
348 }
349 #[doc = "Writes raw bits to the register."]
350 #[inline(always)]
351 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
352 self.0.bits(bits);
353 self
354 }
355}
356#[doc = "HFXO 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 [hfxoctrl](index.html) module"]
357pub struct HFXOCTRL_SPEC;
358impl crate::RegisterSpec for HFXOCTRL_SPEC {
359 type Ux = u32;
360}
361#[doc = "`read()` method returns [hfxoctrl::R](R) reader structure"]
362impl crate::Readable for HFXOCTRL_SPEC {
363 type Reader = R;
364}
365#[doc = "`write(|w| ..)` method takes [hfxoctrl::W](W) writer structure"]
366impl crate::Writable for HFXOCTRL_SPEC {
367 type Writer = W;
368 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
369 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
370}
371#[doc = "`reset()` method sets HFXOCTRL to value 0"]
372impl crate::Resettable for HFXOCTRL_SPEC {
373 const RESET_VALUE: Self::Ux = 0;
374}