avr_device/devices/attiny85/cpu/
mcucr.rs

1#[doc = "Register `MCUCR` reader"]
2pub struct R(crate::R<MCUCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MCUCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MCUCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MCUCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MCUCR` writer"]
17pub struct W(crate::W<MCUCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MCUCR_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<MCUCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MCUCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BODSE` reader - BOD Sleep Enable (available on some devices)"]
38pub type BODSE_R = crate::BitReader<bool>;
39#[doc = "Field `BODSE` writer - BOD Sleep Enable (available on some devices)"]
40pub type BODSE_W<'a, const O: u8> = crate::BitWriter<'a, u8, MCUCR_SPEC, bool, O>;
41#[doc = "Field `SM` reader - Sleep Mode Select Bits"]
42pub type SM_R = crate::FieldReader<u8, SM_A>;
43#[doc = "Sleep Mode Select Bits\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum SM_A {
47    #[doc = "0: Idle"]
48    IDLE = 0,
49    #[doc = "1: ADC Noise Reduction (If Available)"]
50    ADC = 1,
51    #[doc = "2: Power Down"]
52    PDOWN = 2,
53    #[doc = "3: Reserved"]
54    VAL_0X03 = 3,
55}
56impl From<SM_A> for u8 {
57    #[inline(always)]
58    fn from(variant: SM_A) -> Self {
59        variant as _
60    }
61}
62impl SM_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> SM_A {
66        match self.bits {
67            0 => SM_A::IDLE,
68            1 => SM_A::ADC,
69            2 => SM_A::PDOWN,
70            3 => SM_A::VAL_0X03,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `IDLE`"]
75    #[inline(always)]
76    pub fn is_idle(&self) -> bool {
77        *self == SM_A::IDLE
78    }
79    #[doc = "Checks if the value of the field is `ADC`"]
80    #[inline(always)]
81    pub fn is_adc(&self) -> bool {
82        *self == SM_A::ADC
83    }
84    #[doc = "Checks if the value of the field is `PDOWN`"]
85    #[inline(always)]
86    pub fn is_pdown(&self) -> bool {
87        *self == SM_A::PDOWN
88    }
89    #[doc = "Checks if the value of the field is `VAL_0X03`"]
90    #[inline(always)]
91    pub fn is_val_0x03(&self) -> bool {
92        *self == SM_A::VAL_0X03
93    }
94}
95#[doc = "Field `SM` writer - Sleep Mode Select Bits"]
96pub type SM_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, MCUCR_SPEC, u8, SM_A, 2, O>;
97impl<'a, const O: u8> SM_W<'a, O> {
98    #[doc = "Idle"]
99    #[inline(always)]
100    pub fn idle(self) -> &'a mut W {
101        self.variant(SM_A::IDLE)
102    }
103    #[doc = "ADC Noise Reduction (If Available)"]
104    #[inline(always)]
105    pub fn adc(self) -> &'a mut W {
106        self.variant(SM_A::ADC)
107    }
108    #[doc = "Power Down"]
109    #[inline(always)]
110    pub fn pdown(self) -> &'a mut W {
111        self.variant(SM_A::PDOWN)
112    }
113    #[doc = "Reserved"]
114    #[inline(always)]
115    pub fn val_0x03(self) -> &'a mut W {
116        self.variant(SM_A::VAL_0X03)
117    }
118}
119#[doc = "Field `SE` reader - Sleep Enable"]
120pub type SE_R = crate::BitReader<bool>;
121#[doc = "Field `SE` writer - Sleep Enable"]
122pub type SE_W<'a, const O: u8> = crate::BitWriter<'a, u8, MCUCR_SPEC, bool, O>;
123#[doc = "Field `PUD` reader - Pull-up Disable"]
124pub type PUD_R = crate::BitReader<bool>;
125#[doc = "Field `PUD` writer - Pull-up Disable"]
126pub type PUD_W<'a, const O: u8> = crate::BitWriter<'a, u8, MCUCR_SPEC, bool, O>;
127#[doc = "Field `BODS` reader - BOD Sleep (available on some devices)"]
128pub type BODS_R = crate::BitReader<bool>;
129#[doc = "Field `BODS` writer - BOD Sleep (available on some devices)"]
130pub type BODS_W<'a, const O: u8> = crate::BitWriter<'a, u8, MCUCR_SPEC, bool, O>;
131impl R {
132    #[doc = "Bit 2 - BOD Sleep Enable (available on some devices)"]
133    #[inline(always)]
134    pub fn bodse(&self) -> BODSE_R {
135        BODSE_R::new(((self.bits >> 2) & 1) != 0)
136    }
137    #[doc = "Bits 3:4 - Sleep Mode Select Bits"]
138    #[inline(always)]
139    pub fn sm(&self) -> SM_R {
140        SM_R::new((self.bits >> 3) & 3)
141    }
142    #[doc = "Bit 5 - Sleep Enable"]
143    #[inline(always)]
144    pub fn se(&self) -> SE_R {
145        SE_R::new(((self.bits >> 5) & 1) != 0)
146    }
147    #[doc = "Bit 6 - Pull-up Disable"]
148    #[inline(always)]
149    pub fn pud(&self) -> PUD_R {
150        PUD_R::new(((self.bits >> 6) & 1) != 0)
151    }
152    #[doc = "Bit 7 - BOD Sleep (available on some devices)"]
153    #[inline(always)]
154    pub fn bods(&self) -> BODS_R {
155        BODS_R::new(((self.bits >> 7) & 1) != 0)
156    }
157}
158impl W {
159    #[doc = "Bit 2 - BOD Sleep Enable (available on some devices)"]
160    #[inline(always)]
161    #[must_use]
162    pub fn bodse(&mut self) -> BODSE_W<2> {
163        BODSE_W::new(self)
164    }
165    #[doc = "Bits 3:4 - Sleep Mode Select Bits"]
166    #[inline(always)]
167    #[must_use]
168    pub fn sm(&mut self) -> SM_W<3> {
169        SM_W::new(self)
170    }
171    #[doc = "Bit 5 - Sleep Enable"]
172    #[inline(always)]
173    #[must_use]
174    pub fn se(&mut self) -> SE_W<5> {
175        SE_W::new(self)
176    }
177    #[doc = "Bit 6 - Pull-up Disable"]
178    #[inline(always)]
179    #[must_use]
180    pub fn pud(&mut self) -> PUD_W<6> {
181        PUD_W::new(self)
182    }
183    #[doc = "Bit 7 - BOD Sleep (available on some devices)"]
184    #[inline(always)]
185    #[must_use]
186    pub fn bods(&mut self) -> BODS_W<7> {
187        BODS_W::new(self)
188    }
189    #[doc = "Writes raw bits to the register."]
190    #[inline(always)]
191    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
192        self.0.bits(bits);
193        self
194    }
195}
196#[doc = "MCU Control Register\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 [mcucr](index.html) module"]
197pub struct MCUCR_SPEC;
198impl crate::RegisterSpec for MCUCR_SPEC {
199    type Ux = u8;
200}
201#[doc = "`read()` method returns [mcucr::R](R) reader structure"]
202impl crate::Readable for MCUCR_SPEC {
203    type Reader = R;
204}
205#[doc = "`write(|w| ..)` method takes [mcucr::W](W) writer structure"]
206impl crate::Writable for MCUCR_SPEC {
207    type Writer = W;
208    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
209    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
210}
211#[doc = "`reset()` method sets MCUCR to value 0"]
212impl crate::Resettable for MCUCR_SPEC {
213    const RESET_VALUE: Self::Ux = 0;
214}