efm32gg12b530_pac/vdac0/
ch0ctrl.rs

1#[doc = "Register `CH0CTRL` reader"]
2pub struct R(crate::R<CH0CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CH0CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CH0CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CH0CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CH0CTRL` writer"]
17pub struct W(crate::W<CH0CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CH0CTRL_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<CH0CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CH0CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CONVMODE` reader - Conversion Mode"]
38pub type CONVMODE_R = crate::BitReader<bool>;
39#[doc = "Field `CONVMODE` writer - Conversion Mode"]
40pub type CONVMODE_W<'a> = crate::BitWriter<'a, u32, CH0CTRL_SPEC, bool, 0>;
41#[doc = "Channel 0 Trigger Mode\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum TRIGMODE_A {
45    #[doc = "0: Channel 0 is triggered by CH0DATA or COMBDATA write"]
46    SW = 0,
47    #[doc = "1: Channel 0 is triggered by PRS input"]
48    PRS = 1,
49    #[doc = "2: Channel 0 is triggered by Refresh timer"]
50    REFRESH = 2,
51    #[doc = "3: Channel 0 is triggered by CH0DATA/COMBDATA write or PRS input"]
52    SWPRS = 3,
53    #[doc = "4: Channel 0 is triggered by CH0DATA/COMBDATA write or Refresh timer"]
54    SWREFRESH = 4,
55    #[doc = "5: Channel 0 is triggered by LESENSE"]
56    LESENSE = 5,
57}
58impl From<TRIGMODE_A> for u8 {
59    #[inline(always)]
60    fn from(variant: TRIGMODE_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `TRIGMODE` reader - Channel 0 Trigger Mode"]
65pub type TRIGMODE_R = crate::FieldReader<u8, TRIGMODE_A>;
66impl TRIGMODE_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> Option<TRIGMODE_A> {
70        match self.bits {
71            0 => Some(TRIGMODE_A::SW),
72            1 => Some(TRIGMODE_A::PRS),
73            2 => Some(TRIGMODE_A::REFRESH),
74            3 => Some(TRIGMODE_A::SWPRS),
75            4 => Some(TRIGMODE_A::SWREFRESH),
76            5 => Some(TRIGMODE_A::LESENSE),
77            _ => None,
78        }
79    }
80    #[doc = "Checks if the value of the field is `SW`"]
81    #[inline(always)]
82    pub fn is_sw(&self) -> bool {
83        *self == TRIGMODE_A::SW
84    }
85    #[doc = "Checks if the value of the field is `PRS`"]
86    #[inline(always)]
87    pub fn is_prs(&self) -> bool {
88        *self == TRIGMODE_A::PRS
89    }
90    #[doc = "Checks if the value of the field is `REFRESH`"]
91    #[inline(always)]
92    pub fn is_refresh(&self) -> bool {
93        *self == TRIGMODE_A::REFRESH
94    }
95    #[doc = "Checks if the value of the field is `SWPRS`"]
96    #[inline(always)]
97    pub fn is_swprs(&self) -> bool {
98        *self == TRIGMODE_A::SWPRS
99    }
100    #[doc = "Checks if the value of the field is `SWREFRESH`"]
101    #[inline(always)]
102    pub fn is_swrefresh(&self) -> bool {
103        *self == TRIGMODE_A::SWREFRESH
104    }
105    #[doc = "Checks if the value of the field is `LESENSE`"]
106    #[inline(always)]
107    pub fn is_lesense(&self) -> bool {
108        *self == TRIGMODE_A::LESENSE
109    }
110}
111#[doc = "Field `TRIGMODE` writer - Channel 0 Trigger Mode"]
112pub type TRIGMODE_W<'a> = crate::FieldWriter<'a, u32, CH0CTRL_SPEC, u8, TRIGMODE_A, 3, 4>;
113impl<'a> TRIGMODE_W<'a> {
114    #[doc = "Channel 0 is triggered by CH0DATA or COMBDATA write"]
115    #[inline(always)]
116    pub fn sw(self) -> &'a mut W {
117        self.variant(TRIGMODE_A::SW)
118    }
119    #[doc = "Channel 0 is triggered by PRS input"]
120    #[inline(always)]
121    pub fn prs(self) -> &'a mut W {
122        self.variant(TRIGMODE_A::PRS)
123    }
124    #[doc = "Channel 0 is triggered by Refresh timer"]
125    #[inline(always)]
126    pub fn refresh(self) -> &'a mut W {
127        self.variant(TRIGMODE_A::REFRESH)
128    }
129    #[doc = "Channel 0 is triggered by CH0DATA/COMBDATA write or PRS input"]
130    #[inline(always)]
131    pub fn swprs(self) -> &'a mut W {
132        self.variant(TRIGMODE_A::SWPRS)
133    }
134    #[doc = "Channel 0 is triggered by CH0DATA/COMBDATA write or Refresh timer"]
135    #[inline(always)]
136    pub fn swrefresh(self) -> &'a mut W {
137        self.variant(TRIGMODE_A::SWREFRESH)
138    }
139    #[doc = "Channel 0 is triggered by LESENSE"]
140    #[inline(always)]
141    pub fn lesense(self) -> &'a mut W {
142        self.variant(TRIGMODE_A::LESENSE)
143    }
144}
145#[doc = "Field `PRSASYNC` reader - Channel 0 PRS Asynchronous Enable"]
146pub type PRSASYNC_R = crate::BitReader<bool>;
147#[doc = "Field `PRSASYNC` writer - Channel 0 PRS Asynchronous Enable"]
148pub type PRSASYNC_W<'a> = crate::BitWriter<'a, u32, CH0CTRL_SPEC, bool, 8>;
149#[doc = "Channel 0 PRS Trigger Select\n\nValue on reset: 0"]
150#[derive(Clone, Copy, Debug, PartialEq)]
151#[repr(u8)]
152pub enum PRSSEL_A {
153    #[doc = "0: PRS ch 0 triggers a conversion."]
154    PRSCH0 = 0,
155    #[doc = "1: PRS ch 1 triggers a conversion."]
156    PRSCH1 = 1,
157    #[doc = "2: PRS ch 2 triggers a conversion."]
158    PRSCH2 = 2,
159    #[doc = "3: PRS ch 3 triggers a conversion."]
160    PRSCH3 = 3,
161    #[doc = "4: PRS ch 4 triggers a conversion."]
162    PRSCH4 = 4,
163    #[doc = "5: PRS ch 5 triggers a conversion."]
164    PRSCH5 = 5,
165    #[doc = "6: PRS ch 6 triggers a conversion."]
166    PRSCH6 = 6,
167    #[doc = "7: PRS ch 7 triggers a conversion."]
168    PRSCH7 = 7,
169    #[doc = "8: PRS ch 8 triggers a conversion."]
170    PRSCH8 = 8,
171    #[doc = "9: PRS ch 9 triggers a conversion."]
172    PRSCH9 = 9,
173    #[doc = "10: PRS ch 10 triggers a conversion."]
174    PRSCH10 = 10,
175    #[doc = "11: PRS ch 11 triggers a conversion."]
176    PRSCH11 = 11,
177    #[doc = "12: PRS ch 12 triggers a conversion."]
178    PRSCH12 = 12,
179    #[doc = "13: PRS ch 13 triggers a conversion."]
180    PRSCH13 = 13,
181    #[doc = "14: PRS ch 14 triggers a conversion."]
182    PRSCH14 = 14,
183    #[doc = "15: PRS ch 15 triggers a conversion."]
184    PRSCH15 = 15,
185}
186impl From<PRSSEL_A> for u8 {
187    #[inline(always)]
188    fn from(variant: PRSSEL_A) -> Self {
189        variant as _
190    }
191}
192#[doc = "Field `PRSSEL` reader - Channel 0 PRS Trigger Select"]
193pub type PRSSEL_R = crate::FieldReader<u8, PRSSEL_A>;
194impl PRSSEL_R {
195    #[doc = "Get enumerated values variant"]
196    #[inline(always)]
197    pub fn variant(&self) -> PRSSEL_A {
198        match self.bits {
199            0 => PRSSEL_A::PRSCH0,
200            1 => PRSSEL_A::PRSCH1,
201            2 => PRSSEL_A::PRSCH2,
202            3 => PRSSEL_A::PRSCH3,
203            4 => PRSSEL_A::PRSCH4,
204            5 => PRSSEL_A::PRSCH5,
205            6 => PRSSEL_A::PRSCH6,
206            7 => PRSSEL_A::PRSCH7,
207            8 => PRSSEL_A::PRSCH8,
208            9 => PRSSEL_A::PRSCH9,
209            10 => PRSSEL_A::PRSCH10,
210            11 => PRSSEL_A::PRSCH11,
211            12 => PRSSEL_A::PRSCH12,
212            13 => PRSSEL_A::PRSCH13,
213            14 => PRSSEL_A::PRSCH14,
214            15 => PRSSEL_A::PRSCH15,
215            _ => unreachable!(),
216        }
217    }
218    #[doc = "Checks if the value of the field is `PRSCH0`"]
219    #[inline(always)]
220    pub fn is_prsch0(&self) -> bool {
221        *self == PRSSEL_A::PRSCH0
222    }
223    #[doc = "Checks if the value of the field is `PRSCH1`"]
224    #[inline(always)]
225    pub fn is_prsch1(&self) -> bool {
226        *self == PRSSEL_A::PRSCH1
227    }
228    #[doc = "Checks if the value of the field is `PRSCH2`"]
229    #[inline(always)]
230    pub fn is_prsch2(&self) -> bool {
231        *self == PRSSEL_A::PRSCH2
232    }
233    #[doc = "Checks if the value of the field is `PRSCH3`"]
234    #[inline(always)]
235    pub fn is_prsch3(&self) -> bool {
236        *self == PRSSEL_A::PRSCH3
237    }
238    #[doc = "Checks if the value of the field is `PRSCH4`"]
239    #[inline(always)]
240    pub fn is_prsch4(&self) -> bool {
241        *self == PRSSEL_A::PRSCH4
242    }
243    #[doc = "Checks if the value of the field is `PRSCH5`"]
244    #[inline(always)]
245    pub fn is_prsch5(&self) -> bool {
246        *self == PRSSEL_A::PRSCH5
247    }
248    #[doc = "Checks if the value of the field is `PRSCH6`"]
249    #[inline(always)]
250    pub fn is_prsch6(&self) -> bool {
251        *self == PRSSEL_A::PRSCH6
252    }
253    #[doc = "Checks if the value of the field is `PRSCH7`"]
254    #[inline(always)]
255    pub fn is_prsch7(&self) -> bool {
256        *self == PRSSEL_A::PRSCH7
257    }
258    #[doc = "Checks if the value of the field is `PRSCH8`"]
259    #[inline(always)]
260    pub fn is_prsch8(&self) -> bool {
261        *self == PRSSEL_A::PRSCH8
262    }
263    #[doc = "Checks if the value of the field is `PRSCH9`"]
264    #[inline(always)]
265    pub fn is_prsch9(&self) -> bool {
266        *self == PRSSEL_A::PRSCH9
267    }
268    #[doc = "Checks if the value of the field is `PRSCH10`"]
269    #[inline(always)]
270    pub fn is_prsch10(&self) -> bool {
271        *self == PRSSEL_A::PRSCH10
272    }
273    #[doc = "Checks if the value of the field is `PRSCH11`"]
274    #[inline(always)]
275    pub fn is_prsch11(&self) -> bool {
276        *self == PRSSEL_A::PRSCH11
277    }
278    #[doc = "Checks if the value of the field is `PRSCH12`"]
279    #[inline(always)]
280    pub fn is_prsch12(&self) -> bool {
281        *self == PRSSEL_A::PRSCH12
282    }
283    #[doc = "Checks if the value of the field is `PRSCH13`"]
284    #[inline(always)]
285    pub fn is_prsch13(&self) -> bool {
286        *self == PRSSEL_A::PRSCH13
287    }
288    #[doc = "Checks if the value of the field is `PRSCH14`"]
289    #[inline(always)]
290    pub fn is_prsch14(&self) -> bool {
291        *self == PRSSEL_A::PRSCH14
292    }
293    #[doc = "Checks if the value of the field is `PRSCH15`"]
294    #[inline(always)]
295    pub fn is_prsch15(&self) -> bool {
296        *self == PRSSEL_A::PRSCH15
297    }
298}
299#[doc = "Field `PRSSEL` writer - Channel 0 PRS Trigger Select"]
300pub type PRSSEL_W<'a> = crate::FieldWriterSafe<'a, u32, CH0CTRL_SPEC, u8, PRSSEL_A, 4, 12>;
301impl<'a> PRSSEL_W<'a> {
302    #[doc = "PRS ch 0 triggers a conversion."]
303    #[inline(always)]
304    pub fn prsch0(self) -> &'a mut W {
305        self.variant(PRSSEL_A::PRSCH0)
306    }
307    #[doc = "PRS ch 1 triggers a conversion."]
308    #[inline(always)]
309    pub fn prsch1(self) -> &'a mut W {
310        self.variant(PRSSEL_A::PRSCH1)
311    }
312    #[doc = "PRS ch 2 triggers a conversion."]
313    #[inline(always)]
314    pub fn prsch2(self) -> &'a mut W {
315        self.variant(PRSSEL_A::PRSCH2)
316    }
317    #[doc = "PRS ch 3 triggers a conversion."]
318    #[inline(always)]
319    pub fn prsch3(self) -> &'a mut W {
320        self.variant(PRSSEL_A::PRSCH3)
321    }
322    #[doc = "PRS ch 4 triggers a conversion."]
323    #[inline(always)]
324    pub fn prsch4(self) -> &'a mut W {
325        self.variant(PRSSEL_A::PRSCH4)
326    }
327    #[doc = "PRS ch 5 triggers a conversion."]
328    #[inline(always)]
329    pub fn prsch5(self) -> &'a mut W {
330        self.variant(PRSSEL_A::PRSCH5)
331    }
332    #[doc = "PRS ch 6 triggers a conversion."]
333    #[inline(always)]
334    pub fn prsch6(self) -> &'a mut W {
335        self.variant(PRSSEL_A::PRSCH6)
336    }
337    #[doc = "PRS ch 7 triggers a conversion."]
338    #[inline(always)]
339    pub fn prsch7(self) -> &'a mut W {
340        self.variant(PRSSEL_A::PRSCH7)
341    }
342    #[doc = "PRS ch 8 triggers a conversion."]
343    #[inline(always)]
344    pub fn prsch8(self) -> &'a mut W {
345        self.variant(PRSSEL_A::PRSCH8)
346    }
347    #[doc = "PRS ch 9 triggers a conversion."]
348    #[inline(always)]
349    pub fn prsch9(self) -> &'a mut W {
350        self.variant(PRSSEL_A::PRSCH9)
351    }
352    #[doc = "PRS ch 10 triggers a conversion."]
353    #[inline(always)]
354    pub fn prsch10(self) -> &'a mut W {
355        self.variant(PRSSEL_A::PRSCH10)
356    }
357    #[doc = "PRS ch 11 triggers a conversion."]
358    #[inline(always)]
359    pub fn prsch11(self) -> &'a mut W {
360        self.variant(PRSSEL_A::PRSCH11)
361    }
362    #[doc = "PRS ch 12 triggers a conversion."]
363    #[inline(always)]
364    pub fn prsch12(self) -> &'a mut W {
365        self.variant(PRSSEL_A::PRSCH12)
366    }
367    #[doc = "PRS ch 13 triggers a conversion."]
368    #[inline(always)]
369    pub fn prsch13(self) -> &'a mut W {
370        self.variant(PRSSEL_A::PRSCH13)
371    }
372    #[doc = "PRS ch 14 triggers a conversion."]
373    #[inline(always)]
374    pub fn prsch14(self) -> &'a mut W {
375        self.variant(PRSSEL_A::PRSCH14)
376    }
377    #[doc = "PRS ch 15 triggers a conversion."]
378    #[inline(always)]
379    pub fn prsch15(self) -> &'a mut W {
380        self.variant(PRSSEL_A::PRSCH15)
381    }
382}
383impl R {
384    #[doc = "Bit 0 - Conversion Mode"]
385    #[inline(always)]
386    pub fn convmode(&self) -> CONVMODE_R {
387        CONVMODE_R::new((self.bits & 1) != 0)
388    }
389    #[doc = "Bits 4:6 - Channel 0 Trigger Mode"]
390    #[inline(always)]
391    pub fn trigmode(&self) -> TRIGMODE_R {
392        TRIGMODE_R::new(((self.bits >> 4) & 7) as u8)
393    }
394    #[doc = "Bit 8 - Channel 0 PRS Asynchronous Enable"]
395    #[inline(always)]
396    pub fn prsasync(&self) -> PRSASYNC_R {
397        PRSASYNC_R::new(((self.bits >> 8) & 1) != 0)
398    }
399    #[doc = "Bits 12:15 - Channel 0 PRS Trigger Select"]
400    #[inline(always)]
401    pub fn prssel(&self) -> PRSSEL_R {
402        PRSSEL_R::new(((self.bits >> 12) & 0x0f) as u8)
403    }
404}
405impl W {
406    #[doc = "Bit 0 - Conversion Mode"]
407    #[inline(always)]
408    pub fn convmode(&mut self) -> CONVMODE_W {
409        CONVMODE_W::new(self)
410    }
411    #[doc = "Bits 4:6 - Channel 0 Trigger Mode"]
412    #[inline(always)]
413    pub fn trigmode(&mut self) -> TRIGMODE_W {
414        TRIGMODE_W::new(self)
415    }
416    #[doc = "Bit 8 - Channel 0 PRS Asynchronous Enable"]
417    #[inline(always)]
418    pub fn prsasync(&mut self) -> PRSASYNC_W {
419        PRSASYNC_W::new(self)
420    }
421    #[doc = "Bits 12:15 - Channel 0 PRS Trigger Select"]
422    #[inline(always)]
423    pub fn prssel(&mut self) -> PRSSEL_W {
424        PRSSEL_W::new(self)
425    }
426    #[doc = "Writes raw bits to the register."]
427    #[inline(always)]
428    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
429        self.0.bits(bits);
430        self
431    }
432}
433#[doc = "Channel 0 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 [ch0ctrl](index.html) module"]
434pub struct CH0CTRL_SPEC;
435impl crate::RegisterSpec for CH0CTRL_SPEC {
436    type Ux = u32;
437}
438#[doc = "`read()` method returns [ch0ctrl::R](R) reader structure"]
439impl crate::Readable for CH0CTRL_SPEC {
440    type Reader = R;
441}
442#[doc = "`write(|w| ..)` method takes [ch0ctrl::W](W) writer structure"]
443impl crate::Writable for CH0CTRL_SPEC {
444    type Writer = W;
445}
446#[doc = "`reset()` method sets CH0CTRL to value 0"]
447impl crate::Resettable for CH0CTRL_SPEC {
448    #[inline(always)]
449    fn reset_value() -> Self::Ux {
450        0
451    }
452}