avr_device/devices/atmega2560/adc/
adcsra.rs1#[doc = "Register `ADCSRA` reader"]
2pub struct R(crate::R<ADCSRA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<ADCSRA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<ADCSRA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<ADCSRA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `ADCSRA` writer"]
17pub struct W(crate::W<ADCSRA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<ADCSRA_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<ADCSRA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<ADCSRA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `ADPS` reader - ADC Prescaler Select Bits"]
38pub type ADPS_R = crate::FieldReader<u8, ADPS_A>;
39#[doc = "ADC Prescaler Select Bits\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum ADPS_A {
43 #[doc = "1: Prescaler Value 2"]
44 PRESCALER_2 = 1,
45 #[doc = "2: Prescaler Value 4"]
46 PRESCALER_4 = 2,
47 #[doc = "3: Prescaler Value 8"]
48 PRESCALER_8 = 3,
49 #[doc = "4: Prescaler Value 16"]
50 PRESCALER_16 = 4,
51 #[doc = "5: Prescaler Value 32"]
52 PRESCALER_32 = 5,
53 #[doc = "6: Prescaler Value 64"]
54 PRESCALER_64 = 6,
55 #[doc = "7: Prescaler Value 128"]
56 PRESCALER_128 = 7,
57}
58impl From<ADPS_A> for u8 {
59 #[inline(always)]
60 fn from(variant: ADPS_A) -> Self {
61 variant as _
62 }
63}
64impl ADPS_R {
65 #[doc = "Get enumerated values variant"]
66 #[inline(always)]
67 pub fn variant(&self) -> Option<ADPS_A> {
68 match self.bits {
69 1 => Some(ADPS_A::PRESCALER_2),
70 2 => Some(ADPS_A::PRESCALER_4),
71 3 => Some(ADPS_A::PRESCALER_8),
72 4 => Some(ADPS_A::PRESCALER_16),
73 5 => Some(ADPS_A::PRESCALER_32),
74 6 => Some(ADPS_A::PRESCALER_64),
75 7 => Some(ADPS_A::PRESCALER_128),
76 _ => None,
77 }
78 }
79 #[doc = "Checks if the value of the field is `PRESCALER_2`"]
80 #[inline(always)]
81 pub fn is_prescaler_2(&self) -> bool {
82 *self == ADPS_A::PRESCALER_2
83 }
84 #[doc = "Checks if the value of the field is `PRESCALER_4`"]
85 #[inline(always)]
86 pub fn is_prescaler_4(&self) -> bool {
87 *self == ADPS_A::PRESCALER_4
88 }
89 #[doc = "Checks if the value of the field is `PRESCALER_8`"]
90 #[inline(always)]
91 pub fn is_prescaler_8(&self) -> bool {
92 *self == ADPS_A::PRESCALER_8
93 }
94 #[doc = "Checks if the value of the field is `PRESCALER_16`"]
95 #[inline(always)]
96 pub fn is_prescaler_16(&self) -> bool {
97 *self == ADPS_A::PRESCALER_16
98 }
99 #[doc = "Checks if the value of the field is `PRESCALER_32`"]
100 #[inline(always)]
101 pub fn is_prescaler_32(&self) -> bool {
102 *self == ADPS_A::PRESCALER_32
103 }
104 #[doc = "Checks if the value of the field is `PRESCALER_64`"]
105 #[inline(always)]
106 pub fn is_prescaler_64(&self) -> bool {
107 *self == ADPS_A::PRESCALER_64
108 }
109 #[doc = "Checks if the value of the field is `PRESCALER_128`"]
110 #[inline(always)]
111 pub fn is_prescaler_128(&self) -> bool {
112 *self == ADPS_A::PRESCALER_128
113 }
114}
115#[doc = "Field `ADPS` writer - ADC Prescaler Select Bits"]
116pub type ADPS_W<'a, const O: u8> = crate::FieldWriter<'a, u8, ADCSRA_SPEC, u8, ADPS_A, 3, O>;
117impl<'a, const O: u8> ADPS_W<'a, O> {
118 #[doc = "Prescaler Value 2"]
119 #[inline(always)]
120 pub fn prescaler_2(self) -> &'a mut W {
121 self.variant(ADPS_A::PRESCALER_2)
122 }
123 #[doc = "Prescaler Value 4"]
124 #[inline(always)]
125 pub fn prescaler_4(self) -> &'a mut W {
126 self.variant(ADPS_A::PRESCALER_4)
127 }
128 #[doc = "Prescaler Value 8"]
129 #[inline(always)]
130 pub fn prescaler_8(self) -> &'a mut W {
131 self.variant(ADPS_A::PRESCALER_8)
132 }
133 #[doc = "Prescaler Value 16"]
134 #[inline(always)]
135 pub fn prescaler_16(self) -> &'a mut W {
136 self.variant(ADPS_A::PRESCALER_16)
137 }
138 #[doc = "Prescaler Value 32"]
139 #[inline(always)]
140 pub fn prescaler_32(self) -> &'a mut W {
141 self.variant(ADPS_A::PRESCALER_32)
142 }
143 #[doc = "Prescaler Value 64"]
144 #[inline(always)]
145 pub fn prescaler_64(self) -> &'a mut W {
146 self.variant(ADPS_A::PRESCALER_64)
147 }
148 #[doc = "Prescaler Value 128"]
149 #[inline(always)]
150 pub fn prescaler_128(self) -> &'a mut W {
151 self.variant(ADPS_A::PRESCALER_128)
152 }
153}
154#[doc = "Field `ADIE` reader - ADC Interrupt Enable"]
155pub type ADIE_R = crate::BitReader<bool>;
156#[doc = "Field `ADIE` writer - ADC Interrupt Enable"]
157pub type ADIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRA_SPEC, bool, O>;
158#[doc = "Field `ADIF` reader - ADC Interrupt Flag"]
159pub type ADIF_R = crate::BitReader<bool>;
160#[doc = "Field `ADIF` writer - ADC Interrupt Flag"]
161pub type ADIF_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRA_SPEC, bool, O>;
162#[doc = "Field `ADATE` reader - ADC Auto Trigger Enable"]
163pub type ADATE_R = crate::BitReader<bool>;
164#[doc = "Field `ADATE` writer - ADC Auto Trigger Enable"]
165pub type ADATE_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRA_SPEC, bool, O>;
166#[doc = "Field `ADSC` reader - ADC Start Conversion"]
167pub type ADSC_R = crate::BitReader<bool>;
168#[doc = "Field `ADSC` writer - ADC Start Conversion"]
169pub type ADSC_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRA_SPEC, bool, O>;
170#[doc = "Field `ADEN` reader - ADC Enable"]
171pub type ADEN_R = crate::BitReader<bool>;
172#[doc = "Field `ADEN` writer - ADC Enable"]
173pub type ADEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADCSRA_SPEC, bool, O>;
174impl R {
175 #[doc = "Bits 0:2 - ADC Prescaler Select Bits"]
176 #[inline(always)]
177 pub fn adps(&self) -> ADPS_R {
178 ADPS_R::new(self.bits & 7)
179 }
180 #[doc = "Bit 3 - ADC Interrupt Enable"]
181 #[inline(always)]
182 pub fn adie(&self) -> ADIE_R {
183 ADIE_R::new(((self.bits >> 3) & 1) != 0)
184 }
185 #[doc = "Bit 4 - ADC Interrupt Flag"]
186 #[inline(always)]
187 pub fn adif(&self) -> ADIF_R {
188 ADIF_R::new(((self.bits >> 4) & 1) != 0)
189 }
190 #[doc = "Bit 5 - ADC Auto Trigger Enable"]
191 #[inline(always)]
192 pub fn adate(&self) -> ADATE_R {
193 ADATE_R::new(((self.bits >> 5) & 1) != 0)
194 }
195 #[doc = "Bit 6 - ADC Start Conversion"]
196 #[inline(always)]
197 pub fn adsc(&self) -> ADSC_R {
198 ADSC_R::new(((self.bits >> 6) & 1) != 0)
199 }
200 #[doc = "Bit 7 - ADC Enable"]
201 #[inline(always)]
202 pub fn aden(&self) -> ADEN_R {
203 ADEN_R::new(((self.bits >> 7) & 1) != 0)
204 }
205}
206impl W {
207 #[doc = "Bits 0:2 - ADC Prescaler Select Bits"]
208 #[inline(always)]
209 #[must_use]
210 pub fn adps(&mut self) -> ADPS_W<0> {
211 ADPS_W::new(self)
212 }
213 #[doc = "Bit 3 - ADC Interrupt Enable"]
214 #[inline(always)]
215 #[must_use]
216 pub fn adie(&mut self) -> ADIE_W<3> {
217 ADIE_W::new(self)
218 }
219 #[doc = "Bit 4 - ADC Interrupt Flag"]
220 #[inline(always)]
221 #[must_use]
222 pub fn adif(&mut self) -> ADIF_W<4> {
223 ADIF_W::new(self)
224 }
225 #[doc = "Bit 5 - ADC Auto Trigger Enable"]
226 #[inline(always)]
227 #[must_use]
228 pub fn adate(&mut self) -> ADATE_W<5> {
229 ADATE_W::new(self)
230 }
231 #[doc = "Bit 6 - ADC Start Conversion"]
232 #[inline(always)]
233 #[must_use]
234 pub fn adsc(&mut self) -> ADSC_W<6> {
235 ADSC_W::new(self)
236 }
237 #[doc = "Bit 7 - ADC Enable"]
238 #[inline(always)]
239 #[must_use]
240 pub fn aden(&mut self) -> ADEN_W<7> {
241 ADEN_W::new(self)
242 }
243 #[doc = "Writes raw bits to the register."]
244 #[inline(always)]
245 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
246 self.0.bits(bits);
247 self
248 }
249}
250#[doc = "The ADC Control and Status register 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 [adcsra](index.html) module"]
251pub struct ADCSRA_SPEC;
252impl crate::RegisterSpec for ADCSRA_SPEC {
253 type Ux = u8;
254}
255#[doc = "`read()` method returns [adcsra::R](R) reader structure"]
256impl crate::Readable for ADCSRA_SPEC {
257 type Reader = R;
258}
259#[doc = "`write(|w| ..)` method takes [adcsra::W](W) writer structure"]
260impl crate::Writable for ADCSRA_SPEC {
261 type Writer = W;
262 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
263 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
264}
265#[doc = "`reset()` method sets ADCSRA to value 0"]
266impl crate::Resettable for ADCSRA_SPEC {
267 const RESET_VALUE: Self::Ux = 0;
268}