atsamd51g/supc/
bod33.rs
1#[doc = "Register `BOD33` reader"]
2pub type R = crate::R<Bod33Spec>;
3#[doc = "Register `BOD33` writer"]
4pub type W = crate::W<Bod33Spec>;
5#[doc = "Field `ENABLE` reader - Enable"]
6pub type EnableR = crate::BitReader;
7#[doc = "Field `ENABLE` writer - Enable"]
8pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Action when Threshold Crossed\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum Actionselect {
13 #[doc = "0: No action"]
14 None = 0,
15 #[doc = "1: The BOD33 generates a reset"]
16 Reset = 1,
17 #[doc = "2: The BOD33 generates an interrupt"]
18 Int = 2,
19 #[doc = "3: The BOD33 puts the device in backup sleep mode"]
20 Bkup = 3,
21}
22impl From<Actionselect> for u8 {
23 #[inline(always)]
24 fn from(variant: Actionselect) -> Self {
25 variant as _
26 }
27}
28impl crate::FieldSpec for Actionselect {
29 type Ux = u8;
30}
31impl crate::IsEnum for Actionselect {}
32#[doc = "Field `ACTION` reader - Action when Threshold Crossed"]
33pub type ActionR = crate::FieldReader<Actionselect>;
34impl ActionR {
35 #[doc = "Get enumerated values variant"]
36 #[inline(always)]
37 pub const fn variant(&self) -> Actionselect {
38 match self.bits {
39 0 => Actionselect::None,
40 1 => Actionselect::Reset,
41 2 => Actionselect::Int,
42 3 => Actionselect::Bkup,
43 _ => unreachable!(),
44 }
45 }
46 #[doc = "No action"]
47 #[inline(always)]
48 pub fn is_none(&self) -> bool {
49 *self == Actionselect::None
50 }
51 #[doc = "The BOD33 generates a reset"]
52 #[inline(always)]
53 pub fn is_reset(&self) -> bool {
54 *self == Actionselect::Reset
55 }
56 #[doc = "The BOD33 generates an interrupt"]
57 #[inline(always)]
58 pub fn is_int(&self) -> bool {
59 *self == Actionselect::Int
60 }
61 #[doc = "The BOD33 puts the device in backup sleep mode"]
62 #[inline(always)]
63 pub fn is_bkup(&self) -> bool {
64 *self == Actionselect::Bkup
65 }
66}
67#[doc = "Field `ACTION` writer - Action when Threshold Crossed"]
68pub type ActionW<'a, REG> = crate::FieldWriter<'a, REG, 2, Actionselect, crate::Safe>;
69impl<'a, REG> ActionW<'a, REG>
70where
71 REG: crate::Writable + crate::RegisterSpec,
72 REG::Ux: From<u8>,
73{
74 #[doc = "No action"]
75 #[inline(always)]
76 pub fn none(self) -> &'a mut crate::W<REG> {
77 self.variant(Actionselect::None)
78 }
79 #[doc = "The BOD33 generates a reset"]
80 #[inline(always)]
81 pub fn reset(self) -> &'a mut crate::W<REG> {
82 self.variant(Actionselect::Reset)
83 }
84 #[doc = "The BOD33 generates an interrupt"]
85 #[inline(always)]
86 pub fn int(self) -> &'a mut crate::W<REG> {
87 self.variant(Actionselect::Int)
88 }
89 #[doc = "The BOD33 puts the device in backup sleep mode"]
90 #[inline(always)]
91 pub fn bkup(self) -> &'a mut crate::W<REG> {
92 self.variant(Actionselect::Bkup)
93 }
94}
95#[doc = "Field `STDBYCFG` reader - Configuration in Standby mode"]
96pub type StdbycfgR = crate::BitReader;
97#[doc = "Field `STDBYCFG` writer - Configuration in Standby mode"]
98pub type StdbycfgW<'a, REG> = crate::BitWriter<'a, REG>;
99#[doc = "Field `RUNSTDBY` reader - Run in Standby mode"]
100pub type RunstdbyR = crate::BitReader;
101#[doc = "Field `RUNSTDBY` writer - Run in Standby mode"]
102pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
103#[doc = "Field `RUNHIB` reader - Run in Hibernate mode"]
104pub type RunhibR = crate::BitReader;
105#[doc = "Field `RUNHIB` writer - Run in Hibernate mode"]
106pub type RunhibW<'a, REG> = crate::BitWriter<'a, REG>;
107#[doc = "Field `RUNBKUP` reader - Run in Backup mode"]
108pub type RunbkupR = crate::BitReader;
109#[doc = "Field `RUNBKUP` writer - Run in Backup mode"]
110pub type RunbkupW<'a, REG> = crate::BitWriter<'a, REG>;
111#[doc = "Field `HYST` reader - Hysteresis value"]
112pub type HystR = crate::FieldReader;
113#[doc = "Field `HYST` writer - Hysteresis value"]
114pub type HystW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
115#[doc = "Prescaler Select\n\nValue on reset: 0"]
116#[derive(Clone, Copy, Debug, PartialEq, Eq)]
117#[repr(u8)]
118pub enum Pselselect {
119 #[doc = "0: Not divided"]
120 Nodiv = 0,
121 #[doc = "1: Divide clock by 4"]
122 Div4 = 1,
123 #[doc = "2: Divide clock by 8"]
124 Div8 = 2,
125 #[doc = "3: Divide clock by 16"]
126 Div16 = 3,
127 #[doc = "4: Divide clock by 32"]
128 Div32 = 4,
129 #[doc = "5: Divide clock by 64"]
130 Div64 = 5,
131 #[doc = "6: Divide clock by 128"]
132 Div128 = 6,
133 #[doc = "7: Divide clock by 256"]
134 Div256 = 7,
135}
136impl From<Pselselect> for u8 {
137 #[inline(always)]
138 fn from(variant: Pselselect) -> Self {
139 variant as _
140 }
141}
142impl crate::FieldSpec for Pselselect {
143 type Ux = u8;
144}
145impl crate::IsEnum for Pselselect {}
146#[doc = "Field `PSEL` reader - Prescaler Select"]
147pub type PselR = crate::FieldReader<Pselselect>;
148impl PselR {
149 #[doc = "Get enumerated values variant"]
150 #[inline(always)]
151 pub const fn variant(&self) -> Pselselect {
152 match self.bits {
153 0 => Pselselect::Nodiv,
154 1 => Pselselect::Div4,
155 2 => Pselselect::Div8,
156 3 => Pselselect::Div16,
157 4 => Pselselect::Div32,
158 5 => Pselselect::Div64,
159 6 => Pselselect::Div128,
160 7 => Pselselect::Div256,
161 _ => unreachable!(),
162 }
163 }
164 #[doc = "Not divided"]
165 #[inline(always)]
166 pub fn is_nodiv(&self) -> bool {
167 *self == Pselselect::Nodiv
168 }
169 #[doc = "Divide clock by 4"]
170 #[inline(always)]
171 pub fn is_div4(&self) -> bool {
172 *self == Pselselect::Div4
173 }
174 #[doc = "Divide clock by 8"]
175 #[inline(always)]
176 pub fn is_div8(&self) -> bool {
177 *self == Pselselect::Div8
178 }
179 #[doc = "Divide clock by 16"]
180 #[inline(always)]
181 pub fn is_div16(&self) -> bool {
182 *self == Pselselect::Div16
183 }
184 #[doc = "Divide clock by 32"]
185 #[inline(always)]
186 pub fn is_div32(&self) -> bool {
187 *self == Pselselect::Div32
188 }
189 #[doc = "Divide clock by 64"]
190 #[inline(always)]
191 pub fn is_div64(&self) -> bool {
192 *self == Pselselect::Div64
193 }
194 #[doc = "Divide clock by 128"]
195 #[inline(always)]
196 pub fn is_div128(&self) -> bool {
197 *self == Pselselect::Div128
198 }
199 #[doc = "Divide clock by 256"]
200 #[inline(always)]
201 pub fn is_div256(&self) -> bool {
202 *self == Pselselect::Div256
203 }
204}
205#[doc = "Field `PSEL` writer - Prescaler Select"]
206pub type PselW<'a, REG> = crate::FieldWriter<'a, REG, 3, Pselselect, crate::Safe>;
207impl<'a, REG> PselW<'a, REG>
208where
209 REG: crate::Writable + crate::RegisterSpec,
210 REG::Ux: From<u8>,
211{
212 #[doc = "Not divided"]
213 #[inline(always)]
214 pub fn nodiv(self) -> &'a mut crate::W<REG> {
215 self.variant(Pselselect::Nodiv)
216 }
217 #[doc = "Divide clock by 4"]
218 #[inline(always)]
219 pub fn div4(self) -> &'a mut crate::W<REG> {
220 self.variant(Pselselect::Div4)
221 }
222 #[doc = "Divide clock by 8"]
223 #[inline(always)]
224 pub fn div8(self) -> &'a mut crate::W<REG> {
225 self.variant(Pselselect::Div8)
226 }
227 #[doc = "Divide clock by 16"]
228 #[inline(always)]
229 pub fn div16(self) -> &'a mut crate::W<REG> {
230 self.variant(Pselselect::Div16)
231 }
232 #[doc = "Divide clock by 32"]
233 #[inline(always)]
234 pub fn div32(self) -> &'a mut crate::W<REG> {
235 self.variant(Pselselect::Div32)
236 }
237 #[doc = "Divide clock by 64"]
238 #[inline(always)]
239 pub fn div64(self) -> &'a mut crate::W<REG> {
240 self.variant(Pselselect::Div64)
241 }
242 #[doc = "Divide clock by 128"]
243 #[inline(always)]
244 pub fn div128(self) -> &'a mut crate::W<REG> {
245 self.variant(Pselselect::Div128)
246 }
247 #[doc = "Divide clock by 256"]
248 #[inline(always)]
249 pub fn div256(self) -> &'a mut crate::W<REG> {
250 self.variant(Pselselect::Div256)
251 }
252}
253#[doc = "Field `LEVEL` reader - Threshold Level for VDD"]
254pub type LevelR = crate::FieldReader;
255#[doc = "Field `LEVEL` writer - Threshold Level for VDD"]
256pub type LevelW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
257#[doc = "Field `VBATLEVEL` reader - Threshold Level in battery backup sleep mode for VBAT"]
258pub type VbatlevelR = crate::FieldReader;
259#[doc = "Field `VBATLEVEL` writer - Threshold Level in battery backup sleep mode for VBAT"]
260pub type VbatlevelW<'a, REG> = crate::FieldWriter<'a, REG, 8>;
261impl R {
262 #[doc = "Bit 1 - Enable"]
263 #[inline(always)]
264 pub fn enable(&self) -> EnableR {
265 EnableR::new(((self.bits >> 1) & 1) != 0)
266 }
267 #[doc = "Bits 2:3 - Action when Threshold Crossed"]
268 #[inline(always)]
269 pub fn action(&self) -> ActionR {
270 ActionR::new(((self.bits >> 2) & 3) as u8)
271 }
272 #[doc = "Bit 4 - Configuration in Standby mode"]
273 #[inline(always)]
274 pub fn stdbycfg(&self) -> StdbycfgR {
275 StdbycfgR::new(((self.bits >> 4) & 1) != 0)
276 }
277 #[doc = "Bit 5 - Run in Standby mode"]
278 #[inline(always)]
279 pub fn runstdby(&self) -> RunstdbyR {
280 RunstdbyR::new(((self.bits >> 5) & 1) != 0)
281 }
282 #[doc = "Bit 6 - Run in Hibernate mode"]
283 #[inline(always)]
284 pub fn runhib(&self) -> RunhibR {
285 RunhibR::new(((self.bits >> 6) & 1) != 0)
286 }
287 #[doc = "Bit 7 - Run in Backup mode"]
288 #[inline(always)]
289 pub fn runbkup(&self) -> RunbkupR {
290 RunbkupR::new(((self.bits >> 7) & 1) != 0)
291 }
292 #[doc = "Bits 8:11 - Hysteresis value"]
293 #[inline(always)]
294 pub fn hyst(&self) -> HystR {
295 HystR::new(((self.bits >> 8) & 0x0f) as u8)
296 }
297 #[doc = "Bits 12:14 - Prescaler Select"]
298 #[inline(always)]
299 pub fn psel(&self) -> PselR {
300 PselR::new(((self.bits >> 12) & 7) as u8)
301 }
302 #[doc = "Bits 16:23 - Threshold Level for VDD"]
303 #[inline(always)]
304 pub fn level(&self) -> LevelR {
305 LevelR::new(((self.bits >> 16) & 0xff) as u8)
306 }
307 #[doc = "Bits 24:31 - Threshold Level in battery backup sleep mode for VBAT"]
308 #[inline(always)]
309 pub fn vbatlevel(&self) -> VbatlevelR {
310 VbatlevelR::new(((self.bits >> 24) & 0xff) as u8)
311 }
312}
313impl W {
314 #[doc = "Bit 1 - Enable"]
315 #[inline(always)]
316 #[must_use]
317 pub fn enable(&mut self) -> EnableW<Bod33Spec> {
318 EnableW::new(self, 1)
319 }
320 #[doc = "Bits 2:3 - Action when Threshold Crossed"]
321 #[inline(always)]
322 #[must_use]
323 pub fn action(&mut self) -> ActionW<Bod33Spec> {
324 ActionW::new(self, 2)
325 }
326 #[doc = "Bit 4 - Configuration in Standby mode"]
327 #[inline(always)]
328 #[must_use]
329 pub fn stdbycfg(&mut self) -> StdbycfgW<Bod33Spec> {
330 StdbycfgW::new(self, 4)
331 }
332 #[doc = "Bit 5 - Run in Standby mode"]
333 #[inline(always)]
334 #[must_use]
335 pub fn runstdby(&mut self) -> RunstdbyW<Bod33Spec> {
336 RunstdbyW::new(self, 5)
337 }
338 #[doc = "Bit 6 - Run in Hibernate mode"]
339 #[inline(always)]
340 #[must_use]
341 pub fn runhib(&mut self) -> RunhibW<Bod33Spec> {
342 RunhibW::new(self, 6)
343 }
344 #[doc = "Bit 7 - Run in Backup mode"]
345 #[inline(always)]
346 #[must_use]
347 pub fn runbkup(&mut self) -> RunbkupW<Bod33Spec> {
348 RunbkupW::new(self, 7)
349 }
350 #[doc = "Bits 8:11 - Hysteresis value"]
351 #[inline(always)]
352 #[must_use]
353 pub fn hyst(&mut self) -> HystW<Bod33Spec> {
354 HystW::new(self, 8)
355 }
356 #[doc = "Bits 12:14 - Prescaler Select"]
357 #[inline(always)]
358 #[must_use]
359 pub fn psel(&mut self) -> PselW<Bod33Spec> {
360 PselW::new(self, 12)
361 }
362 #[doc = "Bits 16:23 - Threshold Level for VDD"]
363 #[inline(always)]
364 #[must_use]
365 pub fn level(&mut self) -> LevelW<Bod33Spec> {
366 LevelW::new(self, 16)
367 }
368 #[doc = "Bits 24:31 - Threshold Level in battery backup sleep mode for VBAT"]
369 #[inline(always)]
370 #[must_use]
371 pub fn vbatlevel(&mut self) -> VbatlevelW<Bod33Spec> {
372 VbatlevelW::new(self, 24)
373 }
374}
375#[doc = "BOD33 Control\n\nYou can [`read`](crate::Reg::read) this register and get [`bod33::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`bod33::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
376pub struct Bod33Spec;
377impl crate::RegisterSpec for Bod33Spec {
378 type Ux = u32;
379}
380#[doc = "`read()` method returns [`bod33::R`](R) reader structure"]
381impl crate::Readable for Bod33Spec {}
382#[doc = "`write(|w| ..)` method takes [`bod33::W`](W) writer structure"]
383impl crate::Writable for Bod33Spec {
384 type Safety = crate::Unsafe;
385 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
386 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
387}
388#[doc = "`reset()` method sets BOD33 to value 0"]
389impl crate::Resettable for Bod33Spec {
390 const RESET_VALUE: u32 = 0;
391}