avr_device/devices/atmega32u4/fuse/
extended.rs

1#[doc = "Register `EXTENDED` reader"]
2pub struct R(crate::R<EXTENDED_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EXTENDED_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EXTENDED_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EXTENDED_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EXTENDED` writer"]
17pub struct W(crate::W<EXTENDED_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EXTENDED_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<EXTENDED_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EXTENDED_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BODLEVEL` reader - Brown-out Detector trigger level"]
38pub type BODLEVEL_R = crate::FieldReader<u8, BODLEVEL_A>;
39#[doc = "Brown-out Detector trigger level\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum BODLEVEL_A {
43    #[doc = "0: Brown-out detection at VCC=4.3 V"]
44    _4V3 = 0,
45    #[doc = "1: Brown-out detection at VCC=3.5 V"]
46    _3V5 = 1,
47    #[doc = "2: Brown-out detection at VCC=3.4 V"]
48    _3V4 = 2,
49    #[doc = "3: Brown-out detection at VCC=2.6 V"]
50    _2V6 = 3,
51    #[doc = "4: Brown-out detection at VCC=2.4 V"]
52    _2V4 = 4,
53    #[doc = "5: Brown-out detection at VCC=2.2 V"]
54    _2V2 = 5,
55    #[doc = "6: Brown-out detection at VCC=2.0 V"]
56    _2V0 = 6,
57    #[doc = "7: Brown-out detection disabled; \\[BODLEVEL=111\\]"]
58    DISABLED = 7,
59}
60impl From<BODLEVEL_A> for u8 {
61    #[inline(always)]
62    fn from(variant: BODLEVEL_A) -> Self {
63        variant as _
64    }
65}
66impl BODLEVEL_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> BODLEVEL_A {
70        match self.bits {
71            0 => BODLEVEL_A::_4V3,
72            1 => BODLEVEL_A::_3V5,
73            2 => BODLEVEL_A::_3V4,
74            3 => BODLEVEL_A::_2V6,
75            4 => BODLEVEL_A::_2V4,
76            5 => BODLEVEL_A::_2V2,
77            6 => BODLEVEL_A::_2V0,
78            7 => BODLEVEL_A::DISABLED,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_4V3`"]
83    #[inline(always)]
84    pub fn is_4v3(&self) -> bool {
85        *self == BODLEVEL_A::_4V3
86    }
87    #[doc = "Checks if the value of the field is `_3V5`"]
88    #[inline(always)]
89    pub fn is_3v5(&self) -> bool {
90        *self == BODLEVEL_A::_3V5
91    }
92    #[doc = "Checks if the value of the field is `_3V4`"]
93    #[inline(always)]
94    pub fn is_3v4(&self) -> bool {
95        *self == BODLEVEL_A::_3V4
96    }
97    #[doc = "Checks if the value of the field is `_2V6`"]
98    #[inline(always)]
99    pub fn is_2v6(&self) -> bool {
100        *self == BODLEVEL_A::_2V6
101    }
102    #[doc = "Checks if the value of the field is `_2V4`"]
103    #[inline(always)]
104    pub fn is_2v4(&self) -> bool {
105        *self == BODLEVEL_A::_2V4
106    }
107    #[doc = "Checks if the value of the field is `_2V2`"]
108    #[inline(always)]
109    pub fn is_2v2(&self) -> bool {
110        *self == BODLEVEL_A::_2V2
111    }
112    #[doc = "Checks if the value of the field is `_2V0`"]
113    #[inline(always)]
114    pub fn is_2v0(&self) -> bool {
115        *self == BODLEVEL_A::_2V0
116    }
117    #[doc = "Checks if the value of the field is `DISABLED`"]
118    #[inline(always)]
119    pub fn is_disabled(&self) -> bool {
120        *self == BODLEVEL_A::DISABLED
121    }
122}
123#[doc = "Field `BODLEVEL` writer - Brown-out Detector trigger level"]
124pub type BODLEVEL_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u8, EXTENDED_SPEC, u8, BODLEVEL_A, 3, O>;
126impl<'a, const O: u8> BODLEVEL_W<'a, O> {
127    #[doc = "Brown-out detection at VCC=4.3 V"]
128    #[inline(always)]
129    pub fn _4v3(self) -> &'a mut W {
130        self.variant(BODLEVEL_A::_4V3)
131    }
132    #[doc = "Brown-out detection at VCC=3.5 V"]
133    #[inline(always)]
134    pub fn _3v5(self) -> &'a mut W {
135        self.variant(BODLEVEL_A::_3V5)
136    }
137    #[doc = "Brown-out detection at VCC=3.4 V"]
138    #[inline(always)]
139    pub fn _3v4(self) -> &'a mut W {
140        self.variant(BODLEVEL_A::_3V4)
141    }
142    #[doc = "Brown-out detection at VCC=2.6 V"]
143    #[inline(always)]
144    pub fn _2v6(self) -> &'a mut W {
145        self.variant(BODLEVEL_A::_2V6)
146    }
147    #[doc = "Brown-out detection at VCC=2.4 V"]
148    #[inline(always)]
149    pub fn _2v4(self) -> &'a mut W {
150        self.variant(BODLEVEL_A::_2V4)
151    }
152    #[doc = "Brown-out detection at VCC=2.2 V"]
153    #[inline(always)]
154    pub fn _2v2(self) -> &'a mut W {
155        self.variant(BODLEVEL_A::_2V2)
156    }
157    #[doc = "Brown-out detection at VCC=2.0 V"]
158    #[inline(always)]
159    pub fn _2v0(self) -> &'a mut W {
160        self.variant(BODLEVEL_A::_2V0)
161    }
162    #[doc = "Brown-out detection disabled; \\[BODLEVEL=111\\]"]
163    #[inline(always)]
164    pub fn disabled(self) -> &'a mut W {
165        self.variant(BODLEVEL_A::DISABLED)
166    }
167}
168#[doc = "Field `HWBE` reader - Hardware Boot Enable"]
169pub type HWBE_R = crate::BitReader<bool>;
170#[doc = "Field `HWBE` writer - Hardware Boot Enable"]
171pub type HWBE_W<'a, const O: u8> = crate::BitWriter<'a, u8, EXTENDED_SPEC, bool, O>;
172impl R {
173    #[doc = "Bits 0:2 - Brown-out Detector trigger level"]
174    #[inline(always)]
175    pub fn bodlevel(&self) -> BODLEVEL_R {
176        BODLEVEL_R::new(self.bits & 7)
177    }
178    #[doc = "Bit 3 - Hardware Boot Enable"]
179    #[inline(always)]
180    pub fn hwbe(&self) -> HWBE_R {
181        HWBE_R::new(((self.bits >> 3) & 1) != 0)
182    }
183}
184impl W {
185    #[doc = "Bits 0:2 - Brown-out Detector trigger level"]
186    #[inline(always)]
187    #[must_use]
188    pub fn bodlevel(&mut self) -> BODLEVEL_W<0> {
189        BODLEVEL_W::new(self)
190    }
191    #[doc = "Bit 3 - Hardware Boot Enable"]
192    #[inline(always)]
193    #[must_use]
194    pub fn hwbe(&mut self) -> HWBE_W<3> {
195        HWBE_W::new(self)
196    }
197    #[doc = "Writes raw bits to the register."]
198    #[inline(always)]
199    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
200        self.0.bits(bits);
201        self
202    }
203}
204#[doc = "No Description.\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 [extended](index.html) module"]
205pub struct EXTENDED_SPEC;
206impl crate::RegisterSpec for EXTENDED_SPEC {
207    type Ux = u8;
208}
209#[doc = "`read()` method returns [extended::R](R) reader structure"]
210impl crate::Readable for EXTENDED_SPEC {
211    type Reader = R;
212}
213#[doc = "`write(|w| ..)` method takes [extended::W](W) writer structure"]
214impl crate::Writable for EXTENDED_SPEC {
215    type Writer = W;
216    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
217    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
218}
219#[doc = "`reset()` method sets EXTENDED to value 0"]
220impl crate::Resettable for EXTENDED_SPEC {
221    const RESET_VALUE: Self::Ux = 0;
222}