efm32pg12b500_pac/vdac0/
ch1ctrl.rs

1#[doc = "Register `CH1CTRL` reader"]
2pub struct R(crate::R<CH1CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CH1CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CH1CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CH1CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CH1CTRL` writer"]
17pub struct W(crate::W<CH1CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CH1CTRL_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<CH1CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CH1CTRL_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, CH1CTRL_SPEC, bool, 0>;
41#[doc = "Channel 1 Trigger Mode\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum TRIGMODE_A {
45    #[doc = "0: Channel 1 is triggered by CH1DATA or COMBDATA write"]
46    SW = 0,
47    #[doc = "1: Channel 1 is triggered by PRS input"]
48    PRS = 1,
49    #[doc = "2: Channel 1 is triggered by Refresh timer"]
50    REFRESH = 2,
51    #[doc = "3: Channel 1 is triggered by CH1DATA/COMBDATA write or PRS input"]
52    SWPRS = 3,
53    #[doc = "4: Channel 1 is triggered by CH1DATA/COMBDATA write or Refresh timer"]
54    SWREFRESH = 4,
55    #[doc = "5: Channel 1 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 1 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 1 Trigger Mode"]
112pub type TRIGMODE_W<'a> = crate::FieldWriter<'a, u32, CH1CTRL_SPEC, u8, TRIGMODE_A, 3, 4>;
113impl<'a> TRIGMODE_W<'a> {
114    #[doc = "Channel 1 is triggered by CH1DATA or COMBDATA write"]
115    #[inline(always)]
116    pub fn sw(self) -> &'a mut W {
117        self.variant(TRIGMODE_A::SW)
118    }
119    #[doc = "Channel 1 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 1 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 1 is triggered by CH1DATA/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 1 is triggered by CH1DATA/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 1 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 1 PRS Asynchronous Enable"]
146pub type PRSASYNC_R = crate::BitReader<bool>;
147#[doc = "Field `PRSASYNC` writer - Channel 1 PRS Asynchronous Enable"]
148pub type PRSASYNC_W<'a> = crate::BitWriter<'a, u32, CH1CTRL_SPEC, bool, 8>;
149#[doc = "Channel 1 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}
178impl From<PRSSEL_A> for u8 {
179    #[inline(always)]
180    fn from(variant: PRSSEL_A) -> Self {
181        variant as _
182    }
183}
184#[doc = "Field `PRSSEL` reader - Channel 1 PRS Trigger Select"]
185pub type PRSSEL_R = crate::FieldReader<u8, PRSSEL_A>;
186impl PRSSEL_R {
187    #[doc = "Get enumerated values variant"]
188    #[inline(always)]
189    pub fn variant(&self) -> Option<PRSSEL_A> {
190        match self.bits {
191            0 => Some(PRSSEL_A::PRSCH0),
192            1 => Some(PRSSEL_A::PRSCH1),
193            2 => Some(PRSSEL_A::PRSCH2),
194            3 => Some(PRSSEL_A::PRSCH3),
195            4 => Some(PRSSEL_A::PRSCH4),
196            5 => Some(PRSSEL_A::PRSCH5),
197            6 => Some(PRSSEL_A::PRSCH6),
198            7 => Some(PRSSEL_A::PRSCH7),
199            8 => Some(PRSSEL_A::PRSCH8),
200            9 => Some(PRSSEL_A::PRSCH9),
201            10 => Some(PRSSEL_A::PRSCH10),
202            11 => Some(PRSSEL_A::PRSCH11),
203            _ => None,
204        }
205    }
206    #[doc = "Checks if the value of the field is `PRSCH0`"]
207    #[inline(always)]
208    pub fn is_prsch0(&self) -> bool {
209        *self == PRSSEL_A::PRSCH0
210    }
211    #[doc = "Checks if the value of the field is `PRSCH1`"]
212    #[inline(always)]
213    pub fn is_prsch1(&self) -> bool {
214        *self == PRSSEL_A::PRSCH1
215    }
216    #[doc = "Checks if the value of the field is `PRSCH2`"]
217    #[inline(always)]
218    pub fn is_prsch2(&self) -> bool {
219        *self == PRSSEL_A::PRSCH2
220    }
221    #[doc = "Checks if the value of the field is `PRSCH3`"]
222    #[inline(always)]
223    pub fn is_prsch3(&self) -> bool {
224        *self == PRSSEL_A::PRSCH3
225    }
226    #[doc = "Checks if the value of the field is `PRSCH4`"]
227    #[inline(always)]
228    pub fn is_prsch4(&self) -> bool {
229        *self == PRSSEL_A::PRSCH4
230    }
231    #[doc = "Checks if the value of the field is `PRSCH5`"]
232    #[inline(always)]
233    pub fn is_prsch5(&self) -> bool {
234        *self == PRSSEL_A::PRSCH5
235    }
236    #[doc = "Checks if the value of the field is `PRSCH6`"]
237    #[inline(always)]
238    pub fn is_prsch6(&self) -> bool {
239        *self == PRSSEL_A::PRSCH6
240    }
241    #[doc = "Checks if the value of the field is `PRSCH7`"]
242    #[inline(always)]
243    pub fn is_prsch7(&self) -> bool {
244        *self == PRSSEL_A::PRSCH7
245    }
246    #[doc = "Checks if the value of the field is `PRSCH8`"]
247    #[inline(always)]
248    pub fn is_prsch8(&self) -> bool {
249        *self == PRSSEL_A::PRSCH8
250    }
251    #[doc = "Checks if the value of the field is `PRSCH9`"]
252    #[inline(always)]
253    pub fn is_prsch9(&self) -> bool {
254        *self == PRSSEL_A::PRSCH9
255    }
256    #[doc = "Checks if the value of the field is `PRSCH10`"]
257    #[inline(always)]
258    pub fn is_prsch10(&self) -> bool {
259        *self == PRSSEL_A::PRSCH10
260    }
261    #[doc = "Checks if the value of the field is `PRSCH11`"]
262    #[inline(always)]
263    pub fn is_prsch11(&self) -> bool {
264        *self == PRSSEL_A::PRSCH11
265    }
266}
267#[doc = "Field `PRSSEL` writer - Channel 1 PRS Trigger Select"]
268pub type PRSSEL_W<'a> = crate::FieldWriter<'a, u32, CH1CTRL_SPEC, u8, PRSSEL_A, 4, 12>;
269impl<'a> PRSSEL_W<'a> {
270    #[doc = "PRS ch 0 triggers a conversion."]
271    #[inline(always)]
272    pub fn prsch0(self) -> &'a mut W {
273        self.variant(PRSSEL_A::PRSCH0)
274    }
275    #[doc = "PRS ch 1 triggers a conversion."]
276    #[inline(always)]
277    pub fn prsch1(self) -> &'a mut W {
278        self.variant(PRSSEL_A::PRSCH1)
279    }
280    #[doc = "PRS ch 2 triggers a conversion."]
281    #[inline(always)]
282    pub fn prsch2(self) -> &'a mut W {
283        self.variant(PRSSEL_A::PRSCH2)
284    }
285    #[doc = "PRS ch 3 triggers a conversion."]
286    #[inline(always)]
287    pub fn prsch3(self) -> &'a mut W {
288        self.variant(PRSSEL_A::PRSCH3)
289    }
290    #[doc = "PRS ch 4 triggers a conversion."]
291    #[inline(always)]
292    pub fn prsch4(self) -> &'a mut W {
293        self.variant(PRSSEL_A::PRSCH4)
294    }
295    #[doc = "PRS ch 5 triggers a conversion."]
296    #[inline(always)]
297    pub fn prsch5(self) -> &'a mut W {
298        self.variant(PRSSEL_A::PRSCH5)
299    }
300    #[doc = "PRS ch 6 triggers a conversion."]
301    #[inline(always)]
302    pub fn prsch6(self) -> &'a mut W {
303        self.variant(PRSSEL_A::PRSCH6)
304    }
305    #[doc = "PRS ch 7 triggers a conversion."]
306    #[inline(always)]
307    pub fn prsch7(self) -> &'a mut W {
308        self.variant(PRSSEL_A::PRSCH7)
309    }
310    #[doc = "PRS ch 8 triggers a conversion."]
311    #[inline(always)]
312    pub fn prsch8(self) -> &'a mut W {
313        self.variant(PRSSEL_A::PRSCH8)
314    }
315    #[doc = "PRS ch 9 triggers a conversion."]
316    #[inline(always)]
317    pub fn prsch9(self) -> &'a mut W {
318        self.variant(PRSSEL_A::PRSCH9)
319    }
320    #[doc = "PRS ch 10 triggers a conversion."]
321    #[inline(always)]
322    pub fn prsch10(self) -> &'a mut W {
323        self.variant(PRSSEL_A::PRSCH10)
324    }
325    #[doc = "PRS ch 11 triggers a conversion."]
326    #[inline(always)]
327    pub fn prsch11(self) -> &'a mut W {
328        self.variant(PRSSEL_A::PRSCH11)
329    }
330}
331impl R {
332    #[doc = "Bit 0 - Conversion Mode"]
333    #[inline(always)]
334    pub fn convmode(&self) -> CONVMODE_R {
335        CONVMODE_R::new((self.bits & 1) != 0)
336    }
337    #[doc = "Bits 4:6 - Channel 1 Trigger Mode"]
338    #[inline(always)]
339    pub fn trigmode(&self) -> TRIGMODE_R {
340        TRIGMODE_R::new(((self.bits >> 4) & 7) as u8)
341    }
342    #[doc = "Bit 8 - Channel 1 PRS Asynchronous Enable"]
343    #[inline(always)]
344    pub fn prsasync(&self) -> PRSASYNC_R {
345        PRSASYNC_R::new(((self.bits >> 8) & 1) != 0)
346    }
347    #[doc = "Bits 12:15 - Channel 1 PRS Trigger Select"]
348    #[inline(always)]
349    pub fn prssel(&self) -> PRSSEL_R {
350        PRSSEL_R::new(((self.bits >> 12) & 0x0f) as u8)
351    }
352}
353impl W {
354    #[doc = "Bit 0 - Conversion Mode"]
355    #[inline(always)]
356    pub fn convmode(&mut self) -> CONVMODE_W {
357        CONVMODE_W::new(self)
358    }
359    #[doc = "Bits 4:6 - Channel 1 Trigger Mode"]
360    #[inline(always)]
361    pub fn trigmode(&mut self) -> TRIGMODE_W {
362        TRIGMODE_W::new(self)
363    }
364    #[doc = "Bit 8 - Channel 1 PRS Asynchronous Enable"]
365    #[inline(always)]
366    pub fn prsasync(&mut self) -> PRSASYNC_W {
367        PRSASYNC_W::new(self)
368    }
369    #[doc = "Bits 12:15 - Channel 1 PRS Trigger Select"]
370    #[inline(always)]
371    pub fn prssel(&mut self) -> PRSSEL_W {
372        PRSSEL_W::new(self)
373    }
374    #[doc = "Writes raw bits to the register."]
375    #[inline(always)]
376    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
377        self.0.bits(bits);
378        self
379    }
380}
381#[doc = "Channel 1 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 [ch1ctrl](index.html) module"]
382pub struct CH1CTRL_SPEC;
383impl crate::RegisterSpec for CH1CTRL_SPEC {
384    type Ux = u32;
385}
386#[doc = "`read()` method returns [ch1ctrl::R](R) reader structure"]
387impl crate::Readable for CH1CTRL_SPEC {
388    type Reader = R;
389}
390#[doc = "`write(|w| ..)` method takes [ch1ctrl::W](W) writer structure"]
391impl crate::Writable for CH1CTRL_SPEC {
392    type Writer = W;
393}
394#[doc = "`reset()` method sets CH1CTRL to value 0"]
395impl crate::Resettable for CH1CTRL_SPEC {
396    #[inline(always)]
397    fn reset_value() -> Self::Ux {
398        0
399    }
400}