efm32tg11b_pac/efm32tg11b120/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 = "Field `PRESC` reader - HFCLK Prescaler"]
38pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
39#[doc = "HFCLK Prescaler\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum PRESC_A {
43 #[doc = "0: `0`"]
44 NODIVISION = 0,
45}
46impl From<PRESC_A> for u8 {
47 #[inline(always)]
48 fn from(variant: PRESC_A) -> Self {
49 variant as _
50 }
51}
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, const O: u8> = crate::FieldWriter<'a, u32, HFPRESC_SPEC, u8, PRESC_A, 5, O>;
69impl<'a, const O: u8> PRESC_W<'a, O> {
70 #[doc = "`0`"]
71 #[inline(always)]
72 pub fn nodivision(self) -> &'a mut W {
73 self.variant(PRESC_A::NODIVISION)
74 }
75}
76#[doc = "Field `HFCLKLEPRESC` reader - HFCLKLE Prescaler"]
77pub type HFCLKLEPRESC_R = crate::FieldReader<u8, HFCLKLEPRESC_A>;
78#[doc = "HFCLKLE Prescaler\n\nValue on reset: 0"]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80#[repr(u8)]
81pub enum HFCLKLEPRESC_A {
82 #[doc = "0: HFCLKLE is HFBUSCLKLE divided by 2."]
83 DIV2 = 0,
84 #[doc = "1: HFCLKLE is HFBUSCLKLE divided by 4."]
85 DIV4 = 1,
86 #[doc = "2: HFCLKLE is HFBUSCLKLE divided by 8."]
87 DIV8 = 2,
88}
89impl From<HFCLKLEPRESC_A> for u8 {
90 #[inline(always)]
91 fn from(variant: HFCLKLEPRESC_A) -> Self {
92 variant as _
93 }
94}
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, const O: u8> =
124 crate::FieldWriter<'a, u32, HFPRESC_SPEC, u8, HFCLKLEPRESC_A, 2, O>;
125impl<'a, const O: u8> HFCLKLEPRESC_W<'a, O> {
126 #[doc = "HFCLKLE is HFBUSCLKLE divided by 2."]
127 #[inline(always)]
128 pub fn div2(self) -> &'a mut W {
129 self.variant(HFCLKLEPRESC_A::DIV2)
130 }
131 #[doc = "HFCLKLE is HFBUSCLKLE divided by 4."]
132 #[inline(always)]
133 pub fn div4(self) -> &'a mut W {
134 self.variant(HFCLKLEPRESC_A::DIV4)
135 }
136 #[doc = "HFCLKLE is HFBUSCLKLE divided by 8."]
137 #[inline(always)]
138 pub fn div8(self) -> &'a mut W {
139 self.variant(HFCLKLEPRESC_A::DIV8)
140 }
141}
142impl R {
143 #[doc = "Bits 8:12 - HFCLK Prescaler"]
144 #[inline(always)]
145 pub fn presc(&self) -> PRESC_R {
146 PRESC_R::new(((self.bits >> 8) & 0x1f) as u8)
147 }
148 #[doc = "Bits 24:25 - HFCLKLE Prescaler"]
149 #[inline(always)]
150 pub fn hfclklepresc(&self) -> HFCLKLEPRESC_R {
151 HFCLKLEPRESC_R::new(((self.bits >> 24) & 3) as u8)
152 }
153}
154impl W {
155 #[doc = "Bits 8:12 - HFCLK Prescaler"]
156 #[inline(always)]
157 #[must_use]
158 pub fn presc(&mut self) -> PRESC_W<8> {
159 PRESC_W::new(self)
160 }
161 #[doc = "Bits 24:25 - HFCLKLE Prescaler"]
162 #[inline(always)]
163 #[must_use]
164 pub fn hfclklepresc(&mut self) -> HFCLKLEPRESC_W<24> {
165 HFCLKLEPRESC_W::new(self)
166 }
167 #[doc = "Writes raw bits to the register."]
168 #[inline(always)]
169 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
170 self.0.bits(bits);
171 self
172 }
173}
174#[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"]
175pub struct HFPRESC_SPEC;
176impl crate::RegisterSpec for HFPRESC_SPEC {
177 type Ux = u32;
178}
179#[doc = "`read()` method returns [hfpresc::R](R) reader structure"]
180impl crate::Readable for HFPRESC_SPEC {
181 type Reader = R;
182}
183#[doc = "`write(|w| ..)` method takes [hfpresc::W](W) writer structure"]
184impl crate::Writable for HFPRESC_SPEC {
185 type Writer = W;
186 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
187 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
188}
189#[doc = "`reset()` method sets HFPRESC to value 0"]
190impl crate::Resettable for HFPRESC_SPEC {
191 const RESET_VALUE: Self::Ux = 0;
192}