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