avr_device/devices/atmega4809/fuse/
bodcfg.rs1#[doc = "Register `BODCFG` reader"]
2pub struct R(crate::R<BODCFG_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BODCFG_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BODCFG_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BODCFG_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BODCFG` writer"]
17pub struct W(crate::W<BODCFG_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::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::W<BODCFG_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BODCFG_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `SLEEP` reader - BOD Operation in Sleep Mode"]
38pub type SLEEP_R = crate::FieldReader<u8, SLEEP_A>;
39#[doc = "BOD Operation in Sleep Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum SLEEP_A {
43 #[doc = "0: Disabled"]
44 DIS = 0,
45 #[doc = "1: Enabled"]
46 ENABLED = 1,
47 #[doc = "2: Sampled"]
48 SAMPLED = 2,
49}
50impl From<SLEEP_A> for u8 {
51 #[inline(always)]
52 fn from(variant: SLEEP_A) -> Self {
53 variant as _
54 }
55}
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::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 = "Field `ACTIVE` reader - BOD Operation in Active Mode"]
103pub type ACTIVE_R = crate::FieldReader<u8, ACTIVE_A>;
104#[doc = "BOD Operation in Active Mode\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106#[repr(u8)]
107pub enum ACTIVE_A {
108 #[doc = "0: Disabled"]
109 DIS = 0,
110 #[doc = "1: Enabled"]
111 ENABLED = 1,
112 #[doc = "2: Sampled"]
113 SAMPLED = 2,
114 #[doc = "3: Enabled with wake-up halted until BOD is ready"]
115 ENWAKE = 3,
116}
117impl From<ACTIVE_A> for u8 {
118 #[inline(always)]
119 fn from(variant: ACTIVE_A) -> Self {
120 variant as _
121 }
122}
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::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 = "Field `SAMPFREQ` reader - BOD Sample Frequency"]
182pub type SAMPFREQ_R = crate::BitReader<SAMPFREQ_A>;
183#[doc = "BOD Sample Frequency\n\nValue on reset: 0"]
184#[derive(Clone, Copy, Debug, PartialEq, Eq)]
185pub enum SAMPFREQ_A {
186 #[doc = "0: 1kHz sampling frequency"]
187 _1KHZ = 0,
188 #[doc = "1: 125Hz sampling frequency"]
189 _125HZ = 1,
190}
191impl From<SAMPFREQ_A> for bool {
192 #[inline(always)]
193 fn from(variant: SAMPFREQ_A) -> Self {
194 variant as u8 != 0
195 }
196}
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::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 = "Field `LVL` reader - BOD Level"]
232pub type LVL_R = crate::FieldReader<u8, LVL_A>;
233#[doc = "BOD Level\n\nValue on reset: 0"]
234#[derive(Clone, Copy, Debug, PartialEq, Eq)]
235#[repr(u8)]
236pub enum LVL_A {
237 #[doc = "0: 1.8 V"]
238 BODLEVEL0 = 0,
239 #[doc = "2: 2.6 V"]
240 BODLEVEL2 = 2,
241 #[doc = "7: 4.2 V"]
242 BODLEVEL7 = 7,
243}
244impl From<LVL_A> for u8 {
245 #[inline(always)]
246 fn from(variant: LVL_A) -> Self {
247 variant as _
248 }
249}
250impl LVL_R {
251 #[doc = "Get enumerated values variant"]
252 #[inline(always)]
253 pub fn variant(&self) -> Option<LVL_A> {
254 match self.bits {
255 0 => Some(LVL_A::BODLEVEL0),
256 2 => Some(LVL_A::BODLEVEL2),
257 7 => Some(LVL_A::BODLEVEL7),
258 _ => None,
259 }
260 }
261 #[doc = "Checks if the value of the field is `BODLEVEL0`"]
262 #[inline(always)]
263 pub fn is_bodlevel0(&self) -> bool {
264 *self == LVL_A::BODLEVEL0
265 }
266 #[doc = "Checks if the value of the field is `BODLEVEL2`"]
267 #[inline(always)]
268 pub fn is_bodlevel2(&self) -> bool {
269 *self == LVL_A::BODLEVEL2
270 }
271 #[doc = "Checks if the value of the field is `BODLEVEL7`"]
272 #[inline(always)]
273 pub fn is_bodlevel7(&self) -> bool {
274 *self == LVL_A::BODLEVEL7
275 }
276}
277#[doc = "Field `LVL` writer - BOD Level"]
278pub type LVL_W<'a, const O: u8> = crate::FieldWriter<'a, u8, BODCFG_SPEC, u8, LVL_A, 3, O>;
279impl<'a, const O: u8> LVL_W<'a, O> {
280 #[doc = "1.8 V"]
281 #[inline(always)]
282 pub fn bodlevel0(self) -> &'a mut W {
283 self.variant(LVL_A::BODLEVEL0)
284 }
285 #[doc = "2.6 V"]
286 #[inline(always)]
287 pub fn bodlevel2(self) -> &'a mut W {
288 self.variant(LVL_A::BODLEVEL2)
289 }
290 #[doc = "4.2 V"]
291 #[inline(always)]
292 pub fn bodlevel7(self) -> &'a mut W {
293 self.variant(LVL_A::BODLEVEL7)
294 }
295}
296impl R {
297 #[doc = "Bits 0:1 - BOD Operation in Sleep Mode"]
298 #[inline(always)]
299 pub fn sleep(&self) -> SLEEP_R {
300 SLEEP_R::new(self.bits & 3)
301 }
302 #[doc = "Bits 2:3 - BOD Operation in Active Mode"]
303 #[inline(always)]
304 pub fn active(&self) -> ACTIVE_R {
305 ACTIVE_R::new((self.bits >> 2) & 3)
306 }
307 #[doc = "Bit 4 - BOD Sample Frequency"]
308 #[inline(always)]
309 pub fn sampfreq(&self) -> SAMPFREQ_R {
310 SAMPFREQ_R::new(((self.bits >> 4) & 1) != 0)
311 }
312 #[doc = "Bits 5:7 - BOD Level"]
313 #[inline(always)]
314 pub fn lvl(&self) -> LVL_R {
315 LVL_R::new((self.bits >> 5) & 7)
316 }
317}
318impl W {
319 #[doc = "Bits 0:1 - BOD Operation in Sleep Mode"]
320 #[inline(always)]
321 #[must_use]
322 pub fn sleep(&mut self) -> SLEEP_W<0> {
323 SLEEP_W::new(self)
324 }
325 #[doc = "Bits 2:3 - BOD Operation in Active Mode"]
326 #[inline(always)]
327 #[must_use]
328 pub fn active(&mut self) -> ACTIVE_W<2> {
329 ACTIVE_W::new(self)
330 }
331 #[doc = "Bit 4 - BOD Sample Frequency"]
332 #[inline(always)]
333 #[must_use]
334 pub fn sampfreq(&mut self) -> SAMPFREQ_W<4> {
335 SAMPFREQ_W::new(self)
336 }
337 #[doc = "Bits 5:7 - BOD Level"]
338 #[inline(always)]
339 #[must_use]
340 pub fn lvl(&mut self) -> LVL_W<5> {
341 LVL_W::new(self)
342 }
343 #[doc = "Writes raw bits to the register."]
344 #[inline(always)]
345 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
346 self.0.bits(bits);
347 self
348 }
349}
350#[doc = "BOD Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [bodcfg](index.html) module"]
351pub struct BODCFG_SPEC;
352impl crate::RegisterSpec for BODCFG_SPEC {
353 type Ux = u8;
354}
355#[doc = "`read()` method returns [bodcfg::R](R) reader structure"]
356impl crate::Readable for BODCFG_SPEC {
357 type Reader = R;
358}
359#[doc = "`write(|w| ..)` method takes [bodcfg::W](W) writer structure"]
360impl crate::Writable for BODCFG_SPEC {
361 type Writer = W;
362 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
363 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
364}
365#[doc = "`reset()` method sets BODCFG to value 0"]
366impl crate::Resettable for BODCFG_SPEC {
367 const RESET_VALUE: Self::Ux = 0;
368}