efm32gg_pac/efm32gg230/lesense/
ch0_interact.rs1#[doc = "Register `CH0_INTERACT` reader"]
2pub struct R(crate::R<CH0_INTERACT_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CH0_INTERACT_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CH0_INTERACT_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CH0_INTERACT_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CH0_INTERACT` writer"]
17pub struct W(crate::W<CH0_INTERACT_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CH0_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<CH0_INTERACT_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CH0_INTERACT_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `ACMPTHRES` reader - Set ACMP threshold"]
38pub type ACMPTHRES_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `ACMPTHRES` writer - Set ACMP threshold"]
40pub type ACMPTHRES_W<'a, const O: u8> =
41 crate::FieldWriter<'a, u32, CH0_INTERACT_SPEC, u16, u16, 12, O>;
42#[doc = "Field `SAMPLE` reader - Select sample mode"]
43pub type SAMPLE_R = crate::BitReader<bool>;
44#[doc = "Field `SAMPLE` writer - Select sample mode"]
45pub type SAMPLE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH0_INTERACT_SPEC, bool, O>;
46#[doc = "Field `SETIF` reader - Enable interrupt generation"]
47pub type SETIF_R = crate::FieldReader<u8, SETIF_A>;
48#[doc = "Enable interrupt generation\n\nValue on reset: 0"]
49#[derive(Clone, Copy, Debug, PartialEq, Eq)]
50#[repr(u8)]
51pub enum SETIF_A {
52 #[doc = "0: No interrupt is generated"]
53 NONE = 0,
54 #[doc = "1: Set interrupt flag if the sensor triggers."]
55 LEVEL = 1,
56 #[doc = "2: Set interrupt flag on positive edge on the sensor state"]
57 POSEDGE = 2,
58 #[doc = "3: Set interrupt flag on negative edge on the sensor state"]
59 NEGEDGE = 3,
60}
61impl From<SETIF_A> for u8 {
62 #[inline(always)]
63 fn from(variant: SETIF_A) -> Self {
64 variant as _
65 }
66}
67impl SETIF_R {
68 #[doc = "Get enumerated values variant"]
69 #[inline(always)]
70 pub fn variant(&self) -> SETIF_A {
71 match self.bits {
72 0 => SETIF_A::NONE,
73 1 => SETIF_A::LEVEL,
74 2 => SETIF_A::POSEDGE,
75 3 => SETIF_A::NEGEDGE,
76 _ => unreachable!(),
77 }
78 }
79 #[doc = "Checks if the value of the field is `NONE`"]
80 #[inline(always)]
81 pub fn is_none(&self) -> bool {
82 *self == SETIF_A::NONE
83 }
84 #[doc = "Checks if the value of the field is `LEVEL`"]
85 #[inline(always)]
86 pub fn is_level(&self) -> bool {
87 *self == SETIF_A::LEVEL
88 }
89 #[doc = "Checks if the value of the field is `POSEDGE`"]
90 #[inline(always)]
91 pub fn is_posedge(&self) -> bool {
92 *self == SETIF_A::POSEDGE
93 }
94 #[doc = "Checks if the value of the field is `NEGEDGE`"]
95 #[inline(always)]
96 pub fn is_negedge(&self) -> bool {
97 *self == SETIF_A::NEGEDGE
98 }
99}
100#[doc = "Field `SETIF` writer - Enable interrupt generation"]
101pub type SETIF_W<'a, const O: u8> =
102 crate::FieldWriterSafe<'a, u32, CH0_INTERACT_SPEC, u8, SETIF_A, 2, O>;
103impl<'a, const O: u8> SETIF_W<'a, O> {
104 #[doc = "No interrupt is generated"]
105 #[inline(always)]
106 pub fn none(self) -> &'a mut W {
107 self.variant(SETIF_A::NONE)
108 }
109 #[doc = "Set interrupt flag if the sensor triggers."]
110 #[inline(always)]
111 pub fn level(self) -> &'a mut W {
112 self.variant(SETIF_A::LEVEL)
113 }
114 #[doc = "Set interrupt flag on positive edge on the sensor state"]
115 #[inline(always)]
116 pub fn posedge(self) -> &'a mut W {
117 self.variant(SETIF_A::POSEDGE)
118 }
119 #[doc = "Set interrupt flag on negative edge on the sensor state"]
120 #[inline(always)]
121 pub fn negedge(self) -> &'a mut W {
122 self.variant(SETIF_A::NEGEDGE)
123 }
124}
125#[doc = "Field `EXMODE` reader - Set GPIO mode"]
126pub type EXMODE_R = crate::FieldReader<u8, EXMODE_A>;
127#[doc = "Set GPIO mode\n\nValue on reset: 0"]
128#[derive(Clone, Copy, Debug, PartialEq, Eq)]
129#[repr(u8)]
130pub enum EXMODE_A {
131 #[doc = "0: Disabled"]
132 DISABLE = 0,
133 #[doc = "1: Push Pull, GPIO is driven high"]
134 HIGH = 1,
135 #[doc = "2: Push Pull, GPIO is driven low"]
136 LOW = 2,
137 #[doc = "3: DAC output"]
138 DACOUT = 3,
139}
140impl From<EXMODE_A> for u8 {
141 #[inline(always)]
142 fn from(variant: EXMODE_A) -> Self {
143 variant as _
144 }
145}
146impl EXMODE_R {
147 #[doc = "Get enumerated values variant"]
148 #[inline(always)]
149 pub fn variant(&self) -> EXMODE_A {
150 match self.bits {
151 0 => EXMODE_A::DISABLE,
152 1 => EXMODE_A::HIGH,
153 2 => EXMODE_A::LOW,
154 3 => EXMODE_A::DACOUT,
155 _ => unreachable!(),
156 }
157 }
158 #[doc = "Checks if the value of the field is `DISABLE`"]
159 #[inline(always)]
160 pub fn is_disable(&self) -> bool {
161 *self == EXMODE_A::DISABLE
162 }
163 #[doc = "Checks if the value of the field is `HIGH`"]
164 #[inline(always)]
165 pub fn is_high(&self) -> bool {
166 *self == EXMODE_A::HIGH
167 }
168 #[doc = "Checks if the value of the field is `LOW`"]
169 #[inline(always)]
170 pub fn is_low(&self) -> bool {
171 *self == EXMODE_A::LOW
172 }
173 #[doc = "Checks if the value of the field is `DACOUT`"]
174 #[inline(always)]
175 pub fn is_dacout(&self) -> bool {
176 *self == EXMODE_A::DACOUT
177 }
178}
179#[doc = "Field `EXMODE` writer - Set GPIO mode"]
180pub type EXMODE_W<'a, const O: u8> =
181 crate::FieldWriterSafe<'a, u32, CH0_INTERACT_SPEC, u8, EXMODE_A, 2, O>;
182impl<'a, const O: u8> EXMODE_W<'a, O> {
183 #[doc = "Disabled"]
184 #[inline(always)]
185 pub fn disable(self) -> &'a mut W {
186 self.variant(EXMODE_A::DISABLE)
187 }
188 #[doc = "Push Pull, GPIO is driven high"]
189 #[inline(always)]
190 pub fn high(self) -> &'a mut W {
191 self.variant(EXMODE_A::HIGH)
192 }
193 #[doc = "Push Pull, GPIO is driven low"]
194 #[inline(always)]
195 pub fn low(self) -> &'a mut W {
196 self.variant(EXMODE_A::LOW)
197 }
198 #[doc = "DAC output"]
199 #[inline(always)]
200 pub fn dacout(self) -> &'a mut W {
201 self.variant(EXMODE_A::DACOUT)
202 }
203}
204#[doc = "Field `EXCLK` reader - Select clock used for excitation timing"]
205pub type EXCLK_R = crate::BitReader<bool>;
206#[doc = "Field `EXCLK` writer - Select clock used for excitation timing"]
207pub type EXCLK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH0_INTERACT_SPEC, bool, O>;
208#[doc = "Field `SAMPLECLK` reader - Select clock used for timing of sample delay"]
209pub type SAMPLECLK_R = crate::BitReader<bool>;
210#[doc = "Field `SAMPLECLK` writer - Select clock used for timing of sample delay"]
211pub type SAMPLECLK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH0_INTERACT_SPEC, bool, O>;
212#[doc = "Field `ALTEX` reader - Use alternative excite pin"]
213pub type ALTEX_R = crate::BitReader<bool>;
214#[doc = "Field `ALTEX` writer - Use alternative excite pin"]
215pub type ALTEX_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH0_INTERACT_SPEC, bool, O>;
216impl R {
217 #[doc = "Bits 0:11 - Set ACMP threshold"]
218 #[inline(always)]
219 pub fn acmpthres(&self) -> ACMPTHRES_R {
220 ACMPTHRES_R::new((self.bits & 0x0fff) as u16)
221 }
222 #[doc = "Bit 12 - Select sample mode"]
223 #[inline(always)]
224 pub fn sample(&self) -> SAMPLE_R {
225 SAMPLE_R::new(((self.bits >> 12) & 1) != 0)
226 }
227 #[doc = "Bits 13:14 - Enable interrupt generation"]
228 #[inline(always)]
229 pub fn setif(&self) -> SETIF_R {
230 SETIF_R::new(((self.bits >> 13) & 3) as u8)
231 }
232 #[doc = "Bits 15:16 - Set GPIO mode"]
233 #[inline(always)]
234 pub fn exmode(&self) -> EXMODE_R {
235 EXMODE_R::new(((self.bits >> 15) & 3) as u8)
236 }
237 #[doc = "Bit 17 - Select clock used for excitation timing"]
238 #[inline(always)]
239 pub fn exclk(&self) -> EXCLK_R {
240 EXCLK_R::new(((self.bits >> 17) & 1) != 0)
241 }
242 #[doc = "Bit 18 - Select clock used for timing of sample delay"]
243 #[inline(always)]
244 pub fn sampleclk(&self) -> SAMPLECLK_R {
245 SAMPLECLK_R::new(((self.bits >> 18) & 1) != 0)
246 }
247 #[doc = "Bit 19 - Use alternative excite pin"]
248 #[inline(always)]
249 pub fn altex(&self) -> ALTEX_R {
250 ALTEX_R::new(((self.bits >> 19) & 1) != 0)
251 }
252}
253impl W {
254 #[doc = "Bits 0:11 - Set ACMP threshold"]
255 #[inline(always)]
256 #[must_use]
257 pub fn acmpthres(&mut self) -> ACMPTHRES_W<0> {
258 ACMPTHRES_W::new(self)
259 }
260 #[doc = "Bit 12 - Select sample mode"]
261 #[inline(always)]
262 #[must_use]
263 pub fn sample(&mut self) -> SAMPLE_W<12> {
264 SAMPLE_W::new(self)
265 }
266 #[doc = "Bits 13:14 - Enable interrupt generation"]
267 #[inline(always)]
268 #[must_use]
269 pub fn setif(&mut self) -> SETIF_W<13> {
270 SETIF_W::new(self)
271 }
272 #[doc = "Bits 15:16 - Set GPIO mode"]
273 #[inline(always)]
274 #[must_use]
275 pub fn exmode(&mut self) -> EXMODE_W<15> {
276 EXMODE_W::new(self)
277 }
278 #[doc = "Bit 17 - Select clock used for excitation timing"]
279 #[inline(always)]
280 #[must_use]
281 pub fn exclk(&mut self) -> EXCLK_W<17> {
282 EXCLK_W::new(self)
283 }
284 #[doc = "Bit 18 - Select clock used for timing of sample delay"]
285 #[inline(always)]
286 #[must_use]
287 pub fn sampleclk(&mut self) -> SAMPLECLK_W<18> {
288 SAMPLECLK_W::new(self)
289 }
290 #[doc = "Bit 19 - Use alternative excite pin"]
291 #[inline(always)]
292 #[must_use]
293 pub fn altex(&mut self) -> ALTEX_W<19> {
294 ALTEX_W::new(self)
295 }
296 #[doc = "Writes raw bits to the register."]
297 #[inline(always)]
298 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
299 self.0.bits(bits);
300 self
301 }
302}
303#[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 [ch0_interact](index.html) module"]
304pub struct CH0_INTERACT_SPEC;
305impl crate::RegisterSpec for CH0_INTERACT_SPEC {
306 type Ux = u32;
307}
308#[doc = "`read()` method returns [ch0_interact::R](R) reader structure"]
309impl crate::Readable for CH0_INTERACT_SPEC {
310 type Reader = R;
311}
312#[doc = "`write(|w| ..)` method takes [ch0_interact::W](W) writer structure"]
313impl crate::Writable for CH0_INTERACT_SPEC {
314 type Writer = W;
315 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
316 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
317}
318#[doc = "`reset()` method sets CH0_INTERACT to value 0"]
319impl crate::Resettable for CH0_INTERACT_SPEC {
320 const RESET_VALUE: Self::Ux = 0;
321}