ra2e1/adc120/
adcer.rs

1#[doc = "Register `ADCER` reader"]
2pub struct R(crate::R<ADCER_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ADCER_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ADCER_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ADCER_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ADCER` writer"]
17pub struct W(crate::W<ADCER_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ADCER_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<ADCER_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ADCER_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ACE` reader - A/D Data Register Automatic Clearing Enable"]
38pub type ACE_R = crate::BitReader<ACE_A>;
39#[doc = "A/D Data Register Automatic Clearing Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum ACE_A {
42    #[doc = "0: Disable automatic clearing"]
43    _0 = 0,
44    #[doc = "1: Enable automatic clearing"]
45    _1 = 1,
46}
47impl From<ACE_A> for bool {
48    #[inline(always)]
49    fn from(variant: ACE_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl ACE_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> ACE_A {
57        match self.bits {
58            false => ACE_A::_0,
59            true => ACE_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == ACE_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == ACE_A::_1
71    }
72}
73#[doc = "Field `ACE` writer - A/D Data Register Automatic Clearing Enable"]
74pub type ACE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCER_SPEC, ACE_A, O>;
75impl<'a, const O: u8> ACE_W<'a, O> {
76    #[doc = "Disable automatic clearing"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(ACE_A::_0)
80    }
81    #[doc = "Enable automatic clearing"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(ACE_A::_1)
85    }
86}
87#[doc = "Field `DIAGVAL` reader - Self-Diagnosis Conversion Voltage Select"]
88pub type DIAGVAL_R = crate::FieldReader<u8, DIAGVAL_A>;
89#[doc = "Self-Diagnosis Conversion Voltage Select\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum DIAGVAL_A {
93    #[doc = "0: Setting prohibited when self-diagnosis is enabled"]
94    _00 = 0,
95    #[doc = "1: 0 volts"]
96    _01 = 1,
97    #[doc = "2: Reference power supply voltage × 1/2"]
98    _10 = 2,
99    #[doc = "3: Reference power supply voltage"]
100    _11 = 3,
101}
102impl From<DIAGVAL_A> for u8 {
103    #[inline(always)]
104    fn from(variant: DIAGVAL_A) -> Self {
105        variant as _
106    }
107}
108impl DIAGVAL_R {
109    #[doc = "Get enumerated values variant"]
110    #[inline(always)]
111    pub fn variant(&self) -> DIAGVAL_A {
112        match self.bits {
113            0 => DIAGVAL_A::_00,
114            1 => DIAGVAL_A::_01,
115            2 => DIAGVAL_A::_10,
116            3 => DIAGVAL_A::_11,
117            _ => unreachable!(),
118        }
119    }
120    #[doc = "Checks if the value of the field is `_00`"]
121    #[inline(always)]
122    pub fn is_00(&self) -> bool {
123        *self == DIAGVAL_A::_00
124    }
125    #[doc = "Checks if the value of the field is `_01`"]
126    #[inline(always)]
127    pub fn is_01(&self) -> bool {
128        *self == DIAGVAL_A::_01
129    }
130    #[doc = "Checks if the value of the field is `_10`"]
131    #[inline(always)]
132    pub fn is_10(&self) -> bool {
133        *self == DIAGVAL_A::_10
134    }
135    #[doc = "Checks if the value of the field is `_11`"]
136    #[inline(always)]
137    pub fn is_11(&self) -> bool {
138        *self == DIAGVAL_A::_11
139    }
140}
141#[doc = "Field `DIAGVAL` writer - Self-Diagnosis Conversion Voltage Select"]
142pub type DIAGVAL_W<'a, const O: u8> =
143    crate::FieldWriterSafe<'a, u16, ADCER_SPEC, u8, DIAGVAL_A, 2, O>;
144impl<'a, const O: u8> DIAGVAL_W<'a, O> {
145    #[doc = "Setting prohibited when self-diagnosis is enabled"]
146    #[inline(always)]
147    pub fn _00(self) -> &'a mut W {
148        self.variant(DIAGVAL_A::_00)
149    }
150    #[doc = "0 volts"]
151    #[inline(always)]
152    pub fn _01(self) -> &'a mut W {
153        self.variant(DIAGVAL_A::_01)
154    }
155    #[doc = "Reference power supply voltage × 1/2"]
156    #[inline(always)]
157    pub fn _10(self) -> &'a mut W {
158        self.variant(DIAGVAL_A::_10)
159    }
160    #[doc = "Reference power supply voltage"]
161    #[inline(always)]
162    pub fn _11(self) -> &'a mut W {
163        self.variant(DIAGVAL_A::_11)
164    }
165}
166#[doc = "Field `DIAGLD` reader - Self-Diagnosis Mode Select"]
167pub type DIAGLD_R = crate::BitReader<DIAGLD_A>;
168#[doc = "Self-Diagnosis Mode Select\n\nValue on reset: 0"]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170pub enum DIAGLD_A {
171    #[doc = "0: Select rotation mode for self-diagnosis voltage"]
172    _0 = 0,
173    #[doc = "1: Select mixed mode for self-diagnosis voltage"]
174    _1 = 1,
175}
176impl From<DIAGLD_A> for bool {
177    #[inline(always)]
178    fn from(variant: DIAGLD_A) -> Self {
179        variant as u8 != 0
180    }
181}
182impl DIAGLD_R {
183    #[doc = "Get enumerated values variant"]
184    #[inline(always)]
185    pub fn variant(&self) -> DIAGLD_A {
186        match self.bits {
187            false => DIAGLD_A::_0,
188            true => DIAGLD_A::_1,
189        }
190    }
191    #[doc = "Checks if the value of the field is `_0`"]
192    #[inline(always)]
193    pub fn is_0(&self) -> bool {
194        *self == DIAGLD_A::_0
195    }
196    #[doc = "Checks if the value of the field is `_1`"]
197    #[inline(always)]
198    pub fn is_1(&self) -> bool {
199        *self == DIAGLD_A::_1
200    }
201}
202#[doc = "Field `DIAGLD` writer - Self-Diagnosis Mode Select"]
203pub type DIAGLD_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCER_SPEC, DIAGLD_A, O>;
204impl<'a, const O: u8> DIAGLD_W<'a, O> {
205    #[doc = "Select rotation mode for self-diagnosis voltage"]
206    #[inline(always)]
207    pub fn _0(self) -> &'a mut W {
208        self.variant(DIAGLD_A::_0)
209    }
210    #[doc = "Select mixed mode for self-diagnosis voltage"]
211    #[inline(always)]
212    pub fn _1(self) -> &'a mut W {
213        self.variant(DIAGLD_A::_1)
214    }
215}
216#[doc = "Field `DIAGM` reader - Self-Diagnosis Enable"]
217pub type DIAGM_R = crate::BitReader<DIAGM_A>;
218#[doc = "Self-Diagnosis Enable\n\nValue on reset: 0"]
219#[derive(Clone, Copy, Debug, PartialEq, Eq)]
220pub enum DIAGM_A {
221    #[doc = "0: Disable ADC12 self-diagnosis"]
222    _0 = 0,
223    #[doc = "1: Enable ADC12 self-diagnosis"]
224    _1 = 1,
225}
226impl From<DIAGM_A> for bool {
227    #[inline(always)]
228    fn from(variant: DIAGM_A) -> Self {
229        variant as u8 != 0
230    }
231}
232impl DIAGM_R {
233    #[doc = "Get enumerated values variant"]
234    #[inline(always)]
235    pub fn variant(&self) -> DIAGM_A {
236        match self.bits {
237            false => DIAGM_A::_0,
238            true => DIAGM_A::_1,
239        }
240    }
241    #[doc = "Checks if the value of the field is `_0`"]
242    #[inline(always)]
243    pub fn is_0(&self) -> bool {
244        *self == DIAGM_A::_0
245    }
246    #[doc = "Checks if the value of the field is `_1`"]
247    #[inline(always)]
248    pub fn is_1(&self) -> bool {
249        *self == DIAGM_A::_1
250    }
251}
252#[doc = "Field `DIAGM` writer - Self-Diagnosis Enable"]
253pub type DIAGM_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCER_SPEC, DIAGM_A, O>;
254impl<'a, const O: u8> DIAGM_W<'a, O> {
255    #[doc = "Disable ADC12 self-diagnosis"]
256    #[inline(always)]
257    pub fn _0(self) -> &'a mut W {
258        self.variant(DIAGM_A::_0)
259    }
260    #[doc = "Enable ADC12 self-diagnosis"]
261    #[inline(always)]
262    pub fn _1(self) -> &'a mut W {
263        self.variant(DIAGM_A::_1)
264    }
265}
266#[doc = "Field `ADRFMT` reader - A/D Data Register Format Select"]
267pub type ADRFMT_R = crate::BitReader<ADRFMT_A>;
268#[doc = "A/D Data Register Format Select\n\nValue on reset: 0"]
269#[derive(Clone, Copy, Debug, PartialEq, Eq)]
270pub enum ADRFMT_A {
271    #[doc = "0: Select right-justified for the A/D data register format"]
272    _0 = 0,
273    #[doc = "1: Select left-justified for the A/D data register format"]
274    _1 = 1,
275}
276impl From<ADRFMT_A> for bool {
277    #[inline(always)]
278    fn from(variant: ADRFMT_A) -> Self {
279        variant as u8 != 0
280    }
281}
282impl ADRFMT_R {
283    #[doc = "Get enumerated values variant"]
284    #[inline(always)]
285    pub fn variant(&self) -> ADRFMT_A {
286        match self.bits {
287            false => ADRFMT_A::_0,
288            true => ADRFMT_A::_1,
289        }
290    }
291    #[doc = "Checks if the value of the field is `_0`"]
292    #[inline(always)]
293    pub fn is_0(&self) -> bool {
294        *self == ADRFMT_A::_0
295    }
296    #[doc = "Checks if the value of the field is `_1`"]
297    #[inline(always)]
298    pub fn is_1(&self) -> bool {
299        *self == ADRFMT_A::_1
300    }
301}
302#[doc = "Field `ADRFMT` writer - A/D Data Register Format Select"]
303pub type ADRFMT_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCER_SPEC, ADRFMT_A, O>;
304impl<'a, const O: u8> ADRFMT_W<'a, O> {
305    #[doc = "Select right-justified for the A/D data register format"]
306    #[inline(always)]
307    pub fn _0(self) -> &'a mut W {
308        self.variant(ADRFMT_A::_0)
309    }
310    #[doc = "Select left-justified for the A/D data register format"]
311    #[inline(always)]
312    pub fn _1(self) -> &'a mut W {
313        self.variant(ADRFMT_A::_1)
314    }
315}
316impl R {
317    #[doc = "Bit 5 - A/D Data Register Automatic Clearing Enable"]
318    #[inline(always)]
319    pub fn ace(&self) -> ACE_R {
320        ACE_R::new(((self.bits >> 5) & 1) != 0)
321    }
322    #[doc = "Bits 8:9 - Self-Diagnosis Conversion Voltage Select"]
323    #[inline(always)]
324    pub fn diagval(&self) -> DIAGVAL_R {
325        DIAGVAL_R::new(((self.bits >> 8) & 3) as u8)
326    }
327    #[doc = "Bit 10 - Self-Diagnosis Mode Select"]
328    #[inline(always)]
329    pub fn diagld(&self) -> DIAGLD_R {
330        DIAGLD_R::new(((self.bits >> 10) & 1) != 0)
331    }
332    #[doc = "Bit 11 - Self-Diagnosis Enable"]
333    #[inline(always)]
334    pub fn diagm(&self) -> DIAGM_R {
335        DIAGM_R::new(((self.bits >> 11) & 1) != 0)
336    }
337    #[doc = "Bit 15 - A/D Data Register Format Select"]
338    #[inline(always)]
339    pub fn adrfmt(&self) -> ADRFMT_R {
340        ADRFMT_R::new(((self.bits >> 15) & 1) != 0)
341    }
342}
343impl W {
344    #[doc = "Bit 5 - A/D Data Register Automatic Clearing Enable"]
345    #[inline(always)]
346    #[must_use]
347    pub fn ace(&mut self) -> ACE_W<5> {
348        ACE_W::new(self)
349    }
350    #[doc = "Bits 8:9 - Self-Diagnosis Conversion Voltage Select"]
351    #[inline(always)]
352    #[must_use]
353    pub fn diagval(&mut self) -> DIAGVAL_W<8> {
354        DIAGVAL_W::new(self)
355    }
356    #[doc = "Bit 10 - Self-Diagnosis Mode Select"]
357    #[inline(always)]
358    #[must_use]
359    pub fn diagld(&mut self) -> DIAGLD_W<10> {
360        DIAGLD_W::new(self)
361    }
362    #[doc = "Bit 11 - Self-Diagnosis Enable"]
363    #[inline(always)]
364    #[must_use]
365    pub fn diagm(&mut self) -> DIAGM_W<11> {
366        DIAGM_W::new(self)
367    }
368    #[doc = "Bit 15 - A/D Data Register Format Select"]
369    #[inline(always)]
370    #[must_use]
371    pub fn adrfmt(&mut self) -> ADRFMT_W<15> {
372        ADRFMT_W::new(self)
373    }
374    #[doc = "Writes raw bits to the register."]
375    #[inline(always)]
376    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
377        self.0.bits(bits);
378        self
379    }
380}
381#[doc = "A/D Control Extended 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 [adcer](index.html) module"]
382pub struct ADCER_SPEC;
383impl crate::RegisterSpec for ADCER_SPEC {
384    type Ux = u16;
385}
386#[doc = "`read()` method returns [adcer::R](R) reader structure"]
387impl crate::Readable for ADCER_SPEC {
388    type Reader = R;
389}
390#[doc = "`write(|w| ..)` method takes [adcer::W](W) writer structure"]
391impl crate::Writable for ADCER_SPEC {
392    type Writer = W;
393    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
394    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
395}
396#[doc = "`reset()` method sets ADCER to value 0"]
397impl crate::Resettable for ADCER_SPEC {
398    const RESET_VALUE: Self::Ux = 0;
399}