esp8266/timer/
frc2_ctrl.rs1#[doc = "Register `FRC2_CTRL` reader"]
2pub struct R(crate::R<FRC2_CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<FRC2_CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<FRC2_CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<FRC2_CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `FRC2_CTRL` writer"]
17pub struct W(crate::W<FRC2_CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<FRC2_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<FRC2_CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<FRC2_CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `frc2_int` reader - the status of the interrupt, when the count is equal tothe alarm value"]
38pub struct FRC2_INT_R(crate::FieldReader<bool, bool>);
39impl FRC2_INT_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: bool) -> Self {
42 FRC2_INT_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for FRC2_INT_R {
46 type Target = crate::FieldReader<bool, bool>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `frc2_ctrl` reader - bit\\[7\\]
53: timer enable, bit\\[6\\]
54: automatically reload, when the counter isequal to zero, bit\\[3:2\\]
55: prescale-divider, 0: divided by 1, 1: dividedby 16, 2 or 3: divided by 256, bit\\[0\\]
56: interrupt type, 0:edge, 1:level"]
57pub struct FRC2_CTRL_R(crate::FieldReader<u8, u8>);
58impl FRC2_CTRL_R {
59 #[inline(always)]
60 pub(crate) fn new(bits: u8) -> Self {
61 FRC2_CTRL_R(crate::FieldReader::new(bits))
62 }
63}
64impl core::ops::Deref for FRC2_CTRL_R {
65 type Target = crate::FieldReader<u8, u8>;
66 #[inline(always)]
67 fn deref(&self) -> &Self::Target {
68 &self.0
69 }
70}
71#[doc = "Field `frc2_ctrl` writer - bit\\[7\\]
72: timer enable, bit\\[6\\]
73: automatically reload, when the counter isequal to zero, bit\\[3:2\\]
74: prescale-divider, 0: divided by 1, 1: dividedby 16, 2 or 3: divided by 256, bit\\[0\\]
75: interrupt type, 0:edge, 1:level"]
76pub struct FRC2_CTRL_W<'a> {
77 w: &'a mut W,
78}
79impl<'a> FRC2_CTRL_W<'a> {
80 #[doc = r"Writes raw bits to the field"]
81 #[inline(always)]
82 pub unsafe fn bits(self, value: u8) -> &'a mut W {
83 self.w.bits = (self.w.bits & !0xff) | (value as u32 & 0xff);
84 self.w
85 }
86}
87#[doc = "Field `timer_enable` reader - Enable or disable the timer"]
88pub struct TIMER_ENABLE_R(crate::FieldReader<bool, bool>);
89impl TIMER_ENABLE_R {
90 #[inline(always)]
91 pub(crate) fn new(bits: bool) -> Self {
92 TIMER_ENABLE_R(crate::FieldReader::new(bits))
93 }
94}
95impl core::ops::Deref for TIMER_ENABLE_R {
96 type Target = crate::FieldReader<bool, bool>;
97 #[inline(always)]
98 fn deref(&self) -> &Self::Target {
99 &self.0
100 }
101}
102#[doc = "Field `timer_enable` writer - Enable or disable the timer"]
103pub struct TIMER_ENABLE_W<'a> {
104 w: &'a mut W,
105}
106impl<'a> TIMER_ENABLE_W<'a> {
107 #[doc = r"Sets the field bit"]
108 #[inline(always)]
109 pub fn set_bit(self) -> &'a mut W {
110 self.bit(true)
111 }
112 #[doc = r"Clears the field bit"]
113 #[inline(always)]
114 pub fn clear_bit(self) -> &'a mut W {
115 self.bit(false)
116 }
117 #[doc = r"Writes raw bits to the field"]
118 #[inline(always)]
119 pub fn bit(self, value: bool) -> &'a mut W {
120 self.w.bits = (self.w.bits & !(1 << 7)) | ((value as u32 & 1) << 7);
121 self.w
122 }
123}
124#[doc = "Field `rollover` reader - Automatically reload when the counter hits zero"]
125pub struct ROLLOVER_R(crate::FieldReader<bool, bool>);
126impl ROLLOVER_R {
127 #[inline(always)]
128 pub(crate) fn new(bits: bool) -> Self {
129 ROLLOVER_R(crate::FieldReader::new(bits))
130 }
131}
132impl core::ops::Deref for ROLLOVER_R {
133 type Target = crate::FieldReader<bool, bool>;
134 #[inline(always)]
135 fn deref(&self) -> &Self::Target {
136 &self.0
137 }
138}
139#[doc = "Field `rollover` writer - Automatically reload when the counter hits zero"]
140pub struct ROLLOVER_W<'a> {
141 w: &'a mut W,
142}
143impl<'a> ROLLOVER_W<'a> {
144 #[doc = r"Sets the field bit"]
145 #[inline(always)]
146 pub fn set_bit(self) -> &'a mut W {
147 self.bit(true)
148 }
149 #[doc = r"Clears the field bit"]
150 #[inline(always)]
151 pub fn clear_bit(self) -> &'a mut W {
152 self.bit(false)
153 }
154 #[doc = r"Writes raw bits to the field"]
155 #[inline(always)]
156 pub fn bit(self, value: bool) -> &'a mut W {
157 self.w.bits = (self.w.bits & !(1 << 6)) | ((value as u32 & 1) << 6);
158 self.w
159 }
160}
161#[doc = "Pre-scale divider for the timer\n\nValue on reset: 0"]
162#[derive(Clone, Copy, Debug, PartialEq)]
163#[repr(u8)]
164pub enum PRESCALE_DIVIDER_A {
165 #[doc = "0: divided by 1"]
166 DEVIDED_BY_1 = 0,
167 #[doc = "1: divided by 16"]
168 DEVIDED_BY_16 = 1,
169 #[doc = "2: divided by 256"]
170 DEVIDED_BY_256 = 2,
171}
172impl From<PRESCALE_DIVIDER_A> for u8 {
173 #[inline(always)]
174 fn from(variant: PRESCALE_DIVIDER_A) -> Self {
175 variant as _
176 }
177}
178#[doc = "Field `prescale_divider` reader - Pre-scale divider for the timer"]
179pub struct PRESCALE_DIVIDER_R(crate::FieldReader<u8, PRESCALE_DIVIDER_A>);
180impl PRESCALE_DIVIDER_R {
181 #[inline(always)]
182 pub(crate) fn new(bits: u8) -> Self {
183 PRESCALE_DIVIDER_R(crate::FieldReader::new(bits))
184 }
185 #[doc = r"Get enumerated values variant"]
186 #[inline(always)]
187 pub fn variant(&self) -> Option<PRESCALE_DIVIDER_A> {
188 match self.bits {
189 0 => Some(PRESCALE_DIVIDER_A::DEVIDED_BY_1),
190 1 => Some(PRESCALE_DIVIDER_A::DEVIDED_BY_16),
191 2 => Some(PRESCALE_DIVIDER_A::DEVIDED_BY_256),
192 _ => None,
193 }
194 }
195 #[doc = "Checks if the value of the field is `DEVIDED_BY_1`"]
196 #[inline(always)]
197 pub fn is_devided_by_1(&self) -> bool {
198 **self == PRESCALE_DIVIDER_A::DEVIDED_BY_1
199 }
200 #[doc = "Checks if the value of the field is `DEVIDED_BY_16`"]
201 #[inline(always)]
202 pub fn is_devided_by_16(&self) -> bool {
203 **self == PRESCALE_DIVIDER_A::DEVIDED_BY_16
204 }
205 #[doc = "Checks if the value of the field is `DEVIDED_BY_256`"]
206 #[inline(always)]
207 pub fn is_devided_by_256(&self) -> bool {
208 **self == PRESCALE_DIVIDER_A::DEVIDED_BY_256
209 }
210}
211impl core::ops::Deref for PRESCALE_DIVIDER_R {
212 type Target = crate::FieldReader<u8, PRESCALE_DIVIDER_A>;
213 #[inline(always)]
214 fn deref(&self) -> &Self::Target {
215 &self.0
216 }
217}
218#[doc = "Field `prescale_divider` writer - Pre-scale divider for the timer"]
219pub struct PRESCALE_DIVIDER_W<'a> {
220 w: &'a mut W,
221}
222impl<'a> PRESCALE_DIVIDER_W<'a> {
223 #[doc = r"Writes `variant` to the field"]
224 #[inline(always)]
225 pub fn variant(self, variant: PRESCALE_DIVIDER_A) -> &'a mut W {
226 unsafe { self.bits(variant.into()) }
227 }
228 #[doc = "divided by 1"]
229 #[inline(always)]
230 pub fn devided_by_1(self) -> &'a mut W {
231 self.variant(PRESCALE_DIVIDER_A::DEVIDED_BY_1)
232 }
233 #[doc = "divided by 16"]
234 #[inline(always)]
235 pub fn devided_by_16(self) -> &'a mut W {
236 self.variant(PRESCALE_DIVIDER_A::DEVIDED_BY_16)
237 }
238 #[doc = "divided by 256"]
239 #[inline(always)]
240 pub fn devided_by_256(self) -> &'a mut W {
241 self.variant(PRESCALE_DIVIDER_A::DEVIDED_BY_256)
242 }
243 #[doc = r"Writes raw bits to the field"]
244 #[inline(always)]
245 pub unsafe fn bits(self, value: u8) -> &'a mut W {
246 self.w.bits = (self.w.bits & !(3 << 2)) | ((value as u32 & 3) << 2);
247 self.w
248 }
249}
250#[doc = "Configure the interrupt type\n\nValue on reset: 0"]
251#[derive(Clone, Copy, Debug, PartialEq)]
252pub enum INTERRUPT_TYPE_A {
253 #[doc = "0: edge"]
254 EDGE = 0,
255 #[doc = "1: level"]
256 LEVEL = 1,
257}
258impl From<INTERRUPT_TYPE_A> for bool {
259 #[inline(always)]
260 fn from(variant: INTERRUPT_TYPE_A) -> Self {
261 variant as u8 != 0
262 }
263}
264#[doc = "Field `interrupt_type` reader - Configure the interrupt type"]
265pub struct INTERRUPT_TYPE_R(crate::FieldReader<bool, INTERRUPT_TYPE_A>);
266impl INTERRUPT_TYPE_R {
267 #[inline(always)]
268 pub(crate) fn new(bits: bool) -> Self {
269 INTERRUPT_TYPE_R(crate::FieldReader::new(bits))
270 }
271 #[doc = r"Get enumerated values variant"]
272 #[inline(always)]
273 pub fn variant(&self) -> INTERRUPT_TYPE_A {
274 match self.bits {
275 false => INTERRUPT_TYPE_A::EDGE,
276 true => INTERRUPT_TYPE_A::LEVEL,
277 }
278 }
279 #[doc = "Checks if the value of the field is `EDGE`"]
280 #[inline(always)]
281 pub fn is_edge(&self) -> bool {
282 **self == INTERRUPT_TYPE_A::EDGE
283 }
284 #[doc = "Checks if the value of the field is `LEVEL`"]
285 #[inline(always)]
286 pub fn is_level(&self) -> bool {
287 **self == INTERRUPT_TYPE_A::LEVEL
288 }
289}
290impl core::ops::Deref for INTERRUPT_TYPE_R {
291 type Target = crate::FieldReader<bool, INTERRUPT_TYPE_A>;
292 #[inline(always)]
293 fn deref(&self) -> &Self::Target {
294 &self.0
295 }
296}
297#[doc = "Field `interrupt_type` writer - Configure the interrupt type"]
298pub struct INTERRUPT_TYPE_W<'a> {
299 w: &'a mut W,
300}
301impl<'a> INTERRUPT_TYPE_W<'a> {
302 #[doc = r"Writes `variant` to the field"]
303 #[inline(always)]
304 pub fn variant(self, variant: INTERRUPT_TYPE_A) -> &'a mut W {
305 self.bit(variant.into())
306 }
307 #[doc = "edge"]
308 #[inline(always)]
309 pub fn edge(self) -> &'a mut W {
310 self.variant(INTERRUPT_TYPE_A::EDGE)
311 }
312 #[doc = "level"]
313 #[inline(always)]
314 pub fn level(self) -> &'a mut W {
315 self.variant(INTERRUPT_TYPE_A::LEVEL)
316 }
317 #[doc = r"Sets the field bit"]
318 #[inline(always)]
319 pub fn set_bit(self) -> &'a mut W {
320 self.bit(true)
321 }
322 #[doc = r"Clears the field bit"]
323 #[inline(always)]
324 pub fn clear_bit(self) -> &'a mut W {
325 self.bit(false)
326 }
327 #[doc = r"Writes raw bits to the field"]
328 #[inline(always)]
329 pub fn bit(self, value: bool) -> &'a mut W {
330 self.w.bits = (self.w.bits & !1) | (value as u32 & 1);
331 self.w
332 }
333}
334impl R {
335 #[doc = "Bit 8 - the status of the interrupt, when the count is equal tothe alarm value"]
336 #[inline(always)]
337 pub fn frc2_int(&self) -> FRC2_INT_R {
338 FRC2_INT_R::new(((self.bits >> 8) & 1) != 0)
339 }
340 #[doc = "Bits 0:7 - bit\\[7\\]
341: timer enable, bit\\[6\\]
342: automatically reload, when the counter isequal to zero, bit\\[3:2\\]
343: prescale-divider, 0: divided by 1, 1: dividedby 16, 2 or 3: divided by 256, bit\\[0\\]
344: interrupt type, 0:edge, 1:level"]
345 #[inline(always)]
346 pub fn frc2_ctrl(&self) -> FRC2_CTRL_R {
347 FRC2_CTRL_R::new((self.bits & 0xff) as u8)
348 }
349 #[doc = "Bit 7 - Enable or disable the timer"]
350 #[inline(always)]
351 pub fn timer_enable(&self) -> TIMER_ENABLE_R {
352 TIMER_ENABLE_R::new(((self.bits >> 7) & 1) != 0)
353 }
354 #[doc = "Bit 6 - Automatically reload when the counter hits zero"]
355 #[inline(always)]
356 pub fn rollover(&self) -> ROLLOVER_R {
357 ROLLOVER_R::new(((self.bits >> 6) & 1) != 0)
358 }
359 #[doc = "Bits 2:3 - Pre-scale divider for the timer"]
360 #[inline(always)]
361 pub fn prescale_divider(&self) -> PRESCALE_DIVIDER_R {
362 PRESCALE_DIVIDER_R::new(((self.bits >> 2) & 3) as u8)
363 }
364 #[doc = "Bit 0 - Configure the interrupt type"]
365 #[inline(always)]
366 pub fn interrupt_type(&self) -> INTERRUPT_TYPE_R {
367 INTERRUPT_TYPE_R::new((self.bits & 1) != 0)
368 }
369}
370impl W {
371 #[doc = "Bits 0:7 - bit\\[7\\]
372: timer enable, bit\\[6\\]
373: automatically reload, when the counter isequal to zero, bit\\[3:2\\]
374: prescale-divider, 0: divided by 1, 1: dividedby 16, 2 or 3: divided by 256, bit\\[0\\]
375: interrupt type, 0:edge, 1:level"]
376 #[inline(always)]
377 pub fn frc2_ctrl(&mut self) -> FRC2_CTRL_W {
378 FRC2_CTRL_W { w: self }
379 }
380 #[doc = "Bit 7 - Enable or disable the timer"]
381 #[inline(always)]
382 pub fn timer_enable(&mut self) -> TIMER_ENABLE_W {
383 TIMER_ENABLE_W { w: self }
384 }
385 #[doc = "Bit 6 - Automatically reload when the counter hits zero"]
386 #[inline(always)]
387 pub fn rollover(&mut self) -> ROLLOVER_W {
388 ROLLOVER_W { w: self }
389 }
390 #[doc = "Bits 2:3 - Pre-scale divider for the timer"]
391 #[inline(always)]
392 pub fn prescale_divider(&mut self) -> PRESCALE_DIVIDER_W {
393 PRESCALE_DIVIDER_W { w: self }
394 }
395 #[doc = "Bit 0 - Configure the interrupt type"]
396 #[inline(always)]
397 pub fn interrupt_type(&mut self) -> INTERRUPT_TYPE_W {
398 INTERRUPT_TYPE_W { w: self }
399 }
400 #[doc = "Writes raw bits to the register."]
401 #[inline(always)]
402 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
403 self.0.bits(bits);
404 self
405 }
406}
407#[doc = "FRC2_CTRL\n\nThis register you can [`read`]
408(crate::generic::Reg::read), [`write_with_zero`]
409(crate::generic::Reg::write_with_zero), [`reset`]
410(crate::generic::Reg::reset), [`write`]
411(crate::generic::Reg::write), [`modify`]
412(crate::generic::Reg::modify). See [API]
413(https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [frc2_ctrl]
414(index.html) module"]
415pub struct FRC2_CTRL_SPEC;
416impl crate::RegisterSpec for FRC2_CTRL_SPEC {
417 type Ux = u32;
418}
419#[doc = "`read()` method returns [frc2_ctrl::R]
420(R) reader structure"]
421impl crate::Readable for FRC2_CTRL_SPEC {
422 type Reader = R;
423}
424#[doc = "`write(|w| ..)` method takes [frc2_ctrl::W]
425(W) writer structure"]
426impl crate::Writable for FRC2_CTRL_SPEC {
427 type Writer = W;
428}
429#[doc = "`reset()` method sets FRC2_CTRL to value 0"]
430impl crate::Resettable for FRC2_CTRL_SPEC {
431 #[inline(always)]
432 fn reset_value() -> Self::Ux {
433 0
434 }
435}