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