ra4e1/adc120/
adcsr.rs

1#[doc = "Register `ADCSR` reader"]
2pub struct R(crate::R<ADCSR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ADCSR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ADCSR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ADCSR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ADCSR` writer"]
17pub struct W(crate::W<ADCSR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ADCSR_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<ADCSR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ADCSR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DBLANS` reader - Double Trigger Channel Select"]
38pub type DBLANS_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `DBLANS` writer - Double Trigger Channel Select"]
40pub type DBLANS_W<'a, const O: u8> = crate::FieldWriter<'a, u16, ADCSR_SPEC, u8, u8, 5, O>;
41#[doc = "Field `GBADIE` reader - Group B Scan End Interrupt and ELC Event Enable"]
42pub type GBADIE_R = crate::BitReader<GBADIE_A>;
43#[doc = "Group B Scan End Interrupt and ELC Event Enable\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum GBADIE_A {
46    #[doc = "0: Disable ADC120_GBADI interrupt generation on group B scan completion."]
47    _0 = 0,
48    #[doc = "1: Enable ADC120_GBADI interrupt generation on group B scan completion."]
49    _1 = 1,
50}
51impl From<GBADIE_A> for bool {
52    #[inline(always)]
53    fn from(variant: GBADIE_A) -> Self {
54        variant as u8 != 0
55    }
56}
57impl GBADIE_R {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> GBADIE_A {
61        match self.bits {
62            false => GBADIE_A::_0,
63            true => GBADIE_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        *self == GBADIE_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        *self == GBADIE_A::_1
75    }
76}
77#[doc = "Field `GBADIE` writer - Group B Scan End Interrupt and ELC Event Enable"]
78pub type GBADIE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCSR_SPEC, GBADIE_A, O>;
79impl<'a, const O: u8> GBADIE_W<'a, O> {
80    #[doc = "Disable ADC120_GBADI interrupt generation on group B scan completion."]
81    #[inline(always)]
82    pub fn _0(self) -> &'a mut W {
83        self.variant(GBADIE_A::_0)
84    }
85    #[doc = "Enable ADC120_GBADI interrupt generation on group B scan completion."]
86    #[inline(always)]
87    pub fn _1(self) -> &'a mut W {
88        self.variant(GBADIE_A::_1)
89    }
90}
91#[doc = "Field `DBLE` reader - Double Trigger Mode Select"]
92pub type DBLE_R = crate::BitReader<DBLE_A>;
93#[doc = "Double Trigger Mode Select\n\nValue on reset: 0"]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95pub enum DBLE_A {
96    #[doc = "0: Deselect double-trigger mode."]
97    _0 = 0,
98    #[doc = "1: Select double-trigger mode."]
99    _1 = 1,
100}
101impl From<DBLE_A> for bool {
102    #[inline(always)]
103    fn from(variant: DBLE_A) -> Self {
104        variant as u8 != 0
105    }
106}
107impl DBLE_R {
108    #[doc = "Get enumerated values variant"]
109    #[inline(always)]
110    pub fn variant(&self) -> DBLE_A {
111        match self.bits {
112            false => DBLE_A::_0,
113            true => DBLE_A::_1,
114        }
115    }
116    #[doc = "Checks if the value of the field is `_0`"]
117    #[inline(always)]
118    pub fn is_0(&self) -> bool {
119        *self == DBLE_A::_0
120    }
121    #[doc = "Checks if the value of the field is `_1`"]
122    #[inline(always)]
123    pub fn is_1(&self) -> bool {
124        *self == DBLE_A::_1
125    }
126}
127#[doc = "Field `DBLE` writer - Double Trigger Mode Select"]
128pub type DBLE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCSR_SPEC, DBLE_A, O>;
129impl<'a, const O: u8> DBLE_W<'a, O> {
130    #[doc = "Deselect double-trigger mode."]
131    #[inline(always)]
132    pub fn _0(self) -> &'a mut W {
133        self.variant(DBLE_A::_0)
134    }
135    #[doc = "Select double-trigger mode."]
136    #[inline(always)]
137    pub fn _1(self) -> &'a mut W {
138        self.variant(DBLE_A::_1)
139    }
140}
141#[doc = "Field `EXTRG` reader - Trigger Select"]
142pub type EXTRG_R = crate::BitReader<EXTRG_A>;
143#[doc = "Trigger Select\n\nValue on reset: 0"]
144#[derive(Clone, Copy, Debug, PartialEq, Eq)]
145pub enum EXTRG_A {
146    #[doc = "0: Start A/D conversion by the synchronous trigger (ELC)."]
147    _0 = 0,
148    #[doc = "1: Start A/D conversion by the asynchronous trigger (ADTRG0)."]
149    _1 = 1,
150}
151impl From<EXTRG_A> for bool {
152    #[inline(always)]
153    fn from(variant: EXTRG_A) -> Self {
154        variant as u8 != 0
155    }
156}
157impl EXTRG_R {
158    #[doc = "Get enumerated values variant"]
159    #[inline(always)]
160    pub fn variant(&self) -> EXTRG_A {
161        match self.bits {
162            false => EXTRG_A::_0,
163            true => EXTRG_A::_1,
164        }
165    }
166    #[doc = "Checks if the value of the field is `_0`"]
167    #[inline(always)]
168    pub fn is_0(&self) -> bool {
169        *self == EXTRG_A::_0
170    }
171    #[doc = "Checks if the value of the field is `_1`"]
172    #[inline(always)]
173    pub fn is_1(&self) -> bool {
174        *self == EXTRG_A::_1
175    }
176}
177#[doc = "Field `EXTRG` writer - Trigger Select"]
178pub type EXTRG_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCSR_SPEC, EXTRG_A, O>;
179impl<'a, const O: u8> EXTRG_W<'a, O> {
180    #[doc = "Start A/D conversion by the synchronous trigger (ELC)."]
181    #[inline(always)]
182    pub fn _0(self) -> &'a mut W {
183        self.variant(EXTRG_A::_0)
184    }
185    #[doc = "Start A/D conversion by the asynchronous trigger (ADTRG0)."]
186    #[inline(always)]
187    pub fn _1(self) -> &'a mut W {
188        self.variant(EXTRG_A::_1)
189    }
190}
191#[doc = "Field `TRGE` reader - Trigger Start Enable"]
192pub type TRGE_R = crate::BitReader<TRGE_A>;
193#[doc = "Trigger Start Enable\n\nValue on reset: 0"]
194#[derive(Clone, Copy, Debug, PartialEq, Eq)]
195pub enum TRGE_A {
196    #[doc = "0: Disable A/D conversion to be started by the synchronous or asynchronous trigger"]
197    _0 = 0,
198    #[doc = "1: Enable A/D conversion to be started by the synchronous or asynchronous trigger"]
199    _1 = 1,
200}
201impl From<TRGE_A> for bool {
202    #[inline(always)]
203    fn from(variant: TRGE_A) -> Self {
204        variant as u8 != 0
205    }
206}
207impl TRGE_R {
208    #[doc = "Get enumerated values variant"]
209    #[inline(always)]
210    pub fn variant(&self) -> TRGE_A {
211        match self.bits {
212            false => TRGE_A::_0,
213            true => TRGE_A::_1,
214        }
215    }
216    #[doc = "Checks if the value of the field is `_0`"]
217    #[inline(always)]
218    pub fn is_0(&self) -> bool {
219        *self == TRGE_A::_0
220    }
221    #[doc = "Checks if the value of the field is `_1`"]
222    #[inline(always)]
223    pub fn is_1(&self) -> bool {
224        *self == TRGE_A::_1
225    }
226}
227#[doc = "Field `TRGE` writer - Trigger Start Enable"]
228pub type TRGE_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCSR_SPEC, TRGE_A, O>;
229impl<'a, const O: u8> TRGE_W<'a, O> {
230    #[doc = "Disable A/D conversion to be started by the synchronous or asynchronous trigger"]
231    #[inline(always)]
232    pub fn _0(self) -> &'a mut W {
233        self.variant(TRGE_A::_0)
234    }
235    #[doc = "Enable A/D conversion to be started by the synchronous or asynchronous trigger"]
236    #[inline(always)]
237    pub fn _1(self) -> &'a mut W {
238        self.variant(TRGE_A::_1)
239    }
240}
241#[doc = "Field `ADCS` reader - Scan Mode Select"]
242pub type ADCS_R = crate::FieldReader<u8, ADCS_A>;
243#[doc = "Scan Mode Select\n\nValue on reset: 0"]
244#[derive(Clone, Copy, Debug, PartialEq, Eq)]
245#[repr(u8)]
246pub enum ADCS_A {
247    #[doc = "0: Single scan mode"]
248    _00 = 0,
249    #[doc = "1: Group scan mode"]
250    _01 = 1,
251    #[doc = "2: Continuous scan mode"]
252    _10 = 2,
253    #[doc = "3: Setting prohibited"]
254    _11 = 3,
255}
256impl From<ADCS_A> for u8 {
257    #[inline(always)]
258    fn from(variant: ADCS_A) -> Self {
259        variant as _
260    }
261}
262impl ADCS_R {
263    #[doc = "Get enumerated values variant"]
264    #[inline(always)]
265    pub fn variant(&self) -> ADCS_A {
266        match self.bits {
267            0 => ADCS_A::_00,
268            1 => ADCS_A::_01,
269            2 => ADCS_A::_10,
270            3 => ADCS_A::_11,
271            _ => unreachable!(),
272        }
273    }
274    #[doc = "Checks if the value of the field is `_00`"]
275    #[inline(always)]
276    pub fn is_00(&self) -> bool {
277        *self == ADCS_A::_00
278    }
279    #[doc = "Checks if the value of the field is `_01`"]
280    #[inline(always)]
281    pub fn is_01(&self) -> bool {
282        *self == ADCS_A::_01
283    }
284    #[doc = "Checks if the value of the field is `_10`"]
285    #[inline(always)]
286    pub fn is_10(&self) -> bool {
287        *self == ADCS_A::_10
288    }
289    #[doc = "Checks if the value of the field is `_11`"]
290    #[inline(always)]
291    pub fn is_11(&self) -> bool {
292        *self == ADCS_A::_11
293    }
294}
295#[doc = "Field `ADCS` writer - Scan Mode Select"]
296pub type ADCS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u16, ADCSR_SPEC, u8, ADCS_A, 2, O>;
297impl<'a, const O: u8> ADCS_W<'a, O> {
298    #[doc = "Single scan mode"]
299    #[inline(always)]
300    pub fn _00(self) -> &'a mut W {
301        self.variant(ADCS_A::_00)
302    }
303    #[doc = "Group scan mode"]
304    #[inline(always)]
305    pub fn _01(self) -> &'a mut W {
306        self.variant(ADCS_A::_01)
307    }
308    #[doc = "Continuous scan mode"]
309    #[inline(always)]
310    pub fn _10(self) -> &'a mut W {
311        self.variant(ADCS_A::_10)
312    }
313    #[doc = "Setting prohibited"]
314    #[inline(always)]
315    pub fn _11(self) -> &'a mut W {
316        self.variant(ADCS_A::_11)
317    }
318}
319#[doc = "Field `ADST` reader - A/D Conversion Start"]
320pub type ADST_R = crate::BitReader<ADST_A>;
321#[doc = "A/D Conversion Start\n\nValue on reset: 0"]
322#[derive(Clone, Copy, Debug, PartialEq, Eq)]
323pub enum ADST_A {
324    #[doc = "0: Stop A/D conversion process."]
325    _0 = 0,
326    #[doc = "1: Start A/D conversion process."]
327    _1 = 1,
328}
329impl From<ADST_A> for bool {
330    #[inline(always)]
331    fn from(variant: ADST_A) -> Self {
332        variant as u8 != 0
333    }
334}
335impl ADST_R {
336    #[doc = "Get enumerated values variant"]
337    #[inline(always)]
338    pub fn variant(&self) -> ADST_A {
339        match self.bits {
340            false => ADST_A::_0,
341            true => ADST_A::_1,
342        }
343    }
344    #[doc = "Checks if the value of the field is `_0`"]
345    #[inline(always)]
346    pub fn is_0(&self) -> bool {
347        *self == ADST_A::_0
348    }
349    #[doc = "Checks if the value of the field is `_1`"]
350    #[inline(always)]
351    pub fn is_1(&self) -> bool {
352        *self == ADST_A::_1
353    }
354}
355#[doc = "Field `ADST` writer - A/D Conversion Start"]
356pub type ADST_W<'a, const O: u8> = crate::BitWriter<'a, u16, ADCSR_SPEC, ADST_A, O>;
357impl<'a, const O: u8> ADST_W<'a, O> {
358    #[doc = "Stop A/D conversion process."]
359    #[inline(always)]
360    pub fn _0(self) -> &'a mut W {
361        self.variant(ADST_A::_0)
362    }
363    #[doc = "Start A/D conversion process."]
364    #[inline(always)]
365    pub fn _1(self) -> &'a mut W {
366        self.variant(ADST_A::_1)
367    }
368}
369impl R {
370    #[doc = "Bits 0:4 - Double Trigger Channel Select"]
371    #[inline(always)]
372    pub fn dblans(&self) -> DBLANS_R {
373        DBLANS_R::new((self.bits & 0x1f) as u8)
374    }
375    #[doc = "Bit 6 - Group B Scan End Interrupt and ELC Event Enable"]
376    #[inline(always)]
377    pub fn gbadie(&self) -> GBADIE_R {
378        GBADIE_R::new(((self.bits >> 6) & 1) != 0)
379    }
380    #[doc = "Bit 7 - Double Trigger Mode Select"]
381    #[inline(always)]
382    pub fn dble(&self) -> DBLE_R {
383        DBLE_R::new(((self.bits >> 7) & 1) != 0)
384    }
385    #[doc = "Bit 8 - Trigger Select"]
386    #[inline(always)]
387    pub fn extrg(&self) -> EXTRG_R {
388        EXTRG_R::new(((self.bits >> 8) & 1) != 0)
389    }
390    #[doc = "Bit 9 - Trigger Start Enable"]
391    #[inline(always)]
392    pub fn trge(&self) -> TRGE_R {
393        TRGE_R::new(((self.bits >> 9) & 1) != 0)
394    }
395    #[doc = "Bits 13:14 - Scan Mode Select"]
396    #[inline(always)]
397    pub fn adcs(&self) -> ADCS_R {
398        ADCS_R::new(((self.bits >> 13) & 3) as u8)
399    }
400    #[doc = "Bit 15 - A/D Conversion Start"]
401    #[inline(always)]
402    pub fn adst(&self) -> ADST_R {
403        ADST_R::new(((self.bits >> 15) & 1) != 0)
404    }
405}
406impl W {
407    #[doc = "Bits 0:4 - Double Trigger Channel Select"]
408    #[inline(always)]
409    #[must_use]
410    pub fn dblans(&mut self) -> DBLANS_W<0> {
411        DBLANS_W::new(self)
412    }
413    #[doc = "Bit 6 - Group B Scan End Interrupt and ELC Event Enable"]
414    #[inline(always)]
415    #[must_use]
416    pub fn gbadie(&mut self) -> GBADIE_W<6> {
417        GBADIE_W::new(self)
418    }
419    #[doc = "Bit 7 - Double Trigger Mode Select"]
420    #[inline(always)]
421    #[must_use]
422    pub fn dble(&mut self) -> DBLE_W<7> {
423        DBLE_W::new(self)
424    }
425    #[doc = "Bit 8 - Trigger Select"]
426    #[inline(always)]
427    #[must_use]
428    pub fn extrg(&mut self) -> EXTRG_W<8> {
429        EXTRG_W::new(self)
430    }
431    #[doc = "Bit 9 - Trigger Start Enable"]
432    #[inline(always)]
433    #[must_use]
434    pub fn trge(&mut self) -> TRGE_W<9> {
435        TRGE_W::new(self)
436    }
437    #[doc = "Bits 13:14 - Scan Mode Select"]
438    #[inline(always)]
439    #[must_use]
440    pub fn adcs(&mut self) -> ADCS_W<13> {
441        ADCS_W::new(self)
442    }
443    #[doc = "Bit 15 - A/D Conversion Start"]
444    #[inline(always)]
445    #[must_use]
446    pub fn adst(&mut self) -> ADST_W<15> {
447        ADST_W::new(self)
448    }
449    #[doc = "Writes raw bits to the register."]
450    #[inline(always)]
451    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
452        self.0.bits(bits);
453        self
454    }
455}
456#[doc = "A/D 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 [adcsr](index.html) module"]
457pub struct ADCSR_SPEC;
458impl crate::RegisterSpec for ADCSR_SPEC {
459    type Ux = u16;
460}
461#[doc = "`read()` method returns [adcsr::R](R) reader structure"]
462impl crate::Readable for ADCSR_SPEC {
463    type Reader = R;
464}
465#[doc = "`write(|w| ..)` method takes [adcsr::W](W) writer structure"]
466impl crate::Writable for ADCSR_SPEC {
467    type Writer = W;
468    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
469    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
470}
471#[doc = "`reset()` method sets ADCSR to value 0"]
472impl crate::Resettable for ADCSR_SPEC {
473    const RESET_VALUE: Self::Ux = 0;
474}