eos_s3/adc/
adc_control.rs1#[doc = "Register `ADC_Control` reader"]
2pub struct R(crate::R<ADC_CONTROL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<ADC_CONTROL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<ADC_CONTROL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<ADC_CONTROL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `ADC_Control` writer"]
17pub struct W(crate::W<ADC_CONTROL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<ADC_CONTROL_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<ADC_CONTROL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<ADC_CONTROL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Asynchronous start-of-conversion. Needs to rise and be held high for each conversion\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum SOC_A {
40 #[doc = "0: Stop conversion"]
41 STOP = 0,
42 #[doc = "1: Start conversion. Needs to be held high until EOC is valid"]
43 START = 1,
44}
45impl From<SOC_A> for bool {
46 #[inline(always)]
47 fn from(variant: SOC_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `SOC` reader - Asynchronous start-of-conversion. Needs to rise and be held high for each conversion"]
52pub struct SOC_R(crate::FieldReader<bool, SOC_A>);
53impl SOC_R {
54 #[inline(always)]
55 pub(crate) fn new(bits: bool) -> Self {
56 SOC_R(crate::FieldReader::new(bits))
57 }
58 #[doc = r"Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> SOC_A {
61 match self.bits {
62 false => SOC_A::STOP,
63 true => SOC_A::START,
64 }
65 }
66 #[doc = "Checks if the value of the field is `STOP`"]
67 #[inline(always)]
68 pub fn is_stop(&self) -> bool {
69 **self == SOC_A::STOP
70 }
71 #[doc = "Checks if the value of the field is `START`"]
72 #[inline(always)]
73 pub fn is_start(&self) -> bool {
74 **self == SOC_A::START
75 }
76}
77impl core::ops::Deref for SOC_R {
78 type Target = crate::FieldReader<bool, SOC_A>;
79 #[inline(always)]
80 fn deref(&self) -> &Self::Target {
81 &self.0
82 }
83}
84#[doc = "Field `SOC` writer - Asynchronous start-of-conversion. Needs to rise and be held high for each conversion"]
85pub struct SOC_W<'a> {
86 w: &'a mut W,
87}
88impl<'a> SOC_W<'a> {
89 #[doc = r"Writes `variant` to the field"]
90 #[inline(always)]
91 pub fn variant(self, variant: SOC_A) -> &'a mut W {
92 self.bit(variant.into())
93 }
94 #[doc = "Stop conversion"]
95 #[inline(always)]
96 pub fn stop(self) -> &'a mut W {
97 self.variant(SOC_A::STOP)
98 }
99 #[doc = "Start conversion. Needs to be held high until EOC is valid"]
100 #[inline(always)]
101 pub fn start(self) -> &'a mut W {
102 self.variant(SOC_A::START)
103 }
104 #[doc = r"Sets the field bit"]
105 #[inline(always)]
106 pub fn set_bit(self) -> &'a mut W {
107 self.bit(true)
108 }
109 #[doc = r"Clears the field bit"]
110 #[inline(always)]
111 pub fn clear_bit(self) -> &'a mut W {
112 self.bit(false)
113 }
114 #[doc = r"Writes raw bits to the field"]
115 #[inline(always)]
116 pub fn bit(self, value: bool) -> &'a mut W {
117 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118 self.w
119 }
120}
121#[doc = "Channel Selection. 0 = CH0, 1 = CH1\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum SEL_A {
124 #[doc = "0: Select channel 0"]
125 SELECT_CH0 = 0,
126 #[doc = "1: Select channel 1"]
127 SELECT_CH1 = 1,
128}
129impl From<SEL_A> for bool {
130 #[inline(always)]
131 fn from(variant: SEL_A) -> Self {
132 variant as u8 != 0
133 }
134}
135#[doc = "Field `SEL` reader - Channel Selection. 0 = CH0, 1 = CH1"]
136pub struct SEL_R(crate::FieldReader<bool, SEL_A>);
137impl SEL_R {
138 #[inline(always)]
139 pub(crate) fn new(bits: bool) -> Self {
140 SEL_R(crate::FieldReader::new(bits))
141 }
142 #[doc = r"Get enumerated values variant"]
143 #[inline(always)]
144 pub fn variant(&self) -> SEL_A {
145 match self.bits {
146 false => SEL_A::SELECT_CH0,
147 true => SEL_A::SELECT_CH1,
148 }
149 }
150 #[doc = "Checks if the value of the field is `SELECT_CH0`"]
151 #[inline(always)]
152 pub fn is_select_ch0(&self) -> bool {
153 **self == SEL_A::SELECT_CH0
154 }
155 #[doc = "Checks if the value of the field is `SELECT_CH1`"]
156 #[inline(always)]
157 pub fn is_select_ch1(&self) -> bool {
158 **self == SEL_A::SELECT_CH1
159 }
160}
161impl core::ops::Deref for SEL_R {
162 type Target = crate::FieldReader<bool, SEL_A>;
163 #[inline(always)]
164 fn deref(&self) -> &Self::Target {
165 &self.0
166 }
167}
168#[doc = "Field `SEL` writer - Channel Selection. 0 = CH0, 1 = CH1"]
169pub struct SEL_W<'a> {
170 w: &'a mut W,
171}
172impl<'a> SEL_W<'a> {
173 #[doc = r"Writes `variant` to the field"]
174 #[inline(always)]
175 pub fn variant(self, variant: SEL_A) -> &'a mut W {
176 self.bit(variant.into())
177 }
178 #[doc = "Select channel 0"]
179 #[inline(always)]
180 pub fn select_ch0(self) -> &'a mut W {
181 self.variant(SEL_A::SELECT_CH0)
182 }
183 #[doc = "Select channel 1"]
184 #[inline(always)]
185 pub fn select_ch1(self) -> &'a mut W {
186 self.variant(SEL_A::SELECT_CH1)
187 }
188 #[doc = r"Sets the field bit"]
189 #[inline(always)]
190 pub fn set_bit(self) -> &'a mut W {
191 self.bit(true)
192 }
193 #[doc = r"Clears the field bit"]
194 #[inline(always)]
195 pub fn clear_bit(self) -> &'a mut W {
196 self.bit(false)
197 }
198 #[doc = r"Writes raw bits to the field"]
199 #[inline(always)]
200 pub fn bit(self, value: bool) -> &'a mut W {
201 self.w.bits =
202 (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
203 self.w
204 }
205}
206#[doc = "Battery measurement enable\n\nValue on reset: 0"]
207#[derive(Clone, Copy, Debug, PartialEq)]
208pub enum BAT_A {
209 #[doc = "0: Disables battery measurement"]
210 DISABLE = 0,
211 #[doc = "1: Enables battery measurement"]
212 ENABLE = 1,
213}
214impl From<BAT_A> for bool {
215 #[inline(always)]
216 fn from(variant: BAT_A) -> Self {
217 variant as u8 != 0
218 }
219}
220#[doc = "Field `BAT` reader - Battery measurement enable"]
221pub struct BAT_R(crate::FieldReader<bool, BAT_A>);
222impl BAT_R {
223 #[inline(always)]
224 pub(crate) fn new(bits: bool) -> Self {
225 BAT_R(crate::FieldReader::new(bits))
226 }
227 #[doc = r"Get enumerated values variant"]
228 #[inline(always)]
229 pub fn variant(&self) -> BAT_A {
230 match self.bits {
231 false => BAT_A::DISABLE,
232 true => BAT_A::ENABLE,
233 }
234 }
235 #[doc = "Checks if the value of the field is `DISABLE`"]
236 #[inline(always)]
237 pub fn is_disable(&self) -> bool {
238 **self == BAT_A::DISABLE
239 }
240 #[doc = "Checks if the value of the field is `ENABLE`"]
241 #[inline(always)]
242 pub fn is_enable(&self) -> bool {
243 **self == BAT_A::ENABLE
244 }
245}
246impl core::ops::Deref for BAT_R {
247 type Target = crate::FieldReader<bool, BAT_A>;
248 #[inline(always)]
249 fn deref(&self) -> &Self::Target {
250 &self.0
251 }
252}
253#[doc = "Field `BAT` writer - Battery measurement enable"]
254pub struct BAT_W<'a> {
255 w: &'a mut W,
256}
257impl<'a> BAT_W<'a> {
258 #[doc = r"Writes `variant` to the field"]
259 #[inline(always)]
260 pub fn variant(self, variant: BAT_A) -> &'a mut W {
261 self.bit(variant.into())
262 }
263 #[doc = "Disables battery measurement"]
264 #[inline(always)]
265 pub fn disable(self) -> &'a mut W {
266 self.variant(BAT_A::DISABLE)
267 }
268 #[doc = "Enables battery measurement"]
269 #[inline(always)]
270 pub fn enable(self) -> &'a mut W {
271 self.variant(BAT_A::ENABLE)
272 }
273 #[doc = r"Sets the field bit"]
274 #[inline(always)]
275 pub fn set_bit(self) -> &'a mut W {
276 self.bit(true)
277 }
278 #[doc = r"Clears the field bit"]
279 #[inline(always)]
280 pub fn clear_bit(self) -> &'a mut W {
281 self.bit(false)
282 }
283 #[doc = r"Writes raw bits to the field"]
284 #[inline(always)]
285 pub fn bit(self, value: bool) -> &'a mut W {
286 self.w.bits =
287 (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
288 self.w
289 }
290}
291impl R {
292 #[doc = "Bit 0 - Asynchronous start-of-conversion. Needs to rise and be held high for each conversion"]
293 #[inline(always)]
294 pub fn soc(&self) -> SOC_R {
295 SOC_R::new((self.bits & 0x01) != 0)
296 }
297 #[doc = "Bit 1 - Channel Selection. 0 = CH0, 1 = CH1"]
298 #[inline(always)]
299 pub fn sel(&self) -> SEL_R {
300 SEL_R::new(((self.bits >> 1) & 0x01) != 0)
301 }
302 #[doc = "Bit 2 - Battery measurement enable"]
303 #[inline(always)]
304 pub fn bat(&self) -> BAT_R {
305 BAT_R::new(((self.bits >> 2) & 0x01) != 0)
306 }
307}
308impl W {
309 #[doc = "Bit 0 - Asynchronous start-of-conversion. Needs to rise and be held high for each conversion"]
310 #[inline(always)]
311 pub fn soc(&mut self) -> SOC_W {
312 SOC_W { w: self }
313 }
314 #[doc = "Bit 1 - Channel Selection. 0 = CH0, 1 = CH1"]
315 #[inline(always)]
316 pub fn sel(&mut self) -> SEL_W {
317 SEL_W { w: self }
318 }
319 #[doc = "Bit 2 - Battery measurement enable"]
320 #[inline(always)]
321 pub fn bat(&mut self) -> BAT_W {
322 BAT_W { w: self }
323 }
324 #[doc = "Writes raw bits to the register."]
325 #[inline(always)]
326 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
327 self.0.bits(bits);
328 self
329 }
330}
331#[doc = "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 [adc_control](index.html) module"]
332pub struct ADC_CONTROL_SPEC;
333impl crate::RegisterSpec for ADC_CONTROL_SPEC {
334 type Ux = u32;
335}
336#[doc = "`read()` method returns [adc_control::R](R) reader structure"]
337impl crate::Readable for ADC_CONTROL_SPEC {
338 type Reader = R;
339}
340#[doc = "`write(|w| ..)` method takes [adc_control::W](W) writer structure"]
341impl crate::Writable for ADC_CONTROL_SPEC {
342 type Writer = W;
343}
344#[doc = "`reset()` method sets ADC_Control to value 0"]
345impl crate::Resettable for ADC_CONTROL_SPEC {
346 #[inline(always)]
347 fn reset_value() -> Self::Ux {
348 0
349 }
350}