efm32tg11b_pac/efm32tg11b120/cmu/
lfxoctrl.rs1#[doc = "Register `LFXOCTRL` reader"]
2pub struct R(crate::R<LFXOCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<LFXOCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<LFXOCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<LFXOCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `LFXOCTRL` writer"]
17pub struct W(crate::W<LFXOCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<LFXOCTRL_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<LFXOCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<LFXOCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `TUNING` reader - LFXO Internal Capacitor Array Tuning Value"]
38pub type TUNING_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `TUNING` writer - LFXO Internal Capacitor Array Tuning Value"]
40pub type TUNING_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFXOCTRL_SPEC, u8, u8, 7, O>;
41#[doc = "Field `MODE` reader - LFXO Mode"]
42pub type MODE_R = crate::FieldReader<u8, MODE_A>;
43#[doc = "LFXO Mode\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum MODE_A {
47 #[doc = "0: 32768 Hz crystal oscillator"]
48 XTAL = 0,
49 #[doc = "1: An AC coupled buffer is coupled in series with LFXTAL_N pin, suitable for external sinus wave (32768 Hz)."]
50 BUFEXTCLK = 1,
51 #[doc = "2: Digital external clock on LFXTAL_N pin. Oscillator is effectively bypassed."]
52 DIGEXTCLK = 2,
53}
54impl From<MODE_A> for u8 {
55 #[inline(always)]
56 fn from(variant: MODE_A) -> Self {
57 variant as _
58 }
59}
60impl MODE_R {
61 #[doc = "Get enumerated values variant"]
62 #[inline(always)]
63 pub fn variant(&self) -> Option<MODE_A> {
64 match self.bits {
65 0 => Some(MODE_A::XTAL),
66 1 => Some(MODE_A::BUFEXTCLK),
67 2 => Some(MODE_A::DIGEXTCLK),
68 _ => None,
69 }
70 }
71 #[doc = "Checks if the value of the field is `XTAL`"]
72 #[inline(always)]
73 pub fn is_xtal(&self) -> bool {
74 *self == MODE_A::XTAL
75 }
76 #[doc = "Checks if the value of the field is `BUFEXTCLK`"]
77 #[inline(always)]
78 pub fn is_bufextclk(&self) -> bool {
79 *self == MODE_A::BUFEXTCLK
80 }
81 #[doc = "Checks if the value of the field is `DIGEXTCLK`"]
82 #[inline(always)]
83 pub fn is_digextclk(&self) -> bool {
84 *self == MODE_A::DIGEXTCLK
85 }
86}
87#[doc = "Field `MODE` writer - LFXO Mode"]
88pub type MODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFXOCTRL_SPEC, u8, MODE_A, 2, O>;
89impl<'a, const O: u8> MODE_W<'a, O> {
90 #[doc = "32768 Hz crystal oscillator"]
91 #[inline(always)]
92 pub fn xtal(self) -> &'a mut W {
93 self.variant(MODE_A::XTAL)
94 }
95 #[doc = "An AC coupled buffer is coupled in series with LFXTAL_N pin, suitable for external sinus wave (32768 Hz)."]
96 #[inline(always)]
97 pub fn bufextclk(self) -> &'a mut W {
98 self.variant(MODE_A::BUFEXTCLK)
99 }
100 #[doc = "Digital external clock on LFXTAL_N pin. Oscillator is effectively bypassed."]
101 #[inline(always)]
102 pub fn digextclk(self) -> &'a mut W {
103 self.variant(MODE_A::DIGEXTCLK)
104 }
105}
106#[doc = "Field `GAIN` reader - LFXO Startup Gain"]
107pub type GAIN_R = crate::FieldReader<u8, u8>;
108#[doc = "Field `GAIN` writer - LFXO Startup Gain"]
109pub type GAIN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFXOCTRL_SPEC, u8, u8, 2, O>;
110#[doc = "Field `HIGHAMPL` reader - LFXO High XTAL Oscillation Amplitude Enable"]
111pub type HIGHAMPL_R = crate::BitReader<bool>;
112#[doc = "Field `HIGHAMPL` writer - LFXO High XTAL Oscillation Amplitude Enable"]
113pub type HIGHAMPL_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFXOCTRL_SPEC, bool, O>;
114#[doc = "Field `AGC` reader - LFXO AGC Enable"]
115pub type AGC_R = crate::BitReader<bool>;
116#[doc = "Field `AGC` writer - LFXO AGC Enable"]
117pub type AGC_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFXOCTRL_SPEC, bool, O>;
118#[doc = "Field `CUR` reader - LFXO Current Trim"]
119pub type CUR_R = crate::FieldReader<u8, u8>;
120#[doc = "Field `CUR` writer - LFXO Current Trim"]
121pub type CUR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LFXOCTRL_SPEC, u8, u8, 2, O>;
122#[doc = "Field `BUFCUR` reader - LFXO Buffer Bias Current"]
123pub type BUFCUR_R = crate::BitReader<bool>;
124#[doc = "Field `BUFCUR` writer - LFXO Buffer Bias Current"]
125pub type BUFCUR_W<'a, const O: u8> = crate::BitWriter<'a, u32, LFXOCTRL_SPEC, bool, O>;
126#[doc = "Field `TIMEOUT` reader - LFXO Timeout"]
127pub type TIMEOUT_R = crate::FieldReader<u8, TIMEOUT_A>;
128#[doc = "LFXO Timeout\n\nValue on reset: 7"]
129#[derive(Clone, Copy, Debug, PartialEq, Eq)]
130#[repr(u8)]
131pub enum TIMEOUT_A {
132 #[doc = "0: Timeout period of 2 cycles"]
133 _2CYCLES = 0,
134 #[doc = "1: Timeout period of 256 cycles"]
135 _256CYCLES = 1,
136 #[doc = "2: Timeout period of 1024 cycles"]
137 _1KCYCLES = 2,
138 #[doc = "3: Timeout period of 2048 cycles"]
139 _2KCYCLES = 3,
140 #[doc = "4: Timeout period of 4096 cycles"]
141 _4KCYCLES = 4,
142 #[doc = "5: Timeout period of 8192 cycles"]
143 _8KCYCLES = 5,
144 #[doc = "6: Timeout period of 16384 cycles"]
145 _16KCYCLES = 6,
146 #[doc = "7: Timeout period of 32768 cycles"]
147 _32KCYCLES = 7,
148}
149impl From<TIMEOUT_A> for u8 {
150 #[inline(always)]
151 fn from(variant: TIMEOUT_A) -> Self {
152 variant as _
153 }
154}
155impl TIMEOUT_R {
156 #[doc = "Get enumerated values variant"]
157 #[inline(always)]
158 pub fn variant(&self) -> TIMEOUT_A {
159 match self.bits {
160 0 => TIMEOUT_A::_2CYCLES,
161 1 => TIMEOUT_A::_256CYCLES,
162 2 => TIMEOUT_A::_1KCYCLES,
163 3 => TIMEOUT_A::_2KCYCLES,
164 4 => TIMEOUT_A::_4KCYCLES,
165 5 => TIMEOUT_A::_8KCYCLES,
166 6 => TIMEOUT_A::_16KCYCLES,
167 7 => TIMEOUT_A::_32KCYCLES,
168 _ => unreachable!(),
169 }
170 }
171 #[doc = "Checks if the value of the field is `_2CYCLES`"]
172 #[inline(always)]
173 pub fn is_2cycles(&self) -> bool {
174 *self == TIMEOUT_A::_2CYCLES
175 }
176 #[doc = "Checks if the value of the field is `_256CYCLES`"]
177 #[inline(always)]
178 pub fn is_256cycles(&self) -> bool {
179 *self == TIMEOUT_A::_256CYCLES
180 }
181 #[doc = "Checks if the value of the field is `_1KCYCLES`"]
182 #[inline(always)]
183 pub fn is_1kcycles(&self) -> bool {
184 *self == TIMEOUT_A::_1KCYCLES
185 }
186 #[doc = "Checks if the value of the field is `_2KCYCLES`"]
187 #[inline(always)]
188 pub fn is_2kcycles(&self) -> bool {
189 *self == TIMEOUT_A::_2KCYCLES
190 }
191 #[doc = "Checks if the value of the field is `_4KCYCLES`"]
192 #[inline(always)]
193 pub fn is_4kcycles(&self) -> bool {
194 *self == TIMEOUT_A::_4KCYCLES
195 }
196 #[doc = "Checks if the value of the field is `_8KCYCLES`"]
197 #[inline(always)]
198 pub fn is_8kcycles(&self) -> bool {
199 *self == TIMEOUT_A::_8KCYCLES
200 }
201 #[doc = "Checks if the value of the field is `_16KCYCLES`"]
202 #[inline(always)]
203 pub fn is_16kcycles(&self) -> bool {
204 *self == TIMEOUT_A::_16KCYCLES
205 }
206 #[doc = "Checks if the value of the field is `_32KCYCLES`"]
207 #[inline(always)]
208 pub fn is_32kcycles(&self) -> bool {
209 *self == TIMEOUT_A::_32KCYCLES
210 }
211}
212#[doc = "Field `TIMEOUT` writer - LFXO Timeout"]
213pub type TIMEOUT_W<'a, const O: u8> =
214 crate::FieldWriterSafe<'a, u32, LFXOCTRL_SPEC, u8, TIMEOUT_A, 3, O>;
215impl<'a, const O: u8> TIMEOUT_W<'a, O> {
216 #[doc = "Timeout period of 2 cycles"]
217 #[inline(always)]
218 pub fn _2cycles(self) -> &'a mut W {
219 self.variant(TIMEOUT_A::_2CYCLES)
220 }
221 #[doc = "Timeout period of 256 cycles"]
222 #[inline(always)]
223 pub fn _256cycles(self) -> &'a mut W {
224 self.variant(TIMEOUT_A::_256CYCLES)
225 }
226 #[doc = "Timeout period of 1024 cycles"]
227 #[inline(always)]
228 pub fn _1kcycles(self) -> &'a mut W {
229 self.variant(TIMEOUT_A::_1KCYCLES)
230 }
231 #[doc = "Timeout period of 2048 cycles"]
232 #[inline(always)]
233 pub fn _2kcycles(self) -> &'a mut W {
234 self.variant(TIMEOUT_A::_2KCYCLES)
235 }
236 #[doc = "Timeout period of 4096 cycles"]
237 #[inline(always)]
238 pub fn _4kcycles(self) -> &'a mut W {
239 self.variant(TIMEOUT_A::_4KCYCLES)
240 }
241 #[doc = "Timeout period of 8192 cycles"]
242 #[inline(always)]
243 pub fn _8kcycles(self) -> &'a mut W {
244 self.variant(TIMEOUT_A::_8KCYCLES)
245 }
246 #[doc = "Timeout period of 16384 cycles"]
247 #[inline(always)]
248 pub fn _16kcycles(self) -> &'a mut W {
249 self.variant(TIMEOUT_A::_16KCYCLES)
250 }
251 #[doc = "Timeout period of 32768 cycles"]
252 #[inline(always)]
253 pub fn _32kcycles(self) -> &'a mut W {
254 self.variant(TIMEOUT_A::_32KCYCLES)
255 }
256}
257impl R {
258 #[doc = "Bits 0:6 - LFXO Internal Capacitor Array Tuning Value"]
259 #[inline(always)]
260 pub fn tuning(&self) -> TUNING_R {
261 TUNING_R::new((self.bits & 0x7f) as u8)
262 }
263 #[doc = "Bits 8:9 - LFXO Mode"]
264 #[inline(always)]
265 pub fn mode(&self) -> MODE_R {
266 MODE_R::new(((self.bits >> 8) & 3) as u8)
267 }
268 #[doc = "Bits 11:12 - LFXO Startup Gain"]
269 #[inline(always)]
270 pub fn gain(&self) -> GAIN_R {
271 GAIN_R::new(((self.bits >> 11) & 3) as u8)
272 }
273 #[doc = "Bit 14 - LFXO High XTAL Oscillation Amplitude Enable"]
274 #[inline(always)]
275 pub fn highampl(&self) -> HIGHAMPL_R {
276 HIGHAMPL_R::new(((self.bits >> 14) & 1) != 0)
277 }
278 #[doc = "Bit 15 - LFXO AGC Enable"]
279 #[inline(always)]
280 pub fn agc(&self) -> AGC_R {
281 AGC_R::new(((self.bits >> 15) & 1) != 0)
282 }
283 #[doc = "Bits 16:17 - LFXO Current Trim"]
284 #[inline(always)]
285 pub fn cur(&self) -> CUR_R {
286 CUR_R::new(((self.bits >> 16) & 3) as u8)
287 }
288 #[doc = "Bit 20 - LFXO Buffer Bias Current"]
289 #[inline(always)]
290 pub fn bufcur(&self) -> BUFCUR_R {
291 BUFCUR_R::new(((self.bits >> 20) & 1) != 0)
292 }
293 #[doc = "Bits 24:26 - LFXO Timeout"]
294 #[inline(always)]
295 pub fn timeout(&self) -> TIMEOUT_R {
296 TIMEOUT_R::new(((self.bits >> 24) & 7) as u8)
297 }
298}
299impl W {
300 #[doc = "Bits 0:6 - LFXO Internal Capacitor Array Tuning Value"]
301 #[inline(always)]
302 #[must_use]
303 pub fn tuning(&mut self) -> TUNING_W<0> {
304 TUNING_W::new(self)
305 }
306 #[doc = "Bits 8:9 - LFXO Mode"]
307 #[inline(always)]
308 #[must_use]
309 pub fn mode(&mut self) -> MODE_W<8> {
310 MODE_W::new(self)
311 }
312 #[doc = "Bits 11:12 - LFXO Startup Gain"]
313 #[inline(always)]
314 #[must_use]
315 pub fn gain(&mut self) -> GAIN_W<11> {
316 GAIN_W::new(self)
317 }
318 #[doc = "Bit 14 - LFXO High XTAL Oscillation Amplitude Enable"]
319 #[inline(always)]
320 #[must_use]
321 pub fn highampl(&mut self) -> HIGHAMPL_W<14> {
322 HIGHAMPL_W::new(self)
323 }
324 #[doc = "Bit 15 - LFXO AGC Enable"]
325 #[inline(always)]
326 #[must_use]
327 pub fn agc(&mut self) -> AGC_W<15> {
328 AGC_W::new(self)
329 }
330 #[doc = "Bits 16:17 - LFXO Current Trim"]
331 #[inline(always)]
332 #[must_use]
333 pub fn cur(&mut self) -> CUR_W<16> {
334 CUR_W::new(self)
335 }
336 #[doc = "Bit 20 - LFXO Buffer Bias Current"]
337 #[inline(always)]
338 #[must_use]
339 pub fn bufcur(&mut self) -> BUFCUR_W<20> {
340 BUFCUR_W::new(self)
341 }
342 #[doc = "Bits 24:26 - LFXO Timeout"]
343 #[inline(always)]
344 #[must_use]
345 pub fn timeout(&mut self) -> TIMEOUT_W<24> {
346 TIMEOUT_W::new(self)
347 }
348 #[doc = "Writes raw bits to the register."]
349 #[inline(always)]
350 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
351 self.0.bits(bits);
352 self
353 }
354}
355#[doc = "LFXO 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 [lfxoctrl](index.html) module"]
356pub struct LFXOCTRL_SPEC;
357impl crate::RegisterSpec for LFXOCTRL_SPEC {
358 type Ux = u32;
359}
360#[doc = "`read()` method returns [lfxoctrl::R](R) reader structure"]
361impl crate::Readable for LFXOCTRL_SPEC {
362 type Reader = R;
363}
364#[doc = "`write(|w| ..)` method takes [lfxoctrl::W](W) writer structure"]
365impl crate::Writable for LFXOCTRL_SPEC {
366 type Writer = W;
367 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
368 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
369}
370#[doc = "`reset()` method sets LFXOCTRL to value 0x0700_9000"]
371impl crate::Resettable for LFXOCTRL_SPEC {
372 const RESET_VALUE: Self::Ux = 0x0700_9000;
373}