efm32g222_pac/prs/
ch7_ctrl.rs

1#[doc = "Register `CH7_CTRL` reader"]
2pub struct R(crate::R<CH7_CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CH7_CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CH7_CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CH7_CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CH7_CTRL` writer"]
17pub struct W(crate::W<CH7_CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CH7_CTRL_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<CH7_CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CH7_CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SIGSEL` reader - Signal Select"]
38pub type SIGSEL_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `SIGSEL` writer - Signal Select"]
40pub type SIGSEL_W<'a> = crate::FieldWriter<'a, u32, CH7_CTRL_SPEC, u8, u8, 3, 0>;
41#[doc = "Source Select\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum SOURCESEL_A {
45    #[doc = "0: No source selected"]
46    NONE = 0,
47    #[doc = "1: Voltage Comparator"]
48    VCMP = 1,
49    #[doc = "2: Analog Comparator 0"]
50    ACMP0 = 2,
51    #[doc = "3: Analog Comparator 1"]
52    ACMP1 = 3,
53    #[doc = "6: Digital to Analog Converter 0"]
54    DAC0 = 6,
55    #[doc = "8: Analog to Digital Converter 0"]
56    ADC0 = 8,
57    #[doc = "16: Universal Synchronous/Asynchronous Receiver/Transmitter 0"]
58    USART0 = 16,
59    #[doc = "17: Universal Synchronous/Asynchronous Receiver/Transmitter 1"]
60    USART1 = 17,
61    #[doc = "28: Timer 0"]
62    TIMER0 = 28,
63    #[doc = "29: Timer 1"]
64    TIMER1 = 29,
65    #[doc = "30: Timer 2"]
66    TIMER2 = 30,
67    #[doc = "40: Real-Time Counter"]
68    RTC = 40,
69    #[doc = "48: General purpose Input/Output"]
70    GPIOL = 48,
71    #[doc = "49: General purpose Input/Output"]
72    GPIOH = 49,
73}
74impl From<SOURCESEL_A> for u8 {
75    #[inline(always)]
76    fn from(variant: SOURCESEL_A) -> Self {
77        variant as _
78    }
79}
80#[doc = "Field `SOURCESEL` reader - Source Select"]
81pub type SOURCESEL_R = crate::FieldReader<u8, SOURCESEL_A>;
82impl SOURCESEL_R {
83    #[doc = "Get enumerated values variant"]
84    #[inline(always)]
85    pub fn variant(&self) -> Option<SOURCESEL_A> {
86        match self.bits {
87            0 => Some(SOURCESEL_A::NONE),
88            1 => Some(SOURCESEL_A::VCMP),
89            2 => Some(SOURCESEL_A::ACMP0),
90            3 => Some(SOURCESEL_A::ACMP1),
91            6 => Some(SOURCESEL_A::DAC0),
92            8 => Some(SOURCESEL_A::ADC0),
93            16 => Some(SOURCESEL_A::USART0),
94            17 => Some(SOURCESEL_A::USART1),
95            28 => Some(SOURCESEL_A::TIMER0),
96            29 => Some(SOURCESEL_A::TIMER1),
97            30 => Some(SOURCESEL_A::TIMER2),
98            40 => Some(SOURCESEL_A::RTC),
99            48 => Some(SOURCESEL_A::GPIOL),
100            49 => Some(SOURCESEL_A::GPIOH),
101            _ => None,
102        }
103    }
104    #[doc = "Checks if the value of the field is `NONE`"]
105    #[inline(always)]
106    pub fn is_none(&self) -> bool {
107        *self == SOURCESEL_A::NONE
108    }
109    #[doc = "Checks if the value of the field is `VCMP`"]
110    #[inline(always)]
111    pub fn is_vcmp(&self) -> bool {
112        *self == SOURCESEL_A::VCMP
113    }
114    #[doc = "Checks if the value of the field is `ACMP0`"]
115    #[inline(always)]
116    pub fn is_acmp0(&self) -> bool {
117        *self == SOURCESEL_A::ACMP0
118    }
119    #[doc = "Checks if the value of the field is `ACMP1`"]
120    #[inline(always)]
121    pub fn is_acmp1(&self) -> bool {
122        *self == SOURCESEL_A::ACMP1
123    }
124    #[doc = "Checks if the value of the field is `DAC0`"]
125    #[inline(always)]
126    pub fn is_dac0(&self) -> bool {
127        *self == SOURCESEL_A::DAC0
128    }
129    #[doc = "Checks if the value of the field is `ADC0`"]
130    #[inline(always)]
131    pub fn is_adc0(&self) -> bool {
132        *self == SOURCESEL_A::ADC0
133    }
134    #[doc = "Checks if the value of the field is `USART0`"]
135    #[inline(always)]
136    pub fn is_usart0(&self) -> bool {
137        *self == SOURCESEL_A::USART0
138    }
139    #[doc = "Checks if the value of the field is `USART1`"]
140    #[inline(always)]
141    pub fn is_usart1(&self) -> bool {
142        *self == SOURCESEL_A::USART1
143    }
144    #[doc = "Checks if the value of the field is `TIMER0`"]
145    #[inline(always)]
146    pub fn is_timer0(&self) -> bool {
147        *self == SOURCESEL_A::TIMER0
148    }
149    #[doc = "Checks if the value of the field is `TIMER1`"]
150    #[inline(always)]
151    pub fn is_timer1(&self) -> bool {
152        *self == SOURCESEL_A::TIMER1
153    }
154    #[doc = "Checks if the value of the field is `TIMER2`"]
155    #[inline(always)]
156    pub fn is_timer2(&self) -> bool {
157        *self == SOURCESEL_A::TIMER2
158    }
159    #[doc = "Checks if the value of the field is `RTC`"]
160    #[inline(always)]
161    pub fn is_rtc(&self) -> bool {
162        *self == SOURCESEL_A::RTC
163    }
164    #[doc = "Checks if the value of the field is `GPIOL`"]
165    #[inline(always)]
166    pub fn is_gpiol(&self) -> bool {
167        *self == SOURCESEL_A::GPIOL
168    }
169    #[doc = "Checks if the value of the field is `GPIOH`"]
170    #[inline(always)]
171    pub fn is_gpioh(&self) -> bool {
172        *self == SOURCESEL_A::GPIOH
173    }
174}
175#[doc = "Field `SOURCESEL` writer - Source Select"]
176pub type SOURCESEL_W<'a> = crate::FieldWriter<'a, u32, CH7_CTRL_SPEC, u8, SOURCESEL_A, 6, 16>;
177impl<'a> SOURCESEL_W<'a> {
178    #[doc = "No source selected"]
179    #[inline(always)]
180    pub fn none(self) -> &'a mut W {
181        self.variant(SOURCESEL_A::NONE)
182    }
183    #[doc = "Voltage Comparator"]
184    #[inline(always)]
185    pub fn vcmp(self) -> &'a mut W {
186        self.variant(SOURCESEL_A::VCMP)
187    }
188    #[doc = "Analog Comparator 0"]
189    #[inline(always)]
190    pub fn acmp0(self) -> &'a mut W {
191        self.variant(SOURCESEL_A::ACMP0)
192    }
193    #[doc = "Analog Comparator 1"]
194    #[inline(always)]
195    pub fn acmp1(self) -> &'a mut W {
196        self.variant(SOURCESEL_A::ACMP1)
197    }
198    #[doc = "Digital to Analog Converter 0"]
199    #[inline(always)]
200    pub fn dac0(self) -> &'a mut W {
201        self.variant(SOURCESEL_A::DAC0)
202    }
203    #[doc = "Analog to Digital Converter 0"]
204    #[inline(always)]
205    pub fn adc0(self) -> &'a mut W {
206        self.variant(SOURCESEL_A::ADC0)
207    }
208    #[doc = "Universal Synchronous/Asynchronous Receiver/Transmitter 0"]
209    #[inline(always)]
210    pub fn usart0(self) -> &'a mut W {
211        self.variant(SOURCESEL_A::USART0)
212    }
213    #[doc = "Universal Synchronous/Asynchronous Receiver/Transmitter 1"]
214    #[inline(always)]
215    pub fn usart1(self) -> &'a mut W {
216        self.variant(SOURCESEL_A::USART1)
217    }
218    #[doc = "Timer 0"]
219    #[inline(always)]
220    pub fn timer0(self) -> &'a mut W {
221        self.variant(SOURCESEL_A::TIMER0)
222    }
223    #[doc = "Timer 1"]
224    #[inline(always)]
225    pub fn timer1(self) -> &'a mut W {
226        self.variant(SOURCESEL_A::TIMER1)
227    }
228    #[doc = "Timer 2"]
229    #[inline(always)]
230    pub fn timer2(self) -> &'a mut W {
231        self.variant(SOURCESEL_A::TIMER2)
232    }
233    #[doc = "Real-Time Counter"]
234    #[inline(always)]
235    pub fn rtc(self) -> &'a mut W {
236        self.variant(SOURCESEL_A::RTC)
237    }
238    #[doc = "General purpose Input/Output"]
239    #[inline(always)]
240    pub fn gpiol(self) -> &'a mut W {
241        self.variant(SOURCESEL_A::GPIOL)
242    }
243    #[doc = "General purpose Input/Output"]
244    #[inline(always)]
245    pub fn gpioh(self) -> &'a mut W {
246        self.variant(SOURCESEL_A::GPIOH)
247    }
248}
249#[doc = "Edge Detect Select\n\nValue on reset: 0"]
250#[derive(Clone, Copy, Debug, PartialEq)]
251#[repr(u8)]
252pub enum EDSEL_A {
253    #[doc = "0: Signal is left as it is"]
254    OFF = 0,
255    #[doc = "1: A one HFPERCLK cycle pulse is generated for every positive edge of the incoming signal"]
256    POSEDGE = 1,
257    #[doc = "2: A one HFPERCLK clock cycle pulse is generated for every negative edge of the incoming signal"]
258    NEGEDGE = 2,
259    #[doc = "3: A one HFPERCLK clock cycle pulse is generated for every edge of the incoming signal"]
260    BOTHEDGES = 3,
261}
262impl From<EDSEL_A> for u8 {
263    #[inline(always)]
264    fn from(variant: EDSEL_A) -> Self {
265        variant as _
266    }
267}
268#[doc = "Field `EDSEL` reader - Edge Detect Select"]
269pub type EDSEL_R = crate::FieldReader<u8, EDSEL_A>;
270impl EDSEL_R {
271    #[doc = "Get enumerated values variant"]
272    #[inline(always)]
273    pub fn variant(&self) -> EDSEL_A {
274        match self.bits {
275            0 => EDSEL_A::OFF,
276            1 => EDSEL_A::POSEDGE,
277            2 => EDSEL_A::NEGEDGE,
278            3 => EDSEL_A::BOTHEDGES,
279            _ => unreachable!(),
280        }
281    }
282    #[doc = "Checks if the value of the field is `OFF`"]
283    #[inline(always)]
284    pub fn is_off(&self) -> bool {
285        *self == EDSEL_A::OFF
286    }
287    #[doc = "Checks if the value of the field is `POSEDGE`"]
288    #[inline(always)]
289    pub fn is_posedge(&self) -> bool {
290        *self == EDSEL_A::POSEDGE
291    }
292    #[doc = "Checks if the value of the field is `NEGEDGE`"]
293    #[inline(always)]
294    pub fn is_negedge(&self) -> bool {
295        *self == EDSEL_A::NEGEDGE
296    }
297    #[doc = "Checks if the value of the field is `BOTHEDGES`"]
298    #[inline(always)]
299    pub fn is_bothedges(&self) -> bool {
300        *self == EDSEL_A::BOTHEDGES
301    }
302}
303#[doc = "Field `EDSEL` writer - Edge Detect Select"]
304pub type EDSEL_W<'a> = crate::FieldWriterSafe<'a, u32, CH7_CTRL_SPEC, u8, EDSEL_A, 2, 24>;
305impl<'a> EDSEL_W<'a> {
306    #[doc = "Signal is left as it is"]
307    #[inline(always)]
308    pub fn off(self) -> &'a mut W {
309        self.variant(EDSEL_A::OFF)
310    }
311    #[doc = "A one HFPERCLK cycle pulse is generated for every positive edge of the incoming signal"]
312    #[inline(always)]
313    pub fn posedge(self) -> &'a mut W {
314        self.variant(EDSEL_A::POSEDGE)
315    }
316    #[doc = "A one HFPERCLK clock cycle pulse is generated for every negative edge of the incoming signal"]
317    #[inline(always)]
318    pub fn negedge(self) -> &'a mut W {
319        self.variant(EDSEL_A::NEGEDGE)
320    }
321    #[doc = "A one HFPERCLK clock cycle pulse is generated for every edge of the incoming signal"]
322    #[inline(always)]
323    pub fn bothedges(self) -> &'a mut W {
324        self.variant(EDSEL_A::BOTHEDGES)
325    }
326}
327impl R {
328    #[doc = "Bits 0:2 - Signal Select"]
329    #[inline(always)]
330    pub fn sigsel(&self) -> SIGSEL_R {
331        SIGSEL_R::new((self.bits & 7) as u8)
332    }
333    #[doc = "Bits 16:21 - Source Select"]
334    #[inline(always)]
335    pub fn sourcesel(&self) -> SOURCESEL_R {
336        SOURCESEL_R::new(((self.bits >> 16) & 0x3f) as u8)
337    }
338    #[doc = "Bits 24:25 - Edge Detect Select"]
339    #[inline(always)]
340    pub fn edsel(&self) -> EDSEL_R {
341        EDSEL_R::new(((self.bits >> 24) & 3) as u8)
342    }
343}
344impl W {
345    #[doc = "Bits 0:2 - Signal Select"]
346    #[inline(always)]
347    pub fn sigsel(&mut self) -> SIGSEL_W {
348        SIGSEL_W::new(self)
349    }
350    #[doc = "Bits 16:21 - Source Select"]
351    #[inline(always)]
352    pub fn sourcesel(&mut self) -> SOURCESEL_W {
353        SOURCESEL_W::new(self)
354    }
355    #[doc = "Bits 24:25 - Edge Detect Select"]
356    #[inline(always)]
357    pub fn edsel(&mut self) -> EDSEL_W {
358        EDSEL_W::new(self)
359    }
360    #[doc = "Writes raw bits to the register."]
361    #[inline(always)]
362    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
363        self.0.bits(bits);
364        self
365    }
366}
367#[doc = "Channel 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 [ch7_ctrl](index.html) module"]
368pub struct CH7_CTRL_SPEC;
369impl crate::RegisterSpec for CH7_CTRL_SPEC {
370    type Ux = u32;
371}
372#[doc = "`read()` method returns [ch7_ctrl::R](R) reader structure"]
373impl crate::Readable for CH7_CTRL_SPEC {
374    type Reader = R;
375}
376#[doc = "`write(|w| ..)` method takes [ch7_ctrl::W](W) writer structure"]
377impl crate::Writable for CH7_CTRL_SPEC {
378    type Writer = W;
379}
380#[doc = "`reset()` method sets CH7_CTRL to value 0"]
381impl crate::Resettable for CH7_CTRL_SPEC {
382    #[inline(always)]
383    fn reset_value() -> Self::Ux {
384        0
385    }
386}