efm32gg12b_pac/efm32gg12b830/lesense/
ch14_interact.rs

1#[doc = "Register `CH14_INTERACT` reader"]
2pub struct R(crate::R<CH14_INTERACT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CH14_INTERACT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CH14_INTERACT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CH14_INTERACT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CH14_INTERACT` writer"]
17pub struct W(crate::W<CH14_INTERACT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CH14_INTERACT_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<CH14_INTERACT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CH14_INTERACT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `THRES` reader - ACMP Threshold or VDAC Data"]
38pub type THRES_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `THRES` writer - ACMP Threshold or VDAC Data"]
40pub type THRES_W<'a, const O: u8> =
41    crate::FieldWriter<'a, u32, CH14_INTERACT_SPEC, u16, u16, 12, O>;
42#[doc = "Field `SAMPLE` reader - Select Sample Mode"]
43pub type SAMPLE_R = crate::FieldReader<u8, SAMPLE_A>;
44#[doc = "Select Sample Mode\n\nValue on reset: 0"]
45#[derive(Clone, Copy, Debug, PartialEq, Eq)]
46#[repr(u8)]
47pub enum SAMPLE_A {
48    #[doc = "0: Counter output will be used in evaluation"]
49    ACMPCOUNT = 0,
50    #[doc = "1: ACMP output will be used in evaluation"]
51    ACMP = 1,
52    #[doc = "2: ADC output will be used in evaluation"]
53    ADC = 2,
54    #[doc = "3: Differential ADC output will be used in evaluation"]
55    ADCDIFF = 3,
56}
57impl From<SAMPLE_A> for u8 {
58    #[inline(always)]
59    fn from(variant: SAMPLE_A) -> Self {
60        variant as _
61    }
62}
63impl SAMPLE_R {
64    #[doc = "Get enumerated values variant"]
65    #[inline(always)]
66    pub fn variant(&self) -> SAMPLE_A {
67        match self.bits {
68            0 => SAMPLE_A::ACMPCOUNT,
69            1 => SAMPLE_A::ACMP,
70            2 => SAMPLE_A::ADC,
71            3 => SAMPLE_A::ADCDIFF,
72            _ => unreachable!(),
73        }
74    }
75    #[doc = "Checks if the value of the field is `ACMPCOUNT`"]
76    #[inline(always)]
77    pub fn is_acmpcount(&self) -> bool {
78        *self == SAMPLE_A::ACMPCOUNT
79    }
80    #[doc = "Checks if the value of the field is `ACMP`"]
81    #[inline(always)]
82    pub fn is_acmp(&self) -> bool {
83        *self == SAMPLE_A::ACMP
84    }
85    #[doc = "Checks if the value of the field is `ADC`"]
86    #[inline(always)]
87    pub fn is_adc(&self) -> bool {
88        *self == SAMPLE_A::ADC
89    }
90    #[doc = "Checks if the value of the field is `ADCDIFF`"]
91    #[inline(always)]
92    pub fn is_adcdiff(&self) -> bool {
93        *self == SAMPLE_A::ADCDIFF
94    }
95}
96#[doc = "Field `SAMPLE` writer - Select Sample Mode"]
97pub type SAMPLE_W<'a, const O: u8> =
98    crate::FieldWriterSafe<'a, u32, CH14_INTERACT_SPEC, u8, SAMPLE_A, 2, O>;
99impl<'a, const O: u8> SAMPLE_W<'a, O> {
100    #[doc = "Counter output will be used in evaluation"]
101    #[inline(always)]
102    pub fn acmpcount(self) -> &'a mut W {
103        self.variant(SAMPLE_A::ACMPCOUNT)
104    }
105    #[doc = "ACMP output will be used in evaluation"]
106    #[inline(always)]
107    pub fn acmp(self) -> &'a mut W {
108        self.variant(SAMPLE_A::ACMP)
109    }
110    #[doc = "ADC output will be used in evaluation"]
111    #[inline(always)]
112    pub fn adc(self) -> &'a mut W {
113        self.variant(SAMPLE_A::ADC)
114    }
115    #[doc = "Differential ADC output will be used in evaluation"]
116    #[inline(always)]
117    pub fn adcdiff(self) -> &'a mut W {
118        self.variant(SAMPLE_A::ADCDIFF)
119    }
120}
121#[doc = "Field `SETIF` reader - Enable Interrupt Generation"]
122pub type SETIF_R = crate::FieldReader<u8, SETIF_A>;
123#[doc = "Enable Interrupt Generation\n\nValue on reset: 0"]
124#[derive(Clone, Copy, Debug, PartialEq, Eq)]
125#[repr(u8)]
126pub enum SETIF_A {
127    #[doc = "0: No interrupt is generated"]
128    NONE = 0,
129    #[doc = "1: Set interrupt flag if the sensor triggers."]
130    LEVEL = 1,
131    #[doc = "2: Set interrupt flag on positive edge of the sensor state"]
132    POSEDGE = 2,
133    #[doc = "3: Set interrupt flag on negative edge of the sensor state"]
134    NEGEDGE = 3,
135    #[doc = "4: Set interrupt flag on both edges of the sensor state"]
136    BOTHEDGES = 4,
137}
138impl From<SETIF_A> for u8 {
139    #[inline(always)]
140    fn from(variant: SETIF_A) -> Self {
141        variant as _
142    }
143}
144impl SETIF_R {
145    #[doc = "Get enumerated values variant"]
146    #[inline(always)]
147    pub fn variant(&self) -> Option<SETIF_A> {
148        match self.bits {
149            0 => Some(SETIF_A::NONE),
150            1 => Some(SETIF_A::LEVEL),
151            2 => Some(SETIF_A::POSEDGE),
152            3 => Some(SETIF_A::NEGEDGE),
153            4 => Some(SETIF_A::BOTHEDGES),
154            _ => None,
155        }
156    }
157    #[doc = "Checks if the value of the field is `NONE`"]
158    #[inline(always)]
159    pub fn is_none(&self) -> bool {
160        *self == SETIF_A::NONE
161    }
162    #[doc = "Checks if the value of the field is `LEVEL`"]
163    #[inline(always)]
164    pub fn is_level(&self) -> bool {
165        *self == SETIF_A::LEVEL
166    }
167    #[doc = "Checks if the value of the field is `POSEDGE`"]
168    #[inline(always)]
169    pub fn is_posedge(&self) -> bool {
170        *self == SETIF_A::POSEDGE
171    }
172    #[doc = "Checks if the value of the field is `NEGEDGE`"]
173    #[inline(always)]
174    pub fn is_negedge(&self) -> bool {
175        *self == SETIF_A::NEGEDGE
176    }
177    #[doc = "Checks if the value of the field is `BOTHEDGES`"]
178    #[inline(always)]
179    pub fn is_bothedges(&self) -> bool {
180        *self == SETIF_A::BOTHEDGES
181    }
182}
183#[doc = "Field `SETIF` writer - Enable Interrupt Generation"]
184pub type SETIF_W<'a, const O: u8> =
185    crate::FieldWriter<'a, u32, CH14_INTERACT_SPEC, u8, SETIF_A, 3, O>;
186impl<'a, const O: u8> SETIF_W<'a, O> {
187    #[doc = "No interrupt is generated"]
188    #[inline(always)]
189    pub fn none(self) -> &'a mut W {
190        self.variant(SETIF_A::NONE)
191    }
192    #[doc = "Set interrupt flag if the sensor triggers."]
193    #[inline(always)]
194    pub fn level(self) -> &'a mut W {
195        self.variant(SETIF_A::LEVEL)
196    }
197    #[doc = "Set interrupt flag on positive edge of the sensor state"]
198    #[inline(always)]
199    pub fn posedge(self) -> &'a mut W {
200        self.variant(SETIF_A::POSEDGE)
201    }
202    #[doc = "Set interrupt flag on negative edge of the sensor state"]
203    #[inline(always)]
204    pub fn negedge(self) -> &'a mut W {
205        self.variant(SETIF_A::NEGEDGE)
206    }
207    #[doc = "Set interrupt flag on both edges of the sensor state"]
208    #[inline(always)]
209    pub fn bothedges(self) -> &'a mut W {
210        self.variant(SETIF_A::BOTHEDGES)
211    }
212}
213#[doc = "Field `EXMODE` reader - Set GPIO Mode"]
214pub type EXMODE_R = crate::FieldReader<u8, EXMODE_A>;
215#[doc = "Set GPIO Mode\n\nValue on reset: 0"]
216#[derive(Clone, Copy, Debug, PartialEq, Eq)]
217#[repr(u8)]
218pub enum EXMODE_A {
219    #[doc = "0: Disabled"]
220    DISABLE = 0,
221    #[doc = "1: Push Pull, GPIO is driven high"]
222    HIGH = 1,
223    #[doc = "2: Push Pull, GPIO is driven low"]
224    LOW = 2,
225    #[doc = "3: VDAC output"]
226    DACOUT = 3,
227}
228impl From<EXMODE_A> for u8 {
229    #[inline(always)]
230    fn from(variant: EXMODE_A) -> Self {
231        variant as _
232    }
233}
234impl EXMODE_R {
235    #[doc = "Get enumerated values variant"]
236    #[inline(always)]
237    pub fn variant(&self) -> EXMODE_A {
238        match self.bits {
239            0 => EXMODE_A::DISABLE,
240            1 => EXMODE_A::HIGH,
241            2 => EXMODE_A::LOW,
242            3 => EXMODE_A::DACOUT,
243            _ => unreachable!(),
244        }
245    }
246    #[doc = "Checks if the value of the field is `DISABLE`"]
247    #[inline(always)]
248    pub fn is_disable(&self) -> bool {
249        *self == EXMODE_A::DISABLE
250    }
251    #[doc = "Checks if the value of the field is `HIGH`"]
252    #[inline(always)]
253    pub fn is_high(&self) -> bool {
254        *self == EXMODE_A::HIGH
255    }
256    #[doc = "Checks if the value of the field is `LOW`"]
257    #[inline(always)]
258    pub fn is_low(&self) -> bool {
259        *self == EXMODE_A::LOW
260    }
261    #[doc = "Checks if the value of the field is `DACOUT`"]
262    #[inline(always)]
263    pub fn is_dacout(&self) -> bool {
264        *self == EXMODE_A::DACOUT
265    }
266}
267#[doc = "Field `EXMODE` writer - Set GPIO Mode"]
268pub type EXMODE_W<'a, const O: u8> =
269    crate::FieldWriterSafe<'a, u32, CH14_INTERACT_SPEC, u8, EXMODE_A, 2, O>;
270impl<'a, const O: u8> EXMODE_W<'a, O> {
271    #[doc = "Disabled"]
272    #[inline(always)]
273    pub fn disable(self) -> &'a mut W {
274        self.variant(EXMODE_A::DISABLE)
275    }
276    #[doc = "Push Pull, GPIO is driven high"]
277    #[inline(always)]
278    pub fn high(self) -> &'a mut W {
279        self.variant(EXMODE_A::HIGH)
280    }
281    #[doc = "Push Pull, GPIO is driven low"]
282    #[inline(always)]
283    pub fn low(self) -> &'a mut W {
284        self.variant(EXMODE_A::LOW)
285    }
286    #[doc = "VDAC output"]
287    #[inline(always)]
288    pub fn dacout(self) -> &'a mut W {
289        self.variant(EXMODE_A::DACOUT)
290    }
291}
292#[doc = "Field `EXCLK` reader - Select Clock Used for Excitation Timing"]
293pub type EXCLK_R = crate::BitReader<bool>;
294#[doc = "Field `EXCLK` writer - Select Clock Used for Excitation Timing"]
295pub type EXCLK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH14_INTERACT_SPEC, bool, O>;
296#[doc = "Field `SAMPLECLK` reader - Select Clock Used for Timing of Sample Delay"]
297pub type SAMPLECLK_R = crate::BitReader<bool>;
298#[doc = "Field `SAMPLECLK` writer - Select Clock Used for Timing of Sample Delay"]
299pub type SAMPLECLK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH14_INTERACT_SPEC, bool, O>;
300#[doc = "Field `ALTEX` reader - Use Alternative Excite Pin"]
301pub type ALTEX_R = crate::BitReader<bool>;
302#[doc = "Field `ALTEX` writer - Use Alternative Excite Pin"]
303pub type ALTEX_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH14_INTERACT_SPEC, bool, O>;
304impl R {
305    #[doc = "Bits 0:11 - ACMP Threshold or VDAC Data"]
306    #[inline(always)]
307    pub fn thres(&self) -> THRES_R {
308        THRES_R::new((self.bits & 0x0fff) as u16)
309    }
310    #[doc = "Bits 12:13 - Select Sample Mode"]
311    #[inline(always)]
312    pub fn sample(&self) -> SAMPLE_R {
313        SAMPLE_R::new(((self.bits >> 12) & 3) as u8)
314    }
315    #[doc = "Bits 14:16 - Enable Interrupt Generation"]
316    #[inline(always)]
317    pub fn setif(&self) -> SETIF_R {
318        SETIF_R::new(((self.bits >> 14) & 7) as u8)
319    }
320    #[doc = "Bits 17:18 - Set GPIO Mode"]
321    #[inline(always)]
322    pub fn exmode(&self) -> EXMODE_R {
323        EXMODE_R::new(((self.bits >> 17) & 3) as u8)
324    }
325    #[doc = "Bit 19 - Select Clock Used for Excitation Timing"]
326    #[inline(always)]
327    pub fn exclk(&self) -> EXCLK_R {
328        EXCLK_R::new(((self.bits >> 19) & 1) != 0)
329    }
330    #[doc = "Bit 20 - Select Clock Used for Timing of Sample Delay"]
331    #[inline(always)]
332    pub fn sampleclk(&self) -> SAMPLECLK_R {
333        SAMPLECLK_R::new(((self.bits >> 20) & 1) != 0)
334    }
335    #[doc = "Bit 21 - Use Alternative Excite Pin"]
336    #[inline(always)]
337    pub fn altex(&self) -> ALTEX_R {
338        ALTEX_R::new(((self.bits >> 21) & 1) != 0)
339    }
340}
341impl W {
342    #[doc = "Bits 0:11 - ACMP Threshold or VDAC Data"]
343    #[inline(always)]
344    #[must_use]
345    pub fn thres(&mut self) -> THRES_W<0> {
346        THRES_W::new(self)
347    }
348    #[doc = "Bits 12:13 - Select Sample Mode"]
349    #[inline(always)]
350    #[must_use]
351    pub fn sample(&mut self) -> SAMPLE_W<12> {
352        SAMPLE_W::new(self)
353    }
354    #[doc = "Bits 14:16 - Enable Interrupt Generation"]
355    #[inline(always)]
356    #[must_use]
357    pub fn setif(&mut self) -> SETIF_W<14> {
358        SETIF_W::new(self)
359    }
360    #[doc = "Bits 17:18 - Set GPIO Mode"]
361    #[inline(always)]
362    #[must_use]
363    pub fn exmode(&mut self) -> EXMODE_W<17> {
364        EXMODE_W::new(self)
365    }
366    #[doc = "Bit 19 - Select Clock Used for Excitation Timing"]
367    #[inline(always)]
368    #[must_use]
369    pub fn exclk(&mut self) -> EXCLK_W<19> {
370        EXCLK_W::new(self)
371    }
372    #[doc = "Bit 20 - Select Clock Used for Timing of Sample Delay"]
373    #[inline(always)]
374    #[must_use]
375    pub fn sampleclk(&mut self) -> SAMPLECLK_W<20> {
376        SAMPLECLK_W::new(self)
377    }
378    #[doc = "Bit 21 - Use Alternative Excite Pin"]
379    #[inline(always)]
380    #[must_use]
381    pub fn altex(&mut self) -> ALTEX_W<21> {
382        ALTEX_W::new(self)
383    }
384    #[doc = "Writes raw bits to the register."]
385    #[inline(always)]
386    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
387        self.0.bits(bits);
388        self
389    }
390}
391#[doc = "Scan Configuration\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 [ch14_interact](index.html) module"]
392pub struct CH14_INTERACT_SPEC;
393impl crate::RegisterSpec for CH14_INTERACT_SPEC {
394    type Ux = u32;
395}
396#[doc = "`read()` method returns [ch14_interact::R](R) reader structure"]
397impl crate::Readable for CH14_INTERACT_SPEC {
398    type Reader = R;
399}
400#[doc = "`write(|w| ..)` method takes [ch14_interact::W](W) writer structure"]
401impl crate::Writable for CH14_INTERACT_SPEC {
402    type Writer = W;
403    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
404    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
405}
406#[doc = "`reset()` method sets CH14_INTERACT to value 0"]
407impl crate::Resettable for CH14_INTERACT_SPEC {
408    const RESET_VALUE: Self::Ux = 0;
409}