atsamd51j/wdt/
ewctrl.rs

1#[doc = "Register `EWCTRL` reader"]
2pub type R = crate::R<EwctrlSpec>;
3#[doc = "Register `EWCTRL` writer"]
4pub type W = crate::W<EwctrlSpec>;
5#[doc = "Early Warning Interrupt Time Offset\n\nValue on reset: 11"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Ewoffsetselect {
9    #[doc = "0: 8 clock cycles"]
10    Cyc8 = 0,
11    #[doc = "1: 16 clock cycles"]
12    Cyc16 = 1,
13    #[doc = "2: 32 clock cycles"]
14    Cyc32 = 2,
15    #[doc = "3: 64 clock cycles"]
16    Cyc64 = 3,
17    #[doc = "4: 128 clock cycles"]
18    Cyc128 = 4,
19    #[doc = "5: 256 clock cycles"]
20    Cyc256 = 5,
21    #[doc = "6: 512 clock cycles"]
22    Cyc512 = 6,
23    #[doc = "7: 1024 clock cycles"]
24    Cyc1024 = 7,
25    #[doc = "8: 2048 clock cycles"]
26    Cyc2048 = 8,
27    #[doc = "9: 4096 clock cycles"]
28    Cyc4096 = 9,
29    #[doc = "10: 8192 clock cycles"]
30    Cyc8192 = 10,
31}
32impl From<Ewoffsetselect> for u8 {
33    #[inline(always)]
34    fn from(variant: Ewoffsetselect) -> Self {
35        variant as _
36    }
37}
38impl crate::FieldSpec for Ewoffsetselect {
39    type Ux = u8;
40}
41impl crate::IsEnum for Ewoffsetselect {}
42#[doc = "Field `EWOFFSET` reader - Early Warning Interrupt Time Offset"]
43pub type EwoffsetR = crate::FieldReader<Ewoffsetselect>;
44impl EwoffsetR {
45    #[doc = "Get enumerated values variant"]
46    #[inline(always)]
47    pub const fn variant(&self) -> Option<Ewoffsetselect> {
48        match self.bits {
49            0 => Some(Ewoffsetselect::Cyc8),
50            1 => Some(Ewoffsetselect::Cyc16),
51            2 => Some(Ewoffsetselect::Cyc32),
52            3 => Some(Ewoffsetselect::Cyc64),
53            4 => Some(Ewoffsetselect::Cyc128),
54            5 => Some(Ewoffsetselect::Cyc256),
55            6 => Some(Ewoffsetselect::Cyc512),
56            7 => Some(Ewoffsetselect::Cyc1024),
57            8 => Some(Ewoffsetselect::Cyc2048),
58            9 => Some(Ewoffsetselect::Cyc4096),
59            10 => Some(Ewoffsetselect::Cyc8192),
60            _ => None,
61        }
62    }
63    #[doc = "8 clock cycles"]
64    #[inline(always)]
65    pub fn is_cyc8(&self) -> bool {
66        *self == Ewoffsetselect::Cyc8
67    }
68    #[doc = "16 clock cycles"]
69    #[inline(always)]
70    pub fn is_cyc16(&self) -> bool {
71        *self == Ewoffsetselect::Cyc16
72    }
73    #[doc = "32 clock cycles"]
74    #[inline(always)]
75    pub fn is_cyc32(&self) -> bool {
76        *self == Ewoffsetselect::Cyc32
77    }
78    #[doc = "64 clock cycles"]
79    #[inline(always)]
80    pub fn is_cyc64(&self) -> bool {
81        *self == Ewoffsetselect::Cyc64
82    }
83    #[doc = "128 clock cycles"]
84    #[inline(always)]
85    pub fn is_cyc128(&self) -> bool {
86        *self == Ewoffsetselect::Cyc128
87    }
88    #[doc = "256 clock cycles"]
89    #[inline(always)]
90    pub fn is_cyc256(&self) -> bool {
91        *self == Ewoffsetselect::Cyc256
92    }
93    #[doc = "512 clock cycles"]
94    #[inline(always)]
95    pub fn is_cyc512(&self) -> bool {
96        *self == Ewoffsetselect::Cyc512
97    }
98    #[doc = "1024 clock cycles"]
99    #[inline(always)]
100    pub fn is_cyc1024(&self) -> bool {
101        *self == Ewoffsetselect::Cyc1024
102    }
103    #[doc = "2048 clock cycles"]
104    #[inline(always)]
105    pub fn is_cyc2048(&self) -> bool {
106        *self == Ewoffsetselect::Cyc2048
107    }
108    #[doc = "4096 clock cycles"]
109    #[inline(always)]
110    pub fn is_cyc4096(&self) -> bool {
111        *self == Ewoffsetselect::Cyc4096
112    }
113    #[doc = "8192 clock cycles"]
114    #[inline(always)]
115    pub fn is_cyc8192(&self) -> bool {
116        *self == Ewoffsetselect::Cyc8192
117    }
118}
119#[doc = "Field `EWOFFSET` writer - Early Warning Interrupt Time Offset"]
120pub type EwoffsetW<'a, REG> = crate::FieldWriter<'a, REG, 4, Ewoffsetselect>;
121impl<'a, REG> EwoffsetW<'a, REG>
122where
123    REG: crate::Writable + crate::RegisterSpec,
124    REG::Ux: From<u8>,
125{
126    #[doc = "8 clock cycles"]
127    #[inline(always)]
128    pub fn cyc8(self) -> &'a mut crate::W<REG> {
129        self.variant(Ewoffsetselect::Cyc8)
130    }
131    #[doc = "16 clock cycles"]
132    #[inline(always)]
133    pub fn cyc16(self) -> &'a mut crate::W<REG> {
134        self.variant(Ewoffsetselect::Cyc16)
135    }
136    #[doc = "32 clock cycles"]
137    #[inline(always)]
138    pub fn cyc32(self) -> &'a mut crate::W<REG> {
139        self.variant(Ewoffsetselect::Cyc32)
140    }
141    #[doc = "64 clock cycles"]
142    #[inline(always)]
143    pub fn cyc64(self) -> &'a mut crate::W<REG> {
144        self.variant(Ewoffsetselect::Cyc64)
145    }
146    #[doc = "128 clock cycles"]
147    #[inline(always)]
148    pub fn cyc128(self) -> &'a mut crate::W<REG> {
149        self.variant(Ewoffsetselect::Cyc128)
150    }
151    #[doc = "256 clock cycles"]
152    #[inline(always)]
153    pub fn cyc256(self) -> &'a mut crate::W<REG> {
154        self.variant(Ewoffsetselect::Cyc256)
155    }
156    #[doc = "512 clock cycles"]
157    #[inline(always)]
158    pub fn cyc512(self) -> &'a mut crate::W<REG> {
159        self.variant(Ewoffsetselect::Cyc512)
160    }
161    #[doc = "1024 clock cycles"]
162    #[inline(always)]
163    pub fn cyc1024(self) -> &'a mut crate::W<REG> {
164        self.variant(Ewoffsetselect::Cyc1024)
165    }
166    #[doc = "2048 clock cycles"]
167    #[inline(always)]
168    pub fn cyc2048(self) -> &'a mut crate::W<REG> {
169        self.variant(Ewoffsetselect::Cyc2048)
170    }
171    #[doc = "4096 clock cycles"]
172    #[inline(always)]
173    pub fn cyc4096(self) -> &'a mut crate::W<REG> {
174        self.variant(Ewoffsetselect::Cyc4096)
175    }
176    #[doc = "8192 clock cycles"]
177    #[inline(always)]
178    pub fn cyc8192(self) -> &'a mut crate::W<REG> {
179        self.variant(Ewoffsetselect::Cyc8192)
180    }
181}
182impl R {
183    #[doc = "Bits 0:3 - Early Warning Interrupt Time Offset"]
184    #[inline(always)]
185    pub fn ewoffset(&self) -> EwoffsetR {
186        EwoffsetR::new(self.bits & 0x0f)
187    }
188}
189impl W {
190    #[doc = "Bits 0:3 - Early Warning Interrupt Time Offset"]
191    #[inline(always)]
192    #[must_use]
193    pub fn ewoffset(&mut self) -> EwoffsetW<EwctrlSpec> {
194        EwoffsetW::new(self, 0)
195    }
196}
197#[doc = "Early Warning Interrupt Control\n\nYou can [`read`](crate::Reg::read) this register and get [`ewctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ewctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
198pub struct EwctrlSpec;
199impl crate::RegisterSpec for EwctrlSpec {
200    type Ux = u8;
201}
202#[doc = "`read()` method returns [`ewctrl::R`](R) reader structure"]
203impl crate::Readable for EwctrlSpec {}
204#[doc = "`write(|w| ..)` method takes [`ewctrl::W`](W) writer structure"]
205impl crate::Writable for EwctrlSpec {
206    type Safety = crate::Unsafe;
207    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
208    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
209}
210#[doc = "`reset()` method sets EWCTRL to value 0x0b"]
211impl crate::Resettable for EwctrlSpec {
212    const RESET_VALUE: u8 = 0x0b;
213}