efm32jg12b_pac/efm32jg12b500/lesense/
ch14_eval.rs

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