efm32tg11b540_pac/cmu/
hfpresc.rs1#[doc = "Register `HFPRESC` reader"]
2pub struct R(crate::R<HFPRESC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HFPRESC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HFPRESC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HFPRESC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `HFPRESC` writer"]
17pub struct W(crate::W<HFPRESC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<HFPRESC_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<HFPRESC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<HFPRESC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "HFCLK Prescaler\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum PRESC_A {
41    #[doc = "0: `0`"]
42    NODIVISION = 0,
43}
44impl From<PRESC_A> for u8 {
45    #[inline(always)]
46    fn from(variant: PRESC_A) -> Self {
47        variant as _
48    }
49}
50#[doc = "Field `PRESC` reader - HFCLK Prescaler"]
51pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
52impl PRESC_R {
53    #[doc = "Get enumerated values variant"]
54    #[inline(always)]
55    pub fn variant(&self) -> Option<PRESC_A> {
56        match self.bits {
57            0 => Some(PRESC_A::NODIVISION),
58            _ => None,
59        }
60    }
61    #[doc = "Checks if the value of the field is `NODIVISION`"]
62    #[inline(always)]
63    pub fn is_nodivision(&self) -> bool {
64        *self == PRESC_A::NODIVISION
65    }
66}
67#[doc = "Field `PRESC` writer - HFCLK Prescaler"]
68pub type PRESC_W<'a> = crate::FieldWriter<'a, u32, HFPRESC_SPEC, u8, PRESC_A, 5, 8>;
69impl<'a> PRESC_W<'a> {
70    #[doc = "`0`"]
71    #[inline(always)]
72    pub fn nodivision(self) -> &'a mut W {
73        self.variant(PRESC_A::NODIVISION)
74    }
75}
76#[doc = "HFCLKLE Prescaler\n\nValue on reset: 0"]
77#[derive(Clone, Copy, Debug, PartialEq)]
78#[repr(u8)]
79pub enum HFCLKLEPRESC_A {
80    #[doc = "0: HFCLKLE is HFBUSCLKLE divided by 2."]
81    DIV2 = 0,
82    #[doc = "1: HFCLKLE is HFBUSCLKLE divided by 4."]
83    DIV4 = 1,
84    #[doc = "2: HFCLKLE is HFBUSCLKLE divided by 8."]
85    DIV8 = 2,
86}
87impl From<HFCLKLEPRESC_A> for u8 {
88    #[inline(always)]
89    fn from(variant: HFCLKLEPRESC_A) -> Self {
90        variant as _
91    }
92}
93#[doc = "Field `HFCLKLEPRESC` reader - HFCLKLE Prescaler"]
94pub type HFCLKLEPRESC_R = crate::FieldReader<u8, HFCLKLEPRESC_A>;
95impl HFCLKLEPRESC_R {
96    #[doc = "Get enumerated values variant"]
97    #[inline(always)]
98    pub fn variant(&self) -> Option<HFCLKLEPRESC_A> {
99        match self.bits {
100            0 => Some(HFCLKLEPRESC_A::DIV2),
101            1 => Some(HFCLKLEPRESC_A::DIV4),
102            2 => Some(HFCLKLEPRESC_A::DIV8),
103            _ => None,
104        }
105    }
106    #[doc = "Checks if the value of the field is `DIV2`"]
107    #[inline(always)]
108    pub fn is_div2(&self) -> bool {
109        *self == HFCLKLEPRESC_A::DIV2
110    }
111    #[doc = "Checks if the value of the field is `DIV4`"]
112    #[inline(always)]
113    pub fn is_div4(&self) -> bool {
114        *self == HFCLKLEPRESC_A::DIV4
115    }
116    #[doc = "Checks if the value of the field is `DIV8`"]
117    #[inline(always)]
118    pub fn is_div8(&self) -> bool {
119        *self == HFCLKLEPRESC_A::DIV8
120    }
121}
122#[doc = "Field `HFCLKLEPRESC` writer - HFCLKLE Prescaler"]
123pub type HFCLKLEPRESC_W<'a> = crate::FieldWriter<'a, u32, HFPRESC_SPEC, u8, HFCLKLEPRESC_A, 2, 24>;
124impl<'a> HFCLKLEPRESC_W<'a> {
125    #[doc = "HFCLKLE is HFBUSCLKLE divided by 2."]
126    #[inline(always)]
127    pub fn div2(self) -> &'a mut W {
128        self.variant(HFCLKLEPRESC_A::DIV2)
129    }
130    #[doc = "HFCLKLE is HFBUSCLKLE divided by 4."]
131    #[inline(always)]
132    pub fn div4(self) -> &'a mut W {
133        self.variant(HFCLKLEPRESC_A::DIV4)
134    }
135    #[doc = "HFCLKLE is HFBUSCLKLE divided by 8."]
136    #[inline(always)]
137    pub fn div8(self) -> &'a mut W {
138        self.variant(HFCLKLEPRESC_A::DIV8)
139    }
140}
141impl R {
142    #[doc = "Bits 8:12 - HFCLK Prescaler"]
143    #[inline(always)]
144    pub fn presc(&self) -> PRESC_R {
145        PRESC_R::new(((self.bits >> 8) & 0x1f) as u8)
146    }
147    #[doc = "Bits 24:25 - HFCLKLE Prescaler"]
148    #[inline(always)]
149    pub fn hfclklepresc(&self) -> HFCLKLEPRESC_R {
150        HFCLKLEPRESC_R::new(((self.bits >> 24) & 3) as u8)
151    }
152}
153impl W {
154    #[doc = "Bits 8:12 - HFCLK Prescaler"]
155    #[inline(always)]
156    pub fn presc(&mut self) -> PRESC_W {
157        PRESC_W::new(self)
158    }
159    #[doc = "Bits 24:25 - HFCLKLE Prescaler"]
160    #[inline(always)]
161    pub fn hfclklepresc(&mut self) -> HFCLKLEPRESC_W {
162        HFCLKLEPRESC_W::new(self)
163    }
164    #[doc = "Writes raw bits to the register."]
165    #[inline(always)]
166    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
167        self.0.bits(bits);
168        self
169    }
170}
171#[doc = "High Frequency Clock Prescaler 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 [hfpresc](index.html) module"]
172pub struct HFPRESC_SPEC;
173impl crate::RegisterSpec for HFPRESC_SPEC {
174    type Ux = u32;
175}
176#[doc = "`read()` method returns [hfpresc::R](R) reader structure"]
177impl crate::Readable for HFPRESC_SPEC {
178    type Reader = R;
179}
180#[doc = "`write(|w| ..)` method takes [hfpresc::W](W) writer structure"]
181impl crate::Writable for HFPRESC_SPEC {
182    type Writer = W;
183}
184#[doc = "`reset()` method sets HFPRESC to value 0"]
185impl crate::Resettable for HFPRESC_SPEC {
186    #[inline(always)]
187    fn reset_value() -> Self::Ux {
188        0
189    }
190}