avr_device/devices/atmega4809/vref/
ctrla.rs

1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLA_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `AC0REFSEL` reader - AC0 reference select"]
38pub type AC0REFSEL_R = crate::FieldReader<u8, AC0REFSEL_A>;
39#[doc = "AC0 reference select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum AC0REFSEL_A {
43    #[doc = "0: Voltage reference at 0.55V"]
44    _0V55 = 0,
45    #[doc = "1: Voltage reference at 1.1V"]
46    _1V1 = 1,
47    #[doc = "2: Voltage reference at 2.5V"]
48    _2V5 = 2,
49    #[doc = "3: Voltage reference at 4.34V"]
50    _4V34 = 3,
51    #[doc = "4: Voltage reference at 1.5V"]
52    _1V5 = 4,
53    #[doc = "7: AVDD"]
54    AVDD = 7,
55}
56impl From<AC0REFSEL_A> for u8 {
57    #[inline(always)]
58    fn from(variant: AC0REFSEL_A) -> Self {
59        variant as _
60    }
61}
62impl AC0REFSEL_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<AC0REFSEL_A> {
66        match self.bits {
67            0 => Some(AC0REFSEL_A::_0V55),
68            1 => Some(AC0REFSEL_A::_1V1),
69            2 => Some(AC0REFSEL_A::_2V5),
70            3 => Some(AC0REFSEL_A::_4V34),
71            4 => Some(AC0REFSEL_A::_1V5),
72            7 => Some(AC0REFSEL_A::AVDD),
73            _ => None,
74        }
75    }
76    #[doc = "Checks if the value of the field is `_0V55`"]
77    #[inline(always)]
78    pub fn is_0v55(&self) -> bool {
79        *self == AC0REFSEL_A::_0V55
80    }
81    #[doc = "Checks if the value of the field is `_1V1`"]
82    #[inline(always)]
83    pub fn is_1v1(&self) -> bool {
84        *self == AC0REFSEL_A::_1V1
85    }
86    #[doc = "Checks if the value of the field is `_2V5`"]
87    #[inline(always)]
88    pub fn is_2v5(&self) -> bool {
89        *self == AC0REFSEL_A::_2V5
90    }
91    #[doc = "Checks if the value of the field is `_4V34`"]
92    #[inline(always)]
93    pub fn is_4v34(&self) -> bool {
94        *self == AC0REFSEL_A::_4V34
95    }
96    #[doc = "Checks if the value of the field is `_1V5`"]
97    #[inline(always)]
98    pub fn is_1v5(&self) -> bool {
99        *self == AC0REFSEL_A::_1V5
100    }
101    #[doc = "Checks if the value of the field is `AVDD`"]
102    #[inline(always)]
103    pub fn is_avdd(&self) -> bool {
104        *self == AC0REFSEL_A::AVDD
105    }
106}
107#[doc = "Field `AC0REFSEL` writer - AC0 reference select"]
108pub type AC0REFSEL_W<'a, const O: u8> =
109    crate::FieldWriter<'a, u8, CTRLA_SPEC, u8, AC0REFSEL_A, 3, O>;
110impl<'a, const O: u8> AC0REFSEL_W<'a, O> {
111    #[doc = "Voltage reference at 0.55V"]
112    #[inline(always)]
113    pub fn _0v55(self) -> &'a mut W {
114        self.variant(AC0REFSEL_A::_0V55)
115    }
116    #[doc = "Voltage reference at 1.1V"]
117    #[inline(always)]
118    pub fn _1v1(self) -> &'a mut W {
119        self.variant(AC0REFSEL_A::_1V1)
120    }
121    #[doc = "Voltage reference at 2.5V"]
122    #[inline(always)]
123    pub fn _2v5(self) -> &'a mut W {
124        self.variant(AC0REFSEL_A::_2V5)
125    }
126    #[doc = "Voltage reference at 4.34V"]
127    #[inline(always)]
128    pub fn _4v34(self) -> &'a mut W {
129        self.variant(AC0REFSEL_A::_4V34)
130    }
131    #[doc = "Voltage reference at 1.5V"]
132    #[inline(always)]
133    pub fn _1v5(self) -> &'a mut W {
134        self.variant(AC0REFSEL_A::_1V5)
135    }
136    #[doc = "AVDD"]
137    #[inline(always)]
138    pub fn avdd(self) -> &'a mut W {
139        self.variant(AC0REFSEL_A::AVDD)
140    }
141}
142#[doc = "Field `ADC0REFSEL` reader - ADC0 reference select"]
143pub type ADC0REFSEL_R = crate::FieldReader<u8, ADC0REFSEL_A>;
144#[doc = "ADC0 reference select\n\nValue on reset: 0"]
145#[derive(Clone, Copy, Debug, PartialEq, Eq)]
146#[repr(u8)]
147pub enum ADC0REFSEL_A {
148    #[doc = "0: Voltage reference at 0.55V"]
149    _0V55 = 0,
150    #[doc = "1: Voltage reference at 1.1V"]
151    _1V1 = 1,
152    #[doc = "2: Voltage reference at 2.5V"]
153    _2V5 = 2,
154    #[doc = "3: Voltage reference at 4.34V"]
155    _4V34 = 3,
156    #[doc = "4: Voltage reference at 1.5V"]
157    _1V5 = 4,
158}
159impl From<ADC0REFSEL_A> for u8 {
160    #[inline(always)]
161    fn from(variant: ADC0REFSEL_A) -> Self {
162        variant as _
163    }
164}
165impl ADC0REFSEL_R {
166    #[doc = "Get enumerated values variant"]
167    #[inline(always)]
168    pub fn variant(&self) -> Option<ADC0REFSEL_A> {
169        match self.bits {
170            0 => Some(ADC0REFSEL_A::_0V55),
171            1 => Some(ADC0REFSEL_A::_1V1),
172            2 => Some(ADC0REFSEL_A::_2V5),
173            3 => Some(ADC0REFSEL_A::_4V34),
174            4 => Some(ADC0REFSEL_A::_1V5),
175            _ => None,
176        }
177    }
178    #[doc = "Checks if the value of the field is `_0V55`"]
179    #[inline(always)]
180    pub fn is_0v55(&self) -> bool {
181        *self == ADC0REFSEL_A::_0V55
182    }
183    #[doc = "Checks if the value of the field is `_1V1`"]
184    #[inline(always)]
185    pub fn is_1v1(&self) -> bool {
186        *self == ADC0REFSEL_A::_1V1
187    }
188    #[doc = "Checks if the value of the field is `_2V5`"]
189    #[inline(always)]
190    pub fn is_2v5(&self) -> bool {
191        *self == ADC0REFSEL_A::_2V5
192    }
193    #[doc = "Checks if the value of the field is `_4V34`"]
194    #[inline(always)]
195    pub fn is_4v34(&self) -> bool {
196        *self == ADC0REFSEL_A::_4V34
197    }
198    #[doc = "Checks if the value of the field is `_1V5`"]
199    #[inline(always)]
200    pub fn is_1v5(&self) -> bool {
201        *self == ADC0REFSEL_A::_1V5
202    }
203}
204#[doc = "Field `ADC0REFSEL` writer - ADC0 reference select"]
205pub type ADC0REFSEL_W<'a, const O: u8> =
206    crate::FieldWriter<'a, u8, CTRLA_SPEC, u8, ADC0REFSEL_A, 3, O>;
207impl<'a, const O: u8> ADC0REFSEL_W<'a, O> {
208    #[doc = "Voltage reference at 0.55V"]
209    #[inline(always)]
210    pub fn _0v55(self) -> &'a mut W {
211        self.variant(ADC0REFSEL_A::_0V55)
212    }
213    #[doc = "Voltage reference at 1.1V"]
214    #[inline(always)]
215    pub fn _1v1(self) -> &'a mut W {
216        self.variant(ADC0REFSEL_A::_1V1)
217    }
218    #[doc = "Voltage reference at 2.5V"]
219    #[inline(always)]
220    pub fn _2v5(self) -> &'a mut W {
221        self.variant(ADC0REFSEL_A::_2V5)
222    }
223    #[doc = "Voltage reference at 4.34V"]
224    #[inline(always)]
225    pub fn _4v34(self) -> &'a mut W {
226        self.variant(ADC0REFSEL_A::_4V34)
227    }
228    #[doc = "Voltage reference at 1.5V"]
229    #[inline(always)]
230    pub fn _1v5(self) -> &'a mut W {
231        self.variant(ADC0REFSEL_A::_1V5)
232    }
233}
234impl R {
235    #[doc = "Bits 0:2 - AC0 reference select"]
236    #[inline(always)]
237    pub fn ac0refsel(&self) -> AC0REFSEL_R {
238        AC0REFSEL_R::new(self.bits & 7)
239    }
240    #[doc = "Bits 4:6 - ADC0 reference select"]
241    #[inline(always)]
242    pub fn adc0refsel(&self) -> ADC0REFSEL_R {
243        ADC0REFSEL_R::new((self.bits >> 4) & 7)
244    }
245}
246impl W {
247    #[doc = "Bits 0:2 - AC0 reference select"]
248    #[inline(always)]
249    #[must_use]
250    pub fn ac0refsel(&mut self) -> AC0REFSEL_W<0> {
251        AC0REFSEL_W::new(self)
252    }
253    #[doc = "Bits 4:6 - ADC0 reference select"]
254    #[inline(always)]
255    #[must_use]
256    pub fn adc0refsel(&mut self) -> ADC0REFSEL_W<4> {
257        ADC0REFSEL_W::new(self)
258    }
259    #[doc = "Writes raw bits to the register."]
260    #[inline(always)]
261    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
262        self.0.bits(bits);
263        self
264    }
265}
266#[doc = "Control A\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 [ctrla](index.html) module"]
267pub struct CTRLA_SPEC;
268impl crate::RegisterSpec for CTRLA_SPEC {
269    type Ux = u8;
270}
271#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
272impl crate::Readable for CTRLA_SPEC {
273    type Reader = R;
274}
275#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
276impl crate::Writable for CTRLA_SPEC {
277    type Writer = W;
278    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
279    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
280}
281#[doc = "`reset()` method sets CTRLA to value 0"]
282impl crate::Resettable for CTRLA_SPEC {
283    const RESET_VALUE: Self::Ux = 0;
284}