esp8266/wdt/
wdt_ctl.rs

1#[doc = "Register `WDT_CTL` reader"]
2pub struct R(crate::R<WDT_CTL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<WDT_CTL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<WDT_CTL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<WDT_CTL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `WDT_CTL` writer"]
17pub struct W(crate::W<WDT_CTL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<WDT_CTL_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<WDT_CTL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<WDT_CTL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `Register` reader - "]
38pub struct REGISTER_R(crate::FieldReader<u32, u32>);
39impl REGISTER_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u32) -> Self {
42        REGISTER_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for REGISTER_R {
46    type Target = crate::FieldReader<u32, u32>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `Register` writer - "]
53pub struct REGISTER_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> REGISTER_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u32) -> &'a mut W {
60        self.w.bits = value;
61        self.w
62    }
63}
64#[doc = "Field `enable` reader - Enable the watchdog timer."]
65pub struct ENABLE_R(crate::FieldReader<bool, bool>);
66impl ENABLE_R {
67    #[inline(always)]
68    pub(crate) fn new(bits: bool) -> Self {
69        ENABLE_R(crate::FieldReader::new(bits))
70    }
71}
72impl core::ops::Deref for ENABLE_R {
73    type Target = crate::FieldReader<bool, bool>;
74    #[inline(always)]
75    fn deref(&self) -> &Self::Target {
76        &self.0
77    }
78}
79#[doc = "Field `enable` writer - Enable the watchdog timer."]
80pub struct ENABLE_W<'a> {
81    w: &'a mut W,
82}
83impl<'a> ENABLE_W<'a> {
84    #[doc = r"Sets the field bit"]
85    #[inline(always)]
86    pub fn set_bit(self) -> &'a mut W {
87        self.bit(true)
88    }
89    #[doc = r"Clears the field bit"]
90    #[inline(always)]
91    pub fn clear_bit(self) -> &'a mut W {
92        self.bit(false)
93    }
94    #[doc = r"Writes raw bits to the field"]
95    #[inline(always)]
96    pub fn bit(self, value: bool) -> &'a mut W {
97        self.w.bits = (self.w.bits & !1) | (value as u32 & 1);
98        self.w
99    }
100}
101#[doc = "Field `stage_1_no_reset` reader - When set to 1, and running in two-stage mode, it turns the watchdog into a single shot timer that doesn't reset the device."]
102pub struct STAGE_1_NO_RESET_R(crate::FieldReader<bool, bool>);
103impl STAGE_1_NO_RESET_R {
104    #[inline(always)]
105    pub(crate) fn new(bits: bool) -> Self {
106        STAGE_1_NO_RESET_R(crate::FieldReader::new(bits))
107    }
108}
109impl core::ops::Deref for STAGE_1_NO_RESET_R {
110    type Target = crate::FieldReader<bool, bool>;
111    #[inline(always)]
112    fn deref(&self) -> &Self::Target {
113        &self.0
114    }
115}
116#[doc = "Field `stage_1_no_reset` writer - When set to 1, and running in two-stage mode, it turns the watchdog into a single shot timer that doesn't reset the device."]
117pub struct STAGE_1_NO_RESET_W<'a> {
118    w: &'a mut W,
119}
120impl<'a> STAGE_1_NO_RESET_W<'a> {
121    #[doc = r"Sets the field bit"]
122    #[inline(always)]
123    pub fn set_bit(self) -> &'a mut W {
124        self.bit(true)
125    }
126    #[doc = r"Clears the field bit"]
127    #[inline(always)]
128    pub fn clear_bit(self) -> &'a mut W {
129        self.bit(false)
130    }
131    #[doc = r"Writes raw bits to the field"]
132    #[inline(always)]
133    pub fn bit(self, value: bool) -> &'a mut W {
134        self.w.bits = (self.w.bits & !(1 << 1)) | ((value as u32 & 1) << 1);
135        self.w
136    }
137}
138#[doc = "Field `stage_1_disable` reader - Set to 1 to disable the stage 1 of the watchdog timer"]
139pub struct STAGE_1_DISABLE_R(crate::FieldReader<bool, bool>);
140impl STAGE_1_DISABLE_R {
141    #[inline(always)]
142    pub(crate) fn new(bits: bool) -> Self {
143        STAGE_1_DISABLE_R(crate::FieldReader::new(bits))
144    }
145}
146impl core::ops::Deref for STAGE_1_DISABLE_R {
147    type Target = crate::FieldReader<bool, bool>;
148    #[inline(always)]
149    fn deref(&self) -> &Self::Target {
150        &self.0
151    }
152}
153#[doc = "Field `stage_1_disable` writer - Set to 1 to disable the stage 1 of the watchdog timer"]
154pub struct STAGE_1_DISABLE_W<'a> {
155    w: &'a mut W,
156}
157impl<'a> STAGE_1_DISABLE_W<'a> {
158    #[doc = r"Sets the field bit"]
159    #[inline(always)]
160    pub fn set_bit(self) -> &'a mut W {
161        self.bit(true)
162    }
163    #[doc = r"Clears the field bit"]
164    #[inline(always)]
165    pub fn clear_bit(self) -> &'a mut W {
166        self.bit(false)
167    }
168    #[doc = r"Writes raw bits to the field"]
169    #[inline(always)]
170    pub fn bit(self, value: bool) -> &'a mut W {
171        self.w.bits = (self.w.bits & !(1 << 2)) | ((value as u32 & 1) << 2);
172        self.w
173    }
174}
175#[doc = "Field `unknown_3` reader - "]
176pub struct UNKNOWN_3_R(crate::FieldReader<bool, bool>);
177impl UNKNOWN_3_R {
178    #[inline(always)]
179    pub(crate) fn new(bits: bool) -> Self {
180        UNKNOWN_3_R(crate::FieldReader::new(bits))
181    }
182}
183impl core::ops::Deref for UNKNOWN_3_R {
184    type Target = crate::FieldReader<bool, bool>;
185    #[inline(always)]
186    fn deref(&self) -> &Self::Target {
187        &self.0
188    }
189}
190#[doc = "Field `unknown_3` writer - "]
191pub struct UNKNOWN_3_W<'a> {
192    w: &'a mut W,
193}
194impl<'a> UNKNOWN_3_W<'a> {
195    #[doc = r"Sets the field bit"]
196    #[inline(always)]
197    pub fn set_bit(self) -> &'a mut W {
198        self.bit(true)
199    }
200    #[doc = r"Clears the field bit"]
201    #[inline(always)]
202    pub fn clear_bit(self) -> &'a mut W {
203        self.bit(false)
204    }
205    #[doc = r"Writes raw bits to the field"]
206    #[inline(always)]
207    pub fn bit(self, value: bool) -> &'a mut W {
208        self.w.bits = (self.w.bits & !(1 << 3)) | ((value as u32 & 1) << 3);
209        self.w
210    }
211}
212#[doc = "Field `unknown_4` reader - "]
213pub struct UNKNOWN_4_R(crate::FieldReader<bool, bool>);
214impl UNKNOWN_4_R {
215    #[inline(always)]
216    pub(crate) fn new(bits: bool) -> Self {
217        UNKNOWN_4_R(crate::FieldReader::new(bits))
218    }
219}
220impl core::ops::Deref for UNKNOWN_4_R {
221    type Target = crate::FieldReader<bool, bool>;
222    #[inline(always)]
223    fn deref(&self) -> &Self::Target {
224        &self.0
225    }
226}
227#[doc = "Field `unknown_4` writer - "]
228pub struct UNKNOWN_4_W<'a> {
229    w: &'a mut W,
230}
231impl<'a> UNKNOWN_4_W<'a> {
232    #[doc = r"Sets the field bit"]
233    #[inline(always)]
234    pub fn set_bit(self) -> &'a mut W {
235        self.bit(true)
236    }
237    #[doc = r"Clears the field bit"]
238    #[inline(always)]
239    pub fn clear_bit(self) -> &'a mut W {
240        self.bit(false)
241    }
242    #[doc = r"Writes raw bits to the field"]
243    #[inline(always)]
244    pub fn bit(self, value: bool) -> &'a mut W {
245        self.w.bits = (self.w.bits & !(1 << 4)) | ((value as u32 & 1) << 4);
246        self.w
247    }
248}
249#[doc = "Field `unknown_5` reader - "]
250pub struct UNKNOWN_5_R(crate::FieldReader<bool, bool>);
251impl UNKNOWN_5_R {
252    #[inline(always)]
253    pub(crate) fn new(bits: bool) -> Self {
254        UNKNOWN_5_R(crate::FieldReader::new(bits))
255    }
256}
257impl core::ops::Deref for UNKNOWN_5_R {
258    type Target = crate::FieldReader<bool, bool>;
259    #[inline(always)]
260    fn deref(&self) -> &Self::Target {
261        &self.0
262    }
263}
264#[doc = "Field `unknown_5` writer - "]
265pub struct UNKNOWN_5_W<'a> {
266    w: &'a mut W,
267}
268impl<'a> UNKNOWN_5_W<'a> {
269    #[doc = r"Sets the field bit"]
270    #[inline(always)]
271    pub fn set_bit(self) -> &'a mut W {
272        self.bit(true)
273    }
274    #[doc = r"Clears the field bit"]
275    #[inline(always)]
276    pub fn clear_bit(self) -> &'a mut W {
277        self.bit(false)
278    }
279    #[doc = r"Writes raw bits to the field"]
280    #[inline(always)]
281    pub fn bit(self, value: bool) -> &'a mut W {
282        self.w.bits = (self.w.bits & !(1 << 5)) | ((value as u32 & 1) << 5);
283        self.w
284    }
285}
286impl R {
287    #[doc = "Bits 0:31"]
288    #[inline(always)]
289    pub fn register(&self) -> REGISTER_R {
290        REGISTER_R::new(self.bits)
291    }
292    #[doc = "Bit 0 - Enable the watchdog timer."]
293    #[inline(always)]
294    pub fn enable(&self) -> ENABLE_R {
295        ENABLE_R::new((self.bits & 1) != 0)
296    }
297    #[doc = "Bit 1 - When set to 1, and running in two-stage mode, it turns the watchdog into a single shot timer that doesn't reset the device."]
298    #[inline(always)]
299    pub fn stage_1_no_reset(&self) -> STAGE_1_NO_RESET_R {
300        STAGE_1_NO_RESET_R::new(((self.bits >> 1) & 1) != 0)
301    }
302    #[doc = "Bit 2 - Set to 1 to disable the stage 1 of the watchdog timer"]
303    #[inline(always)]
304    pub fn stage_1_disable(&self) -> STAGE_1_DISABLE_R {
305        STAGE_1_DISABLE_R::new(((self.bits >> 2) & 1) != 0)
306    }
307    #[doc = "Bit 3"]
308    #[inline(always)]
309    pub fn unknown_3(&self) -> UNKNOWN_3_R {
310        UNKNOWN_3_R::new(((self.bits >> 3) & 1) != 0)
311    }
312    #[doc = "Bit 4"]
313    #[inline(always)]
314    pub fn unknown_4(&self) -> UNKNOWN_4_R {
315        UNKNOWN_4_R::new(((self.bits >> 4) & 1) != 0)
316    }
317    #[doc = "Bit 5"]
318    #[inline(always)]
319    pub fn unknown_5(&self) -> UNKNOWN_5_R {
320        UNKNOWN_5_R::new(((self.bits >> 5) & 1) != 0)
321    }
322}
323impl W {
324    #[doc = "Bits 0:31"]
325    #[inline(always)]
326    pub fn register(&mut self) -> REGISTER_W {
327        REGISTER_W { w: self }
328    }
329    #[doc = "Bit 0 - Enable the watchdog timer."]
330    #[inline(always)]
331    pub fn enable(&mut self) -> ENABLE_W {
332        ENABLE_W { w: self }
333    }
334    #[doc = "Bit 1 - When set to 1, and running in two-stage mode, it turns the watchdog into a single shot timer that doesn't reset the device."]
335    #[inline(always)]
336    pub fn stage_1_no_reset(&mut self) -> STAGE_1_NO_RESET_W {
337        STAGE_1_NO_RESET_W { w: self }
338    }
339    #[doc = "Bit 2 - Set to 1 to disable the stage 1 of the watchdog timer"]
340    #[inline(always)]
341    pub fn stage_1_disable(&mut self) -> STAGE_1_DISABLE_W {
342        STAGE_1_DISABLE_W { w: self }
343    }
344    #[doc = "Bit 3"]
345    #[inline(always)]
346    pub fn unknown_3(&mut self) -> UNKNOWN_3_W {
347        UNKNOWN_3_W { w: self }
348    }
349    #[doc = "Bit 4"]
350    #[inline(always)]
351    pub fn unknown_4(&mut self) -> UNKNOWN_4_W {
352        UNKNOWN_4_W { w: self }
353    }
354    #[doc = "Bit 5"]
355    #[inline(always)]
356    pub fn unknown_5(&mut self) -> UNKNOWN_5_W {
357        UNKNOWN_5_W { w: self }
358    }
359    #[doc = "Writes raw bits to the register."]
360    #[inline(always)]
361    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
362        self.0.bits(bits);
363        self
364    }
365}
366#[doc = "WDT_CTL\n\nThis register you can [`read`]
367(crate::generic::Reg::read), [`write_with_zero`]
368(crate::generic::Reg::write_with_zero), [`reset`]
369(crate::generic::Reg::reset), [`write`]
370(crate::generic::Reg::write), [`modify`]
371(crate::generic::Reg::modify). See [API]
372(https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [wdt_ctl]
373(index.html) module"]
374pub struct WDT_CTL_SPEC;
375impl crate::RegisterSpec for WDT_CTL_SPEC {
376    type Ux = u32;
377}
378#[doc = "`read()` method returns [wdt_ctl::R]
379(R) reader structure"]
380impl crate::Readable for WDT_CTL_SPEC {
381    type Reader = R;
382}
383#[doc = "`write(|w| ..)` method takes [wdt_ctl::W]
384(W) writer structure"]
385impl crate::Writable for WDT_CTL_SPEC {
386    type Writer = W;
387}
388#[doc = "`reset()` method sets WDT_CTL to value 0"]
389impl crate::Resettable for WDT_CTL_SPEC {
390    #[inline(always)]
391    fn reset_value() -> Self::Ux {
392        0
393    }
394}