efm32tg11b_pac/efm32tg11b120/lesense/
ch7_eval.rs1#[doc = "Register `CH7_EVAL` reader"]
2pub struct R(crate::R<CH7_EVAL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CH7_EVAL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CH7_EVAL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CH7_EVAL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CH7_EVAL` writer"]
17pub struct W(crate::W<CH7_EVAL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CH7_EVAL_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_EVAL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CH7_EVAL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `COMPTHRES` reader - Decision Threshold for Sensor Data"]
38pub type COMPTHRES_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `COMPTHRES` writer - Decision Threshold for Sensor Data"]
40pub type COMPTHRES_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CH7_EVAL_SPEC, u16, u16, 16, O>;
41#[doc = "Field `COMP` reader - Select Mode for Threshold Comparison"]
42pub type COMP_R = crate::BitReader<bool>;
43#[doc = "Field `COMP` writer - Select Mode for Threshold Comparison"]
44pub type COMP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH7_EVAL_SPEC, bool, O>;
45#[doc = "Field `DECODE` reader - Send Result to Decoder"]
46pub type DECODE_R = crate::BitReader<bool>;
47#[doc = "Field `DECODE` writer - Send Result to Decoder"]
48pub type DECODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH7_EVAL_SPEC, bool, O>;
49#[doc = "Field `STRSAMPLE` reader - Enable Storing of Sensor Sample in Result Buffer"]
50pub type STRSAMPLE_R = crate::FieldReader<u8, STRSAMPLE_A>;
51#[doc = "Enable Storing of Sensor Sample in Result Buffer\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53#[repr(u8)]
54pub enum STRSAMPLE_A {
55 #[doc = "0: Nothing will be stored in the result buffer."]
56 DISABLE = 0,
57 #[doc = "1: The sensor sample data will be stored in the result buffer."]
58 DATA = 1,
59 #[doc = "2: The data source (i.e., the channel) will be stored alongside the sensor sample data."]
60 DATASRC = 2,
61}
62impl From<STRSAMPLE_A> for u8 {
63 #[inline(always)]
64 fn from(variant: STRSAMPLE_A) -> Self {
65 variant as _
66 }
67}
68impl STRSAMPLE_R {
69 #[doc = "Get enumerated values variant"]
70 #[inline(always)]
71 pub fn variant(&self) -> Option<STRSAMPLE_A> {
72 match self.bits {
73 0 => Some(STRSAMPLE_A::DISABLE),
74 1 => Some(STRSAMPLE_A::DATA),
75 2 => Some(STRSAMPLE_A::DATASRC),
76 _ => None,
77 }
78 }
79 #[doc = "Checks if the value of the field is `DISABLE`"]
80 #[inline(always)]
81 pub fn is_disable(&self) -> bool {
82 *self == STRSAMPLE_A::DISABLE
83 }
84 #[doc = "Checks if the value of the field is `DATA`"]
85 #[inline(always)]
86 pub fn is_data(&self) -> bool {
87 *self == STRSAMPLE_A::DATA
88 }
89 #[doc = "Checks if the value of the field is `DATASRC`"]
90 #[inline(always)]
91 pub fn is_datasrc(&self) -> bool {
92 *self == STRSAMPLE_A::DATASRC
93 }
94}
95#[doc = "Field `STRSAMPLE` writer - Enable Storing of Sensor Sample in Result Buffer"]
96pub type STRSAMPLE_W<'a, const O: u8> =
97 crate::FieldWriter<'a, u32, CH7_EVAL_SPEC, u8, STRSAMPLE_A, 2, O>;
98impl<'a, const O: u8> STRSAMPLE_W<'a, O> {
99 #[doc = "Nothing will be stored in the result buffer."]
100 #[inline(always)]
101 pub fn disable(self) -> &'a mut W {
102 self.variant(STRSAMPLE_A::DISABLE)
103 }
104 #[doc = "The sensor sample data will be stored in the result buffer."]
105 #[inline(always)]
106 pub fn data(self) -> &'a mut W {
107 self.variant(STRSAMPLE_A::DATA)
108 }
109 #[doc = "The data source (i.e., the channel) will be stored alongside the sensor sample data."]
110 #[inline(always)]
111 pub fn datasrc(self) -> &'a mut W {
112 self.variant(STRSAMPLE_A::DATASRC)
113 }
114}
115#[doc = "Field `SCANRESINV` reader - Enable Inversion of Result"]
116pub type SCANRESINV_R = crate::BitReader<bool>;
117#[doc = "Field `SCANRESINV` writer - Enable Inversion of Result"]
118pub type SCANRESINV_W<'a, const O: u8> = crate::BitWriter<'a, u32, CH7_EVAL_SPEC, bool, O>;
119#[doc = "Field `MODE` reader - Configure Evaluation Mode"]
120pub type MODE_R = crate::FieldReader<u8, MODE_A>;
121#[doc = "Configure Evaluation Mode\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123#[repr(u8)]
124pub enum MODE_A {
125 #[doc = "0: Threshold comparison is used to evaluate sensor result"]
126 THRES = 0,
127 #[doc = "1: Sliding window is used to evaluate sensor result"]
128 SLIDINGWIN = 1,
129 #[doc = "2: Step detection is used to evaluate sensor result"]
130 STEPDET = 2,
131}
132impl From<MODE_A> for u8 {
133 #[inline(always)]
134 fn from(variant: MODE_A) -> Self {
135 variant as _
136 }
137}
138impl MODE_R {
139 #[doc = "Get enumerated values variant"]
140 #[inline(always)]
141 pub fn variant(&self) -> Option<MODE_A> {
142 match self.bits {
143 0 => Some(MODE_A::THRES),
144 1 => Some(MODE_A::SLIDINGWIN),
145 2 => Some(MODE_A::STEPDET),
146 _ => None,
147 }
148 }
149 #[doc = "Checks if the value of the field is `THRES`"]
150 #[inline(always)]
151 pub fn is_thres(&self) -> bool {
152 *self == MODE_A::THRES
153 }
154 #[doc = "Checks if the value of the field is `SLIDINGWIN`"]
155 #[inline(always)]
156 pub fn is_slidingwin(&self) -> bool {
157 *self == MODE_A::SLIDINGWIN
158 }
159 #[doc = "Checks if the value of the field is `STEPDET`"]
160 #[inline(always)]
161 pub fn is_stepdet(&self) -> bool {
162 *self == MODE_A::STEPDET
163 }
164}
165#[doc = "Field `MODE` writer - Configure Evaluation Mode"]
166pub type MODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CH7_EVAL_SPEC, u8, MODE_A, 2, O>;
167impl<'a, const O: u8> MODE_W<'a, O> {
168 #[doc = "Threshold comparison is used to evaluate sensor result"]
169 #[inline(always)]
170 pub fn thres(self) -> &'a mut W {
171 self.variant(MODE_A::THRES)
172 }
173 #[doc = "Sliding window is used to evaluate sensor result"]
174 #[inline(always)]
175 pub fn slidingwin(self) -> &'a mut W {
176 self.variant(MODE_A::SLIDINGWIN)
177 }
178 #[doc = "Step detection is used to evaluate sensor result"]
179 #[inline(always)]
180 pub fn stepdet(self) -> &'a mut W {
181 self.variant(MODE_A::STEPDET)
182 }
183}
184impl R {
185 #[doc = "Bits 0:15 - Decision Threshold for Sensor Data"]
186 #[inline(always)]
187 pub fn compthres(&self) -> COMPTHRES_R {
188 COMPTHRES_R::new((self.bits & 0xffff) as u16)
189 }
190 #[doc = "Bit 16 - Select Mode for Threshold Comparison"]
191 #[inline(always)]
192 pub fn comp(&self) -> COMP_R {
193 COMP_R::new(((self.bits >> 16) & 1) != 0)
194 }
195 #[doc = "Bit 17 - Send Result to Decoder"]
196 #[inline(always)]
197 pub fn decode(&self) -> DECODE_R {
198 DECODE_R::new(((self.bits >> 17) & 1) != 0)
199 }
200 #[doc = "Bits 18:19 - Enable Storing of Sensor Sample in Result Buffer"]
201 #[inline(always)]
202 pub fn strsample(&self) -> STRSAMPLE_R {
203 STRSAMPLE_R::new(((self.bits >> 18) & 3) as u8)
204 }
205 #[doc = "Bit 20 - Enable Inversion of Result"]
206 #[inline(always)]
207 pub fn scanresinv(&self) -> SCANRESINV_R {
208 SCANRESINV_R::new(((self.bits >> 20) & 1) != 0)
209 }
210 #[doc = "Bits 21:22 - Configure Evaluation Mode"]
211 #[inline(always)]
212 pub fn mode(&self) -> MODE_R {
213 MODE_R::new(((self.bits >> 21) & 3) as u8)
214 }
215}
216impl W {
217 #[doc = "Bits 0:15 - Decision Threshold for Sensor Data"]
218 #[inline(always)]
219 #[must_use]
220 pub fn compthres(&mut self) -> COMPTHRES_W<0> {
221 COMPTHRES_W::new(self)
222 }
223 #[doc = "Bit 16 - Select Mode for Threshold Comparison"]
224 #[inline(always)]
225 #[must_use]
226 pub fn comp(&mut self) -> COMP_W<16> {
227 COMP_W::new(self)
228 }
229 #[doc = "Bit 17 - Send Result to Decoder"]
230 #[inline(always)]
231 #[must_use]
232 pub fn decode(&mut self) -> DECODE_W<17> {
233 DECODE_W::new(self)
234 }
235 #[doc = "Bits 18:19 - Enable Storing of Sensor Sample in Result Buffer"]
236 #[inline(always)]
237 #[must_use]
238 pub fn strsample(&mut self) -> STRSAMPLE_W<18> {
239 STRSAMPLE_W::new(self)
240 }
241 #[doc = "Bit 20 - Enable Inversion of Result"]
242 #[inline(always)]
243 #[must_use]
244 pub fn scanresinv(&mut self) -> SCANRESINV_W<20> {
245 SCANRESINV_W::new(self)
246 }
247 #[doc = "Bits 21:22 - Configure Evaluation Mode"]
248 #[inline(always)]
249 #[must_use]
250 pub fn mode(&mut self) -> MODE_W<21> {
251 MODE_W::new(self)
252 }
253 #[doc = "Writes raw bits to the register."]
254 #[inline(always)]
255 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
256 self.0.bits(bits);
257 self
258 }
259}
260#[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 [ch7_eval](index.html) module"]
261pub struct CH7_EVAL_SPEC;
262impl crate::RegisterSpec for CH7_EVAL_SPEC {
263 type Ux = u32;
264}
265#[doc = "`read()` method returns [ch7_eval::R](R) reader structure"]
266impl crate::Readable for CH7_EVAL_SPEC {
267 type Reader = R;
268}
269#[doc = "`write(|w| ..)` method takes [ch7_eval::W](W) writer structure"]
270impl crate::Writable for CH7_EVAL_SPEC {
271 type Writer = W;
272 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
273 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
274}
275#[doc = "`reset()` method sets CH7_EVAL to value 0"]
276impl crate::Resettable for CH7_EVAL_SPEC {
277 const RESET_VALUE: Self::Ux = 0;
278}