megatiny_hal/attiny412pac/fuse/
bodcfg.rs1#[doc = "Register `BODCFG` reader"]
2pub struct R(crate::attiny412pac::R<BODCFG_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::attiny412pac::R<BODCFG_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::attiny412pac::R<BODCFG_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::attiny412pac::R<BODCFG_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BODCFG` writer"]
17pub struct W(crate::attiny412pac::W<BODCFG_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::attiny412pac::W<BODCFG_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::attiny412pac::W<BODCFG_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::attiny412pac::W<BODCFG_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "BOD Operation in Sleep Mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum SLEEP_A {
41 #[doc = "0: Disabled"]
42 DIS = 0,
43 #[doc = "1: Enabled"]
44 ENABLED = 1,
45 #[doc = "2: Sampled"]
46 SAMPLED = 2,
47}
48impl From<SLEEP_A> for u8 {
49 #[inline(always)]
50 fn from(variant: SLEEP_A) -> Self {
51 variant as _
52 }
53}
54#[doc = "Field `SLEEP` reader - BOD Operation in Sleep Mode"]
55pub type SLEEP_R = crate::attiny412pac::FieldReader<u8, SLEEP_A>;
56impl SLEEP_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<SLEEP_A> {
60 match self.bits {
61 0 => Some(SLEEP_A::DIS),
62 1 => Some(SLEEP_A::ENABLED),
63 2 => Some(SLEEP_A::SAMPLED),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `DIS`"]
68 #[inline(always)]
69 pub fn is_dis(&self) -> bool {
70 *self == SLEEP_A::DIS
71 }
72 #[doc = "Checks if the value of the field is `ENABLED`"]
73 #[inline(always)]
74 pub fn is_enabled(&self) -> bool {
75 *self == SLEEP_A::ENABLED
76 }
77 #[doc = "Checks if the value of the field is `SAMPLED`"]
78 #[inline(always)]
79 pub fn is_sampled(&self) -> bool {
80 *self == SLEEP_A::SAMPLED
81 }
82}
83#[doc = "Field `SLEEP` writer - BOD Operation in Sleep Mode"]
84pub type SLEEP_W<'a, const O: u8> = crate::attiny412pac::FieldWriter<'a, u8, BODCFG_SPEC, u8, SLEEP_A, 2, O>;
85impl<'a, const O: u8> SLEEP_W<'a, O> {
86 #[doc = "Disabled"]
87 #[inline(always)]
88 pub fn dis(self) -> &'a mut W {
89 self.variant(SLEEP_A::DIS)
90 }
91 #[doc = "Enabled"]
92 #[inline(always)]
93 pub fn enabled(self) -> &'a mut W {
94 self.variant(SLEEP_A::ENABLED)
95 }
96 #[doc = "Sampled"]
97 #[inline(always)]
98 pub fn sampled(self) -> &'a mut W {
99 self.variant(SLEEP_A::SAMPLED)
100 }
101}
102#[doc = "BOD Operation in Active Mode\n\nValue on reset: 0"]
103#[derive(Clone, Copy, Debug, PartialEq)]
104#[repr(u8)]
105pub enum ACTIVE_A {
106 #[doc = "0: Disabled"]
107 DIS = 0,
108 #[doc = "1: Enabled"]
109 ENABLED = 1,
110 #[doc = "2: Sampled"]
111 SAMPLED = 2,
112 #[doc = "3: Enabled with wake-up halted until BOD is ready"]
113 ENWAKE = 3,
114}
115impl From<ACTIVE_A> for u8 {
116 #[inline(always)]
117 fn from(variant: ACTIVE_A) -> Self {
118 variant as _
119 }
120}
121#[doc = "Field `ACTIVE` reader - BOD Operation in Active Mode"]
122pub type ACTIVE_R = crate::attiny412pac::FieldReader<u8, ACTIVE_A>;
123impl ACTIVE_R {
124 #[doc = "Get enumerated values variant"]
125 #[inline(always)]
126 pub fn variant(&self) -> ACTIVE_A {
127 match self.bits {
128 0 => ACTIVE_A::DIS,
129 1 => ACTIVE_A::ENABLED,
130 2 => ACTIVE_A::SAMPLED,
131 3 => ACTIVE_A::ENWAKE,
132 _ => unreachable!(),
133 }
134 }
135 #[doc = "Checks if the value of the field is `DIS`"]
136 #[inline(always)]
137 pub fn is_dis(&self) -> bool {
138 *self == ACTIVE_A::DIS
139 }
140 #[doc = "Checks if the value of the field is `ENABLED`"]
141 #[inline(always)]
142 pub fn is_enabled(&self) -> bool {
143 *self == ACTIVE_A::ENABLED
144 }
145 #[doc = "Checks if the value of the field is `SAMPLED`"]
146 #[inline(always)]
147 pub fn is_sampled(&self) -> bool {
148 *self == ACTIVE_A::SAMPLED
149 }
150 #[doc = "Checks if the value of the field is `ENWAKE`"]
151 #[inline(always)]
152 pub fn is_enwake(&self) -> bool {
153 *self == ACTIVE_A::ENWAKE
154 }
155}
156#[doc = "Field `ACTIVE` writer - BOD Operation in Active Mode"]
157pub type ACTIVE_W<'a, const O: u8> =
158 crate::attiny412pac::FieldWriterSafe<'a, u8, BODCFG_SPEC, u8, ACTIVE_A, 2, O>;
159impl<'a, const O: u8> ACTIVE_W<'a, O> {
160 #[doc = "Disabled"]
161 #[inline(always)]
162 pub fn dis(self) -> &'a mut W {
163 self.variant(ACTIVE_A::DIS)
164 }
165 #[doc = "Enabled"]
166 #[inline(always)]
167 pub fn enabled(self) -> &'a mut W {
168 self.variant(ACTIVE_A::ENABLED)
169 }
170 #[doc = "Sampled"]
171 #[inline(always)]
172 pub fn sampled(self) -> &'a mut W {
173 self.variant(ACTIVE_A::SAMPLED)
174 }
175 #[doc = "Enabled with wake-up halted until BOD is ready"]
176 #[inline(always)]
177 pub fn enwake(self) -> &'a mut W {
178 self.variant(ACTIVE_A::ENWAKE)
179 }
180}
181#[doc = "BOD Sample Frequency\n\nValue on reset: 0"]
182#[derive(Clone, Copy, Debug, PartialEq)]
183pub enum SAMPFREQ_A {
184 #[doc = "0: 1kHz sampling frequency"]
185 _1KHZ = 0,
186 #[doc = "1: 125Hz sampling frequency"]
187 _125HZ = 1,
188}
189impl From<SAMPFREQ_A> for bool {
190 #[inline(always)]
191 fn from(variant: SAMPFREQ_A) -> Self {
192 variant as u8 != 0
193 }
194}
195#[doc = "Field `SAMPFREQ` reader - BOD Sample Frequency"]
196pub type SAMPFREQ_R = crate::attiny412pac::BitReader<SAMPFREQ_A>;
197impl SAMPFREQ_R {
198 #[doc = "Get enumerated values variant"]
199 #[inline(always)]
200 pub fn variant(&self) -> SAMPFREQ_A {
201 match self.bits {
202 false => SAMPFREQ_A::_1KHZ,
203 true => SAMPFREQ_A::_125HZ,
204 }
205 }
206 #[doc = "Checks if the value of the field is `_1KHZ`"]
207 #[inline(always)]
208 pub fn is_1khz(&self) -> bool {
209 *self == SAMPFREQ_A::_1KHZ
210 }
211 #[doc = "Checks if the value of the field is `_125HZ`"]
212 #[inline(always)]
213 pub fn is_125hz(&self) -> bool {
214 *self == SAMPFREQ_A::_125HZ
215 }
216}
217#[doc = "Field `SAMPFREQ` writer - BOD Sample Frequency"]
218pub type SAMPFREQ_W<'a, const O: u8> = crate::attiny412pac::BitWriter<'a, u8, BODCFG_SPEC, SAMPFREQ_A, O>;
219impl<'a, const O: u8> SAMPFREQ_W<'a, O> {
220 #[doc = "1kHz sampling frequency"]
221 #[inline(always)]
222 pub fn _1khz(self) -> &'a mut W {
223 self.variant(SAMPFREQ_A::_1KHZ)
224 }
225 #[doc = "125Hz sampling frequency"]
226 #[inline(always)]
227 pub fn _125hz(self) -> &'a mut W {
228 self.variant(SAMPFREQ_A::_125HZ)
229 }
230}
231#[doc = "BOD Level\n\nValue on reset: 0"]
232#[derive(Clone, Copy, Debug, PartialEq)]
233#[repr(u8)]
234pub enum LVL_A {
235 #[doc = "0: 1.8 V"]
236 BODLEVEL0 = 0,
237 #[doc = "1: 2.1 V"]
238 BODLEVEL1 = 1,
239 #[doc = "2: 2.6 V"]
240 BODLEVEL2 = 2,
241 #[doc = "3: 2.9 V"]
242 BODLEVEL3 = 3,
243 #[doc = "4: 3.3 V"]
244 BODLEVEL4 = 4,
245 #[doc = "5: 3.7 V"]
246 BODLEVEL5 = 5,
247 #[doc = "6: 4.0 V"]
248 BODLEVEL6 = 6,
249 #[doc = "7: 4.2 V"]
250 BODLEVEL7 = 7,
251}
252impl From<LVL_A> for u8 {
253 #[inline(always)]
254 fn from(variant: LVL_A) -> Self {
255 variant as _
256 }
257}
258#[doc = "Field `LVL` reader - BOD Level"]
259pub type LVL_R = crate::attiny412pac::FieldReader<u8, LVL_A>;
260impl LVL_R {
261 #[doc = "Get enumerated values variant"]
262 #[inline(always)]
263 pub fn variant(&self) -> LVL_A {
264 match self.bits {
265 0 => LVL_A::BODLEVEL0,
266 1 => LVL_A::BODLEVEL1,
267 2 => LVL_A::BODLEVEL2,
268 3 => LVL_A::BODLEVEL3,
269 4 => LVL_A::BODLEVEL4,
270 5 => LVL_A::BODLEVEL5,
271 6 => LVL_A::BODLEVEL6,
272 7 => LVL_A::BODLEVEL7,
273 _ => unreachable!(),
274 }
275 }
276 #[doc = "Checks if the value of the field is `BODLEVEL0`"]
277 #[inline(always)]
278 pub fn is_bodlevel0(&self) -> bool {
279 *self == LVL_A::BODLEVEL0
280 }
281 #[doc = "Checks if the value of the field is `BODLEVEL1`"]
282 #[inline(always)]
283 pub fn is_bodlevel1(&self) -> bool {
284 *self == LVL_A::BODLEVEL1
285 }
286 #[doc = "Checks if the value of the field is `BODLEVEL2`"]
287 #[inline(always)]
288 pub fn is_bodlevel2(&self) -> bool {
289 *self == LVL_A::BODLEVEL2
290 }
291 #[doc = "Checks if the value of the field is `BODLEVEL3`"]
292 #[inline(always)]
293 pub fn is_bodlevel3(&self) -> bool {
294 *self == LVL_A::BODLEVEL3
295 }
296 #[doc = "Checks if the value of the field is `BODLEVEL4`"]
297 #[inline(always)]
298 pub fn is_bodlevel4(&self) -> bool {
299 *self == LVL_A::BODLEVEL4
300 }
301 #[doc = "Checks if the value of the field is `BODLEVEL5`"]
302 #[inline(always)]
303 pub fn is_bodlevel5(&self) -> bool {
304 *self == LVL_A::BODLEVEL5
305 }
306 #[doc = "Checks if the value of the field is `BODLEVEL6`"]
307 #[inline(always)]
308 pub fn is_bodlevel6(&self) -> bool {
309 *self == LVL_A::BODLEVEL6
310 }
311 #[doc = "Checks if the value of the field is `BODLEVEL7`"]
312 #[inline(always)]
313 pub fn is_bodlevel7(&self) -> bool {
314 *self == LVL_A::BODLEVEL7
315 }
316}
317#[doc = "Field `LVL` writer - BOD Level"]
318pub type LVL_W<'a, const O: u8> = crate::attiny412pac::FieldWriterSafe<'a, u8, BODCFG_SPEC, u8, LVL_A, 3, O>;
319impl<'a, const O: u8> LVL_W<'a, O> {
320 #[doc = "1.8 V"]
321 #[inline(always)]
322 pub fn bodlevel0(self) -> &'a mut W {
323 self.variant(LVL_A::BODLEVEL0)
324 }
325 #[doc = "2.1 V"]
326 #[inline(always)]
327 pub fn bodlevel1(self) -> &'a mut W {
328 self.variant(LVL_A::BODLEVEL1)
329 }
330 #[doc = "2.6 V"]
331 #[inline(always)]
332 pub fn bodlevel2(self) -> &'a mut W {
333 self.variant(LVL_A::BODLEVEL2)
334 }
335 #[doc = "2.9 V"]
336 #[inline(always)]
337 pub fn bodlevel3(self) -> &'a mut W {
338 self.variant(LVL_A::BODLEVEL3)
339 }
340 #[doc = "3.3 V"]
341 #[inline(always)]
342 pub fn bodlevel4(self) -> &'a mut W {
343 self.variant(LVL_A::BODLEVEL4)
344 }
345 #[doc = "3.7 V"]
346 #[inline(always)]
347 pub fn bodlevel5(self) -> &'a mut W {
348 self.variant(LVL_A::BODLEVEL5)
349 }
350 #[doc = "4.0 V"]
351 #[inline(always)]
352 pub fn bodlevel6(self) -> &'a mut W {
353 self.variant(LVL_A::BODLEVEL6)
354 }
355 #[doc = "4.2 V"]
356 #[inline(always)]
357 pub fn bodlevel7(self) -> &'a mut W {
358 self.variant(LVL_A::BODLEVEL7)
359 }
360}
361impl R {
362 #[doc = "Bits 0:1 - BOD Operation in Sleep Mode"]
363 #[inline(always)]
364 pub fn sleep(&self) -> SLEEP_R {
365 SLEEP_R::new((self.bits & 3) as u8)
366 }
367 #[doc = "Bits 2:3 - BOD Operation in Active Mode"]
368 #[inline(always)]
369 pub fn active(&self) -> ACTIVE_R {
370 ACTIVE_R::new(((self.bits >> 2) & 3) as u8)
371 }
372 #[doc = "Bit 4 - BOD Sample Frequency"]
373 #[inline(always)]
374 pub fn sampfreq(&self) -> SAMPFREQ_R {
375 SAMPFREQ_R::new(((self.bits >> 4) & 1) != 0)
376 }
377 #[doc = "Bits 5:7 - BOD Level"]
378 #[inline(always)]
379 pub fn lvl(&self) -> LVL_R {
380 LVL_R::new(((self.bits >> 5) & 7) as u8)
381 }
382}
383impl W {
384 #[doc = "Bits 0:1 - BOD Operation in Sleep Mode"]
385 #[inline(always)]
386 pub fn sleep(&mut self) -> SLEEP_W<0> {
387 SLEEP_W::new(self)
388 }
389 #[doc = "Bits 2:3 - BOD Operation in Active Mode"]
390 #[inline(always)]
391 pub fn active(&mut self) -> ACTIVE_W<2> {
392 ACTIVE_W::new(self)
393 }
394 #[doc = "Bit 4 - BOD Sample Frequency"]
395 #[inline(always)]
396 pub fn sampfreq(&mut self) -> SAMPFREQ_W<4> {
397 SAMPFREQ_W::new(self)
398 }
399 #[doc = "Bits 5:7 - BOD Level"]
400 #[inline(always)]
401 pub fn lvl(&mut self) -> LVL_W<5> {
402 LVL_W::new(self)
403 }
404 #[doc = "Writes raw bits to the register."]
405 #[inline(always)]
406 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
407 self.0.bits(bits);
408 self
409 }
410}
411#[doc = "BOD Configuration\n\nThis register you can [`read`](crate::attiny412pac::generic::Reg::read), [`write_with_zero`](crate::attiny412pac::generic::Reg::write_with_zero), [`reset`](crate::attiny412pac::generic::Reg::reset), [`write`](crate::attiny412pac::generic::Reg::write), [`modify`](crate::attiny412pac::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [bodcfg](index.html) module"]
412pub struct BODCFG_SPEC;
413impl crate::attiny412pac::RegisterSpec for BODCFG_SPEC {
414 type Ux = u8;
415}
416#[doc = "`read()` method returns [bodcfg::R](R) reader structure"]
417impl crate::attiny412pac::Readable for BODCFG_SPEC {
418 type Reader = R;
419}
420#[doc = "`write(|w| ..)` method takes [bodcfg::W](W) writer structure"]
421impl crate::attiny412pac::Writable for BODCFG_SPEC {
422 type Writer = W;
423}
424#[doc = "`reset()` method sets BODCFG to value 0"]
425impl crate::attiny412pac::Resettable for BODCFG_SPEC {
426 #[inline(always)]
427 fn reset_value() -> Self::Ux {
428 0
429 }
430}