efm32pg1b200_pac/cryotimer/
ctrl.rs1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EN` reader - Enable CRYOTIMER"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - Enable CRYOTIMER"]
40pub type EN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
41#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
42pub type DEBUGRUN_R = crate::BitReader<bool>;
43#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
44pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 1>;
45#[doc = "Select Low Frequency Oscillator\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum OSCSEL_A {
49 #[doc = "0: Select Low Frequency RC Oscillator"]
50 LFRCO = 0,
51 #[doc = "1: Select Low Frequency Crystal Oscillator"]
52 LFXO = 1,
53 #[doc = "2: Select Ultra Low Frequency RC Oscillator"]
54 ULFRCO = 2,
55}
56impl From<OSCSEL_A> for u8 {
57 #[inline(always)]
58 fn from(variant: OSCSEL_A) -> Self {
59 variant as _
60 }
61}
62#[doc = "Field `OSCSEL` reader - Select Low Frequency Oscillator"]
63pub type OSCSEL_R = crate::FieldReader<u8, OSCSEL_A>;
64impl OSCSEL_R {
65 #[doc = "Get enumerated values variant"]
66 #[inline(always)]
67 pub fn variant(&self) -> Option<OSCSEL_A> {
68 match self.bits {
69 0 => Some(OSCSEL_A::LFRCO),
70 1 => Some(OSCSEL_A::LFXO),
71 2 => Some(OSCSEL_A::ULFRCO),
72 _ => None,
73 }
74 }
75 #[doc = "Checks if the value of the field is `LFRCO`"]
76 #[inline(always)]
77 pub fn is_lfrco(&self) -> bool {
78 *self == OSCSEL_A::LFRCO
79 }
80 #[doc = "Checks if the value of the field is `LFXO`"]
81 #[inline(always)]
82 pub fn is_lfxo(&self) -> bool {
83 *self == OSCSEL_A::LFXO
84 }
85 #[doc = "Checks if the value of the field is `ULFRCO`"]
86 #[inline(always)]
87 pub fn is_ulfrco(&self) -> bool {
88 *self == OSCSEL_A::ULFRCO
89 }
90}
91#[doc = "Field `OSCSEL` writer - Select Low Frequency Oscillator"]
92pub type OSCSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, OSCSEL_A, 2, 2>;
93impl<'a> OSCSEL_W<'a> {
94 #[doc = "Select Low Frequency RC Oscillator"]
95 #[inline(always)]
96 pub fn lfrco(self) -> &'a mut W {
97 self.variant(OSCSEL_A::LFRCO)
98 }
99 #[doc = "Select Low Frequency Crystal Oscillator"]
100 #[inline(always)]
101 pub fn lfxo(self) -> &'a mut W {
102 self.variant(OSCSEL_A::LFXO)
103 }
104 #[doc = "Select Ultra Low Frequency RC Oscillator"]
105 #[inline(always)]
106 pub fn ulfrco(self) -> &'a mut W {
107 self.variant(OSCSEL_A::ULFRCO)
108 }
109}
110#[doc = "Prescaler Setting\n\nValue on reset: 0"]
111#[derive(Clone, Copy, Debug, PartialEq)]
112#[repr(u8)]
113pub enum PRESC_A {
114 #[doc = "0: LF Oscillator frequency undivided"]
115 DIV1 = 0,
116 #[doc = "1: LF Oscillator frequency divided by 2"]
117 DIV2 = 1,
118 #[doc = "2: LF Oscillator frequency divided by 4"]
119 DIV4 = 2,
120 #[doc = "3: LF Oscillator frequency divided by 8"]
121 DIV8 = 3,
122 #[doc = "4: LF Oscillator frequency divided by 16"]
123 DIV16 = 4,
124 #[doc = "5: LF Oscillator frequency divided by 32"]
125 DIV32 = 5,
126 #[doc = "6: LF Oscillator frequency divided by 64"]
127 DIV64 = 6,
128 #[doc = "7: LF Oscillator frequency divided by 128"]
129 DIV128 = 7,
130}
131impl From<PRESC_A> for u8 {
132 #[inline(always)]
133 fn from(variant: PRESC_A) -> Self {
134 variant as _
135 }
136}
137#[doc = "Field `PRESC` reader - Prescaler Setting"]
138pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
139impl PRESC_R {
140 #[doc = "Get enumerated values variant"]
141 #[inline(always)]
142 pub fn variant(&self) -> PRESC_A {
143 match self.bits {
144 0 => PRESC_A::DIV1,
145 1 => PRESC_A::DIV2,
146 2 => PRESC_A::DIV4,
147 3 => PRESC_A::DIV8,
148 4 => PRESC_A::DIV16,
149 5 => PRESC_A::DIV32,
150 6 => PRESC_A::DIV64,
151 7 => PRESC_A::DIV128,
152 _ => unreachable!(),
153 }
154 }
155 #[doc = "Checks if the value of the field is `DIV1`"]
156 #[inline(always)]
157 pub fn is_div1(&self) -> bool {
158 *self == PRESC_A::DIV1
159 }
160 #[doc = "Checks if the value of the field is `DIV2`"]
161 #[inline(always)]
162 pub fn is_div2(&self) -> bool {
163 *self == PRESC_A::DIV2
164 }
165 #[doc = "Checks if the value of the field is `DIV4`"]
166 #[inline(always)]
167 pub fn is_div4(&self) -> bool {
168 *self == PRESC_A::DIV4
169 }
170 #[doc = "Checks if the value of the field is `DIV8`"]
171 #[inline(always)]
172 pub fn is_div8(&self) -> bool {
173 *self == PRESC_A::DIV8
174 }
175 #[doc = "Checks if the value of the field is `DIV16`"]
176 #[inline(always)]
177 pub fn is_div16(&self) -> bool {
178 *self == PRESC_A::DIV16
179 }
180 #[doc = "Checks if the value of the field is `DIV32`"]
181 #[inline(always)]
182 pub fn is_div32(&self) -> bool {
183 *self == PRESC_A::DIV32
184 }
185 #[doc = "Checks if the value of the field is `DIV64`"]
186 #[inline(always)]
187 pub fn is_div64(&self) -> bool {
188 *self == PRESC_A::DIV64
189 }
190 #[doc = "Checks if the value of the field is `DIV128`"]
191 #[inline(always)]
192 pub fn is_div128(&self) -> bool {
193 *self == PRESC_A::DIV128
194 }
195}
196#[doc = "Field `PRESC` writer - Prescaler Setting"]
197pub type PRESC_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, PRESC_A, 3, 5>;
198impl<'a> PRESC_W<'a> {
199 #[doc = "LF Oscillator frequency undivided"]
200 #[inline(always)]
201 pub fn div1(self) -> &'a mut W {
202 self.variant(PRESC_A::DIV1)
203 }
204 #[doc = "LF Oscillator frequency divided by 2"]
205 #[inline(always)]
206 pub fn div2(self) -> &'a mut W {
207 self.variant(PRESC_A::DIV2)
208 }
209 #[doc = "LF Oscillator frequency divided by 4"]
210 #[inline(always)]
211 pub fn div4(self) -> &'a mut W {
212 self.variant(PRESC_A::DIV4)
213 }
214 #[doc = "LF Oscillator frequency divided by 8"]
215 #[inline(always)]
216 pub fn div8(self) -> &'a mut W {
217 self.variant(PRESC_A::DIV8)
218 }
219 #[doc = "LF Oscillator frequency divided by 16"]
220 #[inline(always)]
221 pub fn div16(self) -> &'a mut W {
222 self.variant(PRESC_A::DIV16)
223 }
224 #[doc = "LF Oscillator frequency divided by 32"]
225 #[inline(always)]
226 pub fn div32(self) -> &'a mut W {
227 self.variant(PRESC_A::DIV32)
228 }
229 #[doc = "LF Oscillator frequency divided by 64"]
230 #[inline(always)]
231 pub fn div64(self) -> &'a mut W {
232 self.variant(PRESC_A::DIV64)
233 }
234 #[doc = "LF Oscillator frequency divided by 128"]
235 #[inline(always)]
236 pub fn div128(self) -> &'a mut W {
237 self.variant(PRESC_A::DIV128)
238 }
239}
240impl R {
241 #[doc = "Bit 0 - Enable CRYOTIMER"]
242 #[inline(always)]
243 pub fn en(&self) -> EN_R {
244 EN_R::new((self.bits & 1) != 0)
245 }
246 #[doc = "Bit 1 - Debug Mode Run Enable"]
247 #[inline(always)]
248 pub fn debugrun(&self) -> DEBUGRUN_R {
249 DEBUGRUN_R::new(((self.bits >> 1) & 1) != 0)
250 }
251 #[doc = "Bits 2:3 - Select Low Frequency Oscillator"]
252 #[inline(always)]
253 pub fn oscsel(&self) -> OSCSEL_R {
254 OSCSEL_R::new(((self.bits >> 2) & 3) as u8)
255 }
256 #[doc = "Bits 5:7 - Prescaler Setting"]
257 #[inline(always)]
258 pub fn presc(&self) -> PRESC_R {
259 PRESC_R::new(((self.bits >> 5) & 7) as u8)
260 }
261}
262impl W {
263 #[doc = "Bit 0 - Enable CRYOTIMER"]
264 #[inline(always)]
265 pub fn en(&mut self) -> EN_W {
266 EN_W::new(self)
267 }
268 #[doc = "Bit 1 - Debug Mode Run Enable"]
269 #[inline(always)]
270 pub fn debugrun(&mut self) -> DEBUGRUN_W {
271 DEBUGRUN_W::new(self)
272 }
273 #[doc = "Bits 2:3 - Select Low Frequency Oscillator"]
274 #[inline(always)]
275 pub fn oscsel(&mut self) -> OSCSEL_W {
276 OSCSEL_W::new(self)
277 }
278 #[doc = "Bits 5:7 - Prescaler Setting"]
279 #[inline(always)]
280 pub fn presc(&mut self) -> PRESC_W {
281 PRESC_W::new(self)
282 }
283 #[doc = "Writes raw bits to the register."]
284 #[inline(always)]
285 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
286 self.0.bits(bits);
287 self
288 }
289}
290#[doc = "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 [ctrl](index.html) module"]
291pub struct CTRL_SPEC;
292impl crate::RegisterSpec for CTRL_SPEC {
293 type Ux = u32;
294}
295#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
296impl crate::Readable for CTRL_SPEC {
297 type Reader = R;
298}
299#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
300impl crate::Writable for CTRL_SPEC {
301 type Writer = W;
302}
303#[doc = "`reset()` method sets CTRL to value 0"]
304impl crate::Resettable for CTRL_SPEC {
305 #[inline(always)]
306 fn reset_value() -> Self::Ux {
307 0
308 }
309}