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