efm32gg11b840_pac/cmu/
lfbpresc0.rs

1#[doc = "Register `LFBPRESC0` reader"]
2pub struct R(crate::R<LFBPRESC0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<LFBPRESC0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<LFBPRESC0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<LFBPRESC0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `LFBPRESC0` writer"]
17pub struct W(crate::W<LFBPRESC0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<LFBPRESC0_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<LFBPRESC0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<LFBPRESC0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Low Energy UART 0 Prescaler\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum LEUART0_A {
41    #[doc = "0: LFBCLKLEUART0 = LFBCLK"]
42    DIV1 = 0,
43    #[doc = "1: LFBCLKLEUART0 = LFBCLK/2"]
44    DIV2 = 1,
45    #[doc = "2: LFBCLKLEUART0 = LFBCLK/4"]
46    DIV4 = 2,
47    #[doc = "3: LFBCLKLEUART0 = LFBCLK/8"]
48    DIV8 = 3,
49}
50impl From<LEUART0_A> for u8 {
51    #[inline(always)]
52    fn from(variant: LEUART0_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `LEUART0` reader - Low Energy UART 0 Prescaler"]
57pub type LEUART0_R = crate::FieldReader<u8, LEUART0_A>;
58impl LEUART0_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> LEUART0_A {
62        match self.bits {
63            0 => LEUART0_A::DIV1,
64            1 => LEUART0_A::DIV2,
65            2 => LEUART0_A::DIV4,
66            3 => LEUART0_A::DIV8,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `DIV1`"]
71    #[inline(always)]
72    pub fn is_div1(&self) -> bool {
73        *self == LEUART0_A::DIV1
74    }
75    #[doc = "Checks if the value of the field is `DIV2`"]
76    #[inline(always)]
77    pub fn is_div2(&self) -> bool {
78        *self == LEUART0_A::DIV2
79    }
80    #[doc = "Checks if the value of the field is `DIV4`"]
81    #[inline(always)]
82    pub fn is_div4(&self) -> bool {
83        *self == LEUART0_A::DIV4
84    }
85    #[doc = "Checks if the value of the field is `DIV8`"]
86    #[inline(always)]
87    pub fn is_div8(&self) -> bool {
88        *self == LEUART0_A::DIV8
89    }
90}
91#[doc = "Field `LEUART0` writer - Low Energy UART 0 Prescaler"]
92pub type LEUART0_W<'a> = crate::FieldWriterSafe<'a, u32, LFBPRESC0_SPEC, u8, LEUART0_A, 2, 0>;
93impl<'a> LEUART0_W<'a> {
94    #[doc = "LFBCLKLEUART0 = LFBCLK"]
95    #[inline(always)]
96    pub fn div1(self) -> &'a mut W {
97        self.variant(LEUART0_A::DIV1)
98    }
99    #[doc = "LFBCLKLEUART0 = LFBCLK/2"]
100    #[inline(always)]
101    pub fn div2(self) -> &'a mut W {
102        self.variant(LEUART0_A::DIV2)
103    }
104    #[doc = "LFBCLKLEUART0 = LFBCLK/4"]
105    #[inline(always)]
106    pub fn div4(self) -> &'a mut W {
107        self.variant(LEUART0_A::DIV4)
108    }
109    #[doc = "LFBCLKLEUART0 = LFBCLK/8"]
110    #[inline(always)]
111    pub fn div8(self) -> &'a mut W {
112        self.variant(LEUART0_A::DIV8)
113    }
114}
115#[doc = "Low Energy UART 1 Prescaler\n\nValue on reset: 0"]
116#[derive(Clone, Copy, Debug, PartialEq)]
117#[repr(u8)]
118pub enum LEUART1_A {
119    #[doc = "0: LFBCLKLEUART1 = LFBCLK"]
120    DIV1 = 0,
121    #[doc = "1: LFBCLKLEUART1 = LFBCLK/2"]
122    DIV2 = 1,
123    #[doc = "2: LFBCLKLEUART1 = LFBCLK/4"]
124    DIV4 = 2,
125    #[doc = "3: LFBCLKLEUART1 = LFBCLK/8"]
126    DIV8 = 3,
127}
128impl From<LEUART1_A> for u8 {
129    #[inline(always)]
130    fn from(variant: LEUART1_A) -> Self {
131        variant as _
132    }
133}
134#[doc = "Field `LEUART1` reader - Low Energy UART 1 Prescaler"]
135pub type LEUART1_R = crate::FieldReader<u8, LEUART1_A>;
136impl LEUART1_R {
137    #[doc = "Get enumerated values variant"]
138    #[inline(always)]
139    pub fn variant(&self) -> LEUART1_A {
140        match self.bits {
141            0 => LEUART1_A::DIV1,
142            1 => LEUART1_A::DIV2,
143            2 => LEUART1_A::DIV4,
144            3 => LEUART1_A::DIV8,
145            _ => unreachable!(),
146        }
147    }
148    #[doc = "Checks if the value of the field is `DIV1`"]
149    #[inline(always)]
150    pub fn is_div1(&self) -> bool {
151        *self == LEUART1_A::DIV1
152    }
153    #[doc = "Checks if the value of the field is `DIV2`"]
154    #[inline(always)]
155    pub fn is_div2(&self) -> bool {
156        *self == LEUART1_A::DIV2
157    }
158    #[doc = "Checks if the value of the field is `DIV4`"]
159    #[inline(always)]
160    pub fn is_div4(&self) -> bool {
161        *self == LEUART1_A::DIV4
162    }
163    #[doc = "Checks if the value of the field is `DIV8`"]
164    #[inline(always)]
165    pub fn is_div8(&self) -> bool {
166        *self == LEUART1_A::DIV8
167    }
168}
169#[doc = "Field `LEUART1` writer - Low Energy UART 1 Prescaler"]
170pub type LEUART1_W<'a> = crate::FieldWriterSafe<'a, u32, LFBPRESC0_SPEC, u8, LEUART1_A, 2, 4>;
171impl<'a> LEUART1_W<'a> {
172    #[doc = "LFBCLKLEUART1 = LFBCLK"]
173    #[inline(always)]
174    pub fn div1(self) -> &'a mut W {
175        self.variant(LEUART1_A::DIV1)
176    }
177    #[doc = "LFBCLKLEUART1 = LFBCLK/2"]
178    #[inline(always)]
179    pub fn div2(self) -> &'a mut W {
180        self.variant(LEUART1_A::DIV2)
181    }
182    #[doc = "LFBCLKLEUART1 = LFBCLK/4"]
183    #[inline(always)]
184    pub fn div4(self) -> &'a mut W {
185        self.variant(LEUART1_A::DIV4)
186    }
187    #[doc = "LFBCLKLEUART1 = LFBCLK/8"]
188    #[inline(always)]
189    pub fn div8(self) -> &'a mut W {
190        self.variant(LEUART1_A::DIV8)
191    }
192}
193#[doc = "Prescaler\n\nValue on reset: 0"]
194#[derive(Clone, Copy, Debug, PartialEq)]
195#[repr(u8)]
196pub enum SYSTICK_A {
197    #[doc = "0: LFBCLKSYSTICK = LFBCLK"]
198    DIV1 = 0,
199}
200impl From<SYSTICK_A> for u8 {
201    #[inline(always)]
202    fn from(variant: SYSTICK_A) -> Self {
203        variant as _
204    }
205}
206#[doc = "Field `SYSTICK` reader - Prescaler"]
207pub type SYSTICK_R = crate::FieldReader<u8, SYSTICK_A>;
208impl SYSTICK_R {
209    #[doc = "Get enumerated values variant"]
210    #[inline(always)]
211    pub fn variant(&self) -> Option<SYSTICK_A> {
212        match self.bits {
213            0 => Some(SYSTICK_A::DIV1),
214            _ => None,
215        }
216    }
217    #[doc = "Checks if the value of the field is `DIV1`"]
218    #[inline(always)]
219    pub fn is_div1(&self) -> bool {
220        *self == SYSTICK_A::DIV1
221    }
222}
223#[doc = "Capacitive touch sense module Prescaler\n\nValue on reset: 0"]
224#[derive(Clone, Copy, Debug, PartialEq)]
225#[repr(u8)]
226pub enum CSEN_A {
227    #[doc = "0: LFBCLKCSEN = LFBCLK/16"]
228    DIV16 = 0,
229    #[doc = "1: LFBCLKCSEN = LFBCLK/32"]
230    DIV32 = 1,
231    #[doc = "2: LFBCLKCSEN = LFBCLK/64"]
232    DIV64 = 2,
233    #[doc = "3: LFBCLKCSEN = LFBCLK/128"]
234    DIV128 = 3,
235}
236impl From<CSEN_A> for u8 {
237    #[inline(always)]
238    fn from(variant: CSEN_A) -> Self {
239        variant as _
240    }
241}
242#[doc = "Field `CSEN` reader - Capacitive touch sense module Prescaler"]
243pub type CSEN_R = crate::FieldReader<u8, CSEN_A>;
244impl CSEN_R {
245    #[doc = "Get enumerated values variant"]
246    #[inline(always)]
247    pub fn variant(&self) -> CSEN_A {
248        match self.bits {
249            0 => CSEN_A::DIV16,
250            1 => CSEN_A::DIV32,
251            2 => CSEN_A::DIV64,
252            3 => CSEN_A::DIV128,
253            _ => unreachable!(),
254        }
255    }
256    #[doc = "Checks if the value of the field is `DIV16`"]
257    #[inline(always)]
258    pub fn is_div16(&self) -> bool {
259        *self == CSEN_A::DIV16
260    }
261    #[doc = "Checks if the value of the field is `DIV32`"]
262    #[inline(always)]
263    pub fn is_div32(&self) -> bool {
264        *self == CSEN_A::DIV32
265    }
266    #[doc = "Checks if the value of the field is `DIV64`"]
267    #[inline(always)]
268    pub fn is_div64(&self) -> bool {
269        *self == CSEN_A::DIV64
270    }
271    #[doc = "Checks if the value of the field is `DIV128`"]
272    #[inline(always)]
273    pub fn is_div128(&self) -> bool {
274        *self == CSEN_A::DIV128
275    }
276}
277#[doc = "Field `CSEN` writer - Capacitive touch sense module Prescaler"]
278pub type CSEN_W<'a> = crate::FieldWriterSafe<'a, u32, LFBPRESC0_SPEC, u8, CSEN_A, 2, 12>;
279impl<'a> CSEN_W<'a> {
280    #[doc = "LFBCLKCSEN = LFBCLK/16"]
281    #[inline(always)]
282    pub fn div16(self) -> &'a mut W {
283        self.variant(CSEN_A::DIV16)
284    }
285    #[doc = "LFBCLKCSEN = LFBCLK/32"]
286    #[inline(always)]
287    pub fn div32(self) -> &'a mut W {
288        self.variant(CSEN_A::DIV32)
289    }
290    #[doc = "LFBCLKCSEN = LFBCLK/64"]
291    #[inline(always)]
292    pub fn div64(self) -> &'a mut W {
293        self.variant(CSEN_A::DIV64)
294    }
295    #[doc = "LFBCLKCSEN = LFBCLK/128"]
296    #[inline(always)]
297    pub fn div128(self) -> &'a mut W {
298        self.variant(CSEN_A::DIV128)
299    }
300}
301impl R {
302    #[doc = "Bits 0:1 - Low Energy UART 0 Prescaler"]
303    #[inline(always)]
304    pub fn leuart0(&self) -> LEUART0_R {
305        LEUART0_R::new((self.bits & 3) as u8)
306    }
307    #[doc = "Bits 4:5 - Low Energy UART 1 Prescaler"]
308    #[inline(always)]
309    pub fn leuart1(&self) -> LEUART1_R {
310        LEUART1_R::new(((self.bits >> 4) & 3) as u8)
311    }
312    #[doc = "Bits 8:11 - Prescaler"]
313    #[inline(always)]
314    pub fn systick(&self) -> SYSTICK_R {
315        SYSTICK_R::new(((self.bits >> 8) & 0x0f) as u8)
316    }
317    #[doc = "Bits 12:13 - Capacitive touch sense module Prescaler"]
318    #[inline(always)]
319    pub fn csen(&self) -> CSEN_R {
320        CSEN_R::new(((self.bits >> 12) & 3) as u8)
321    }
322}
323impl W {
324    #[doc = "Bits 0:1 - Low Energy UART 0 Prescaler"]
325    #[inline(always)]
326    pub fn leuart0(&mut self) -> LEUART0_W {
327        LEUART0_W::new(self)
328    }
329    #[doc = "Bits 4:5 - Low Energy UART 1 Prescaler"]
330    #[inline(always)]
331    pub fn leuart1(&mut self) -> LEUART1_W {
332        LEUART1_W::new(self)
333    }
334    #[doc = "Bits 12:13 - Capacitive touch sense module Prescaler"]
335    #[inline(always)]
336    pub fn csen(&mut self) -> CSEN_W {
337        CSEN_W::new(self)
338    }
339    #[doc = "Writes raw bits to the register."]
340    #[inline(always)]
341    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
342        self.0.bits(bits);
343        self
344    }
345}
346#[doc = "Low Frequency B Prescaler Register 0 (Async Reg)\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 [lfbpresc0](index.html) module"]
347pub struct LFBPRESC0_SPEC;
348impl crate::RegisterSpec for LFBPRESC0_SPEC {
349    type Ux = u32;
350}
351#[doc = "`read()` method returns [lfbpresc0::R](R) reader structure"]
352impl crate::Readable for LFBPRESC0_SPEC {
353    type Reader = R;
354}
355#[doc = "`write(|w| ..)` method takes [lfbpresc0::W](W) writer structure"]
356impl crate::Writable for LFBPRESC0_SPEC {
357    type Writer = W;
358}
359#[doc = "`reset()` method sets LFBPRESC0 to value 0"]
360impl crate::Resettable for LFBPRESC0_SPEC {
361    #[inline(always)]
362    fn reset_value() -> Self::Ux {
363        0
364    }
365}