efm32tg11b340_pac/lesense/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Configure Scan Mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum SCANMODE_A {
41    #[doc = "0: A new scan is started each time the period counter overflows"]
42    PERIODIC = 0,
43    #[doc = "1: A single scan is performed when START in CMD is set"]
44    ONESHOT = 1,
45    #[doc = "2: Pulse on PRS channel"]
46    PRS = 2,
47}
48impl From<SCANMODE_A> for u8 {
49    #[inline(always)]
50    fn from(variant: SCANMODE_A) -> Self {
51        variant as _
52    }
53}
54#[doc = "Field `SCANMODE` reader - Configure Scan Mode"]
55pub type SCANMODE_R = crate::FieldReader<u8, SCANMODE_A>;
56impl SCANMODE_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<SCANMODE_A> {
60        match self.bits {
61            0 => Some(SCANMODE_A::PERIODIC),
62            1 => Some(SCANMODE_A::ONESHOT),
63            2 => Some(SCANMODE_A::PRS),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `PERIODIC`"]
68    #[inline(always)]
69    pub fn is_periodic(&self) -> bool {
70        *self == SCANMODE_A::PERIODIC
71    }
72    #[doc = "Checks if the value of the field is `ONESHOT`"]
73    #[inline(always)]
74    pub fn is_oneshot(&self) -> bool {
75        *self == SCANMODE_A::ONESHOT
76    }
77    #[doc = "Checks if the value of the field is `PRS`"]
78    #[inline(always)]
79    pub fn is_prs(&self) -> bool {
80        *self == SCANMODE_A::PRS
81    }
82}
83#[doc = "Field `SCANMODE` writer - Configure Scan Mode"]
84pub type SCANMODE_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, SCANMODE_A, 2, 0>;
85impl<'a> SCANMODE_W<'a> {
86    #[doc = "A new scan is started each time the period counter overflows"]
87    #[inline(always)]
88    pub fn periodic(self) -> &'a mut W {
89        self.variant(SCANMODE_A::PERIODIC)
90    }
91    #[doc = "A single scan is performed when START in CMD is set"]
92    #[inline(always)]
93    pub fn oneshot(self) -> &'a mut W {
94        self.variant(SCANMODE_A::ONESHOT)
95    }
96    #[doc = "Pulse on PRS channel"]
97    #[inline(always)]
98    pub fn prs(self) -> &'a mut W {
99        self.variant(SCANMODE_A::PRS)
100    }
101}
102#[doc = "Scan Start PRS Select\n\nValue on reset: 0"]
103#[derive(Clone, Copy, Debug, PartialEq)]
104#[repr(u8)]
105pub enum PRSSEL_A {
106    #[doc = "0: PRS Channel 0 selected as input"]
107    PRSCH0 = 0,
108    #[doc = "1: PRS Channel 1 selected as input"]
109    PRSCH1 = 1,
110    #[doc = "2: PRS Channel 2 selected as input"]
111    PRSCH2 = 2,
112    #[doc = "3: PRS Channel 3 selected as input"]
113    PRSCH3 = 3,
114    #[doc = "4: PRS Channel 4 selected as input"]
115    PRSCH4 = 4,
116    #[doc = "5: PRS Channel 5 selected as input"]
117    PRSCH5 = 5,
118    #[doc = "6: PRS Channel 6 selected as input"]
119    PRSCH6 = 6,
120    #[doc = "7: PRS Channel 7 selected as input"]
121    PRSCH7 = 7,
122}
123impl From<PRSSEL_A> for u8 {
124    #[inline(always)]
125    fn from(variant: PRSSEL_A) -> Self {
126        variant as _
127    }
128}
129#[doc = "Field `PRSSEL` reader - Scan Start PRS Select"]
130pub type PRSSEL_R = crate::FieldReader<u8, PRSSEL_A>;
131impl PRSSEL_R {
132    #[doc = "Get enumerated values variant"]
133    #[inline(always)]
134    pub fn variant(&self) -> PRSSEL_A {
135        match self.bits {
136            0 => PRSSEL_A::PRSCH0,
137            1 => PRSSEL_A::PRSCH1,
138            2 => PRSSEL_A::PRSCH2,
139            3 => PRSSEL_A::PRSCH3,
140            4 => PRSSEL_A::PRSCH4,
141            5 => PRSSEL_A::PRSCH5,
142            6 => PRSSEL_A::PRSCH6,
143            7 => PRSSEL_A::PRSCH7,
144            _ => unreachable!(),
145        }
146    }
147    #[doc = "Checks if the value of the field is `PRSCH0`"]
148    #[inline(always)]
149    pub fn is_prsch0(&self) -> bool {
150        *self == PRSSEL_A::PRSCH0
151    }
152    #[doc = "Checks if the value of the field is `PRSCH1`"]
153    #[inline(always)]
154    pub fn is_prsch1(&self) -> bool {
155        *self == PRSSEL_A::PRSCH1
156    }
157    #[doc = "Checks if the value of the field is `PRSCH2`"]
158    #[inline(always)]
159    pub fn is_prsch2(&self) -> bool {
160        *self == PRSSEL_A::PRSCH2
161    }
162    #[doc = "Checks if the value of the field is `PRSCH3`"]
163    #[inline(always)]
164    pub fn is_prsch3(&self) -> bool {
165        *self == PRSSEL_A::PRSCH3
166    }
167    #[doc = "Checks if the value of the field is `PRSCH4`"]
168    #[inline(always)]
169    pub fn is_prsch4(&self) -> bool {
170        *self == PRSSEL_A::PRSCH4
171    }
172    #[doc = "Checks if the value of the field is `PRSCH5`"]
173    #[inline(always)]
174    pub fn is_prsch5(&self) -> bool {
175        *self == PRSSEL_A::PRSCH5
176    }
177    #[doc = "Checks if the value of the field is `PRSCH6`"]
178    #[inline(always)]
179    pub fn is_prsch6(&self) -> bool {
180        *self == PRSSEL_A::PRSCH6
181    }
182    #[doc = "Checks if the value of the field is `PRSCH7`"]
183    #[inline(always)]
184    pub fn is_prsch7(&self) -> bool {
185        *self == PRSSEL_A::PRSCH7
186    }
187}
188#[doc = "Field `PRSSEL` writer - Scan Start PRS Select"]
189pub type PRSSEL_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, PRSSEL_A, 3, 2>;
190impl<'a> PRSSEL_W<'a> {
191    #[doc = "PRS Channel 0 selected as input"]
192    #[inline(always)]
193    pub fn prsch0(self) -> &'a mut W {
194        self.variant(PRSSEL_A::PRSCH0)
195    }
196    #[doc = "PRS Channel 1 selected as input"]
197    #[inline(always)]
198    pub fn prsch1(self) -> &'a mut W {
199        self.variant(PRSSEL_A::PRSCH1)
200    }
201    #[doc = "PRS Channel 2 selected as input"]
202    #[inline(always)]
203    pub fn prsch2(self) -> &'a mut W {
204        self.variant(PRSSEL_A::PRSCH2)
205    }
206    #[doc = "PRS Channel 3 selected as input"]
207    #[inline(always)]
208    pub fn prsch3(self) -> &'a mut W {
209        self.variant(PRSSEL_A::PRSCH3)
210    }
211    #[doc = "PRS Channel 4 selected as input"]
212    #[inline(always)]
213    pub fn prsch4(self) -> &'a mut W {
214        self.variant(PRSSEL_A::PRSCH4)
215    }
216    #[doc = "PRS Channel 5 selected as input"]
217    #[inline(always)]
218    pub fn prsch5(self) -> &'a mut W {
219        self.variant(PRSSEL_A::PRSCH5)
220    }
221    #[doc = "PRS Channel 6 selected as input"]
222    #[inline(always)]
223    pub fn prsch6(self) -> &'a mut W {
224        self.variant(PRSSEL_A::PRSCH6)
225    }
226    #[doc = "PRS Channel 7 selected as input"]
227    #[inline(always)]
228    pub fn prsch7(self) -> &'a mut W {
229        self.variant(PRSSEL_A::PRSCH7)
230    }
231}
232#[doc = "Select Scan Configuration\n\nValue on reset: 0"]
233#[derive(Clone, Copy, Debug, PartialEq)]
234#[repr(u8)]
235pub enum SCANCONF_A {
236    #[doc = "0: The channel configuration register registers used are directly mapped to the channel number."]
237    DIRMAP = 0,
238    #[doc = "1: The channel configuration register registers used are CHX+8_CONF for channels 0-7 and CHX-8_CONF for channels 8-15."]
239    INVMAP = 1,
240    #[doc = "2: The channel configuration register registers used toggles between CHX_CONF and CHX+8_CONF when channel x triggers"]
241    TOGGLE = 2,
242    #[doc = "3: The decoder state defines the CONF registers to be used."]
243    DECDEF = 3,
244}
245impl From<SCANCONF_A> for u8 {
246    #[inline(always)]
247    fn from(variant: SCANCONF_A) -> Self {
248        variant as _
249    }
250}
251#[doc = "Field `SCANCONF` reader - Select Scan Configuration"]
252pub type SCANCONF_R = crate::FieldReader<u8, SCANCONF_A>;
253impl SCANCONF_R {
254    #[doc = "Get enumerated values variant"]
255    #[inline(always)]
256    pub fn variant(&self) -> SCANCONF_A {
257        match self.bits {
258            0 => SCANCONF_A::DIRMAP,
259            1 => SCANCONF_A::INVMAP,
260            2 => SCANCONF_A::TOGGLE,
261            3 => SCANCONF_A::DECDEF,
262            _ => unreachable!(),
263        }
264    }
265    #[doc = "Checks if the value of the field is `DIRMAP`"]
266    #[inline(always)]
267    pub fn is_dirmap(&self) -> bool {
268        *self == SCANCONF_A::DIRMAP
269    }
270    #[doc = "Checks if the value of the field is `INVMAP`"]
271    #[inline(always)]
272    pub fn is_invmap(&self) -> bool {
273        *self == SCANCONF_A::INVMAP
274    }
275    #[doc = "Checks if the value of the field is `TOGGLE`"]
276    #[inline(always)]
277    pub fn is_toggle(&self) -> bool {
278        *self == SCANCONF_A::TOGGLE
279    }
280    #[doc = "Checks if the value of the field is `DECDEF`"]
281    #[inline(always)]
282    pub fn is_decdef(&self) -> bool {
283        *self == SCANCONF_A::DECDEF
284    }
285}
286#[doc = "Field `SCANCONF` writer - Select Scan Configuration"]
287pub type SCANCONF_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, SCANCONF_A, 2, 7>;
288impl<'a> SCANCONF_W<'a> {
289    #[doc = "The channel configuration register registers used are directly mapped to the channel number."]
290    #[inline(always)]
291    pub fn dirmap(self) -> &'a mut W {
292        self.variant(SCANCONF_A::DIRMAP)
293    }
294    #[doc = "The channel configuration register registers used are CHX+8_CONF for channels 0-7 and CHX-8_CONF for channels 8-15."]
295    #[inline(always)]
296    pub fn invmap(self) -> &'a mut W {
297        self.variant(SCANCONF_A::INVMAP)
298    }
299    #[doc = "The channel configuration register registers used toggles between CHX_CONF and CHX+8_CONF when channel x triggers"]
300    #[inline(always)]
301    pub fn toggle(self) -> &'a mut W {
302        self.variant(SCANCONF_A::TOGGLE)
303    }
304    #[doc = "The decoder state defines the CONF registers to be used."]
305    #[inline(always)]
306    pub fn decdef(self) -> &'a mut W {
307        self.variant(SCANCONF_A::DECDEF)
308    }
309}
310#[doc = "Field `ALTEXMAP` reader - Alternative Excitation Map"]
311pub type ALTEXMAP_R = crate::BitReader<bool>;
312#[doc = "Field `ALTEXMAP` writer - Alternative Excitation Map"]
313pub type ALTEXMAP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 11>;
314#[doc = "Field `DUALSAMPLE` reader - Enable Dual Sample Mode"]
315pub type DUALSAMPLE_R = crate::BitReader<bool>;
316#[doc = "Field `DUALSAMPLE` writer - Enable Dual Sample Mode"]
317pub type DUALSAMPLE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 13>;
318#[doc = "Field `BUFOW` reader - Result Buffer Overwrite"]
319pub type BUFOW_R = crate::BitReader<bool>;
320#[doc = "Field `BUFOW` writer - Result Buffer Overwrite"]
321pub type BUFOW_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 16>;
322#[doc = "Field `STRSCANRES` reader - Enable Storing of SCANRES"]
323pub type STRSCANRES_R = crate::BitReader<bool>;
324#[doc = "Field `STRSCANRES` writer - Enable Storing of SCANRES"]
325pub type STRSCANRES_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 17>;
326#[doc = "Field `BUFIDL` reader - Result Buffer Interrupt and DMA Trigger Level"]
327pub type BUFIDL_R = crate::BitReader<bool>;
328#[doc = "Field `BUFIDL` writer - Result Buffer Interrupt and DMA Trigger Level"]
329pub type BUFIDL_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 19>;
330#[doc = "DMA Wake-up From EM2\n\nValue on reset: 0"]
331#[derive(Clone, Copy, Debug, PartialEq)]
332#[repr(u8)]
333pub enum DMAWU_A {
334    #[doc = "0: No DMA wake-up from EM2"]
335    DISABLE = 0,
336    #[doc = "1: DMA wake-up from EM2 when data is valid in the result buffer"]
337    BUFDATAV = 1,
338    #[doc = "2: DMA wake-up from EM2 when the result buffer is full/half-full depending on BUFIDL configuration"]
339    BUFLEVEL = 2,
340}
341impl From<DMAWU_A> for u8 {
342    #[inline(always)]
343    fn from(variant: DMAWU_A) -> Self {
344        variant as _
345    }
346}
347#[doc = "Field `DMAWU` reader - DMA Wake-up From EM2"]
348pub type DMAWU_R = crate::FieldReader<u8, DMAWU_A>;
349impl DMAWU_R {
350    #[doc = "Get enumerated values variant"]
351    #[inline(always)]
352    pub fn variant(&self) -> Option<DMAWU_A> {
353        match self.bits {
354            0 => Some(DMAWU_A::DISABLE),
355            1 => Some(DMAWU_A::BUFDATAV),
356            2 => Some(DMAWU_A::BUFLEVEL),
357            _ => None,
358        }
359    }
360    #[doc = "Checks if the value of the field is `DISABLE`"]
361    #[inline(always)]
362    pub fn is_disable(&self) -> bool {
363        *self == DMAWU_A::DISABLE
364    }
365    #[doc = "Checks if the value of the field is `BUFDATAV`"]
366    #[inline(always)]
367    pub fn is_bufdatav(&self) -> bool {
368        *self == DMAWU_A::BUFDATAV
369    }
370    #[doc = "Checks if the value of the field is `BUFLEVEL`"]
371    #[inline(always)]
372    pub fn is_buflevel(&self) -> bool {
373        *self == DMAWU_A::BUFLEVEL
374    }
375}
376#[doc = "Field `DMAWU` writer - DMA Wake-up From EM2"]
377pub type DMAWU_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, DMAWU_A, 2, 20>;
378impl<'a> DMAWU_W<'a> {
379    #[doc = "No DMA wake-up from EM2"]
380    #[inline(always)]
381    pub fn disable(self) -> &'a mut W {
382        self.variant(DMAWU_A::DISABLE)
383    }
384    #[doc = "DMA wake-up from EM2 when data is valid in the result buffer"]
385    #[inline(always)]
386    pub fn bufdatav(self) -> &'a mut W {
387        self.variant(DMAWU_A::BUFDATAV)
388    }
389    #[doc = "DMA wake-up from EM2 when the result buffer is full/half-full depending on BUFIDL configuration"]
390    #[inline(always)]
391    pub fn buflevel(self) -> &'a mut W {
392        self.variant(DMAWU_A::BUFLEVEL)
393    }
394}
395#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
396pub type DEBUGRUN_R = crate::BitReader<bool>;
397#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
398pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 22>;
399impl R {
400    #[doc = "Bits 0:1 - Configure Scan Mode"]
401    #[inline(always)]
402    pub fn scanmode(&self) -> SCANMODE_R {
403        SCANMODE_R::new((self.bits & 3) as u8)
404    }
405    #[doc = "Bits 2:4 - Scan Start PRS Select"]
406    #[inline(always)]
407    pub fn prssel(&self) -> PRSSEL_R {
408        PRSSEL_R::new(((self.bits >> 2) & 7) as u8)
409    }
410    #[doc = "Bits 7:8 - Select Scan Configuration"]
411    #[inline(always)]
412    pub fn scanconf(&self) -> SCANCONF_R {
413        SCANCONF_R::new(((self.bits >> 7) & 3) as u8)
414    }
415    #[doc = "Bit 11 - Alternative Excitation Map"]
416    #[inline(always)]
417    pub fn altexmap(&self) -> ALTEXMAP_R {
418        ALTEXMAP_R::new(((self.bits >> 11) & 1) != 0)
419    }
420    #[doc = "Bit 13 - Enable Dual Sample Mode"]
421    #[inline(always)]
422    pub fn dualsample(&self) -> DUALSAMPLE_R {
423        DUALSAMPLE_R::new(((self.bits >> 13) & 1) != 0)
424    }
425    #[doc = "Bit 16 - Result Buffer Overwrite"]
426    #[inline(always)]
427    pub fn bufow(&self) -> BUFOW_R {
428        BUFOW_R::new(((self.bits >> 16) & 1) != 0)
429    }
430    #[doc = "Bit 17 - Enable Storing of SCANRES"]
431    #[inline(always)]
432    pub fn strscanres(&self) -> STRSCANRES_R {
433        STRSCANRES_R::new(((self.bits >> 17) & 1) != 0)
434    }
435    #[doc = "Bit 19 - Result Buffer Interrupt and DMA Trigger Level"]
436    #[inline(always)]
437    pub fn bufidl(&self) -> BUFIDL_R {
438        BUFIDL_R::new(((self.bits >> 19) & 1) != 0)
439    }
440    #[doc = "Bits 20:21 - DMA Wake-up From EM2"]
441    #[inline(always)]
442    pub fn dmawu(&self) -> DMAWU_R {
443        DMAWU_R::new(((self.bits >> 20) & 3) as u8)
444    }
445    #[doc = "Bit 22 - Debug Mode Run Enable"]
446    #[inline(always)]
447    pub fn debugrun(&self) -> DEBUGRUN_R {
448        DEBUGRUN_R::new(((self.bits >> 22) & 1) != 0)
449    }
450}
451impl W {
452    #[doc = "Bits 0:1 - Configure Scan Mode"]
453    #[inline(always)]
454    pub fn scanmode(&mut self) -> SCANMODE_W {
455        SCANMODE_W::new(self)
456    }
457    #[doc = "Bits 2:4 - Scan Start PRS Select"]
458    #[inline(always)]
459    pub fn prssel(&mut self) -> PRSSEL_W {
460        PRSSEL_W::new(self)
461    }
462    #[doc = "Bits 7:8 - Select Scan Configuration"]
463    #[inline(always)]
464    pub fn scanconf(&mut self) -> SCANCONF_W {
465        SCANCONF_W::new(self)
466    }
467    #[doc = "Bit 11 - Alternative Excitation Map"]
468    #[inline(always)]
469    pub fn altexmap(&mut self) -> ALTEXMAP_W {
470        ALTEXMAP_W::new(self)
471    }
472    #[doc = "Bit 13 - Enable Dual Sample Mode"]
473    #[inline(always)]
474    pub fn dualsample(&mut self) -> DUALSAMPLE_W {
475        DUALSAMPLE_W::new(self)
476    }
477    #[doc = "Bit 16 - Result Buffer Overwrite"]
478    #[inline(always)]
479    pub fn bufow(&mut self) -> BUFOW_W {
480        BUFOW_W::new(self)
481    }
482    #[doc = "Bit 17 - Enable Storing of SCANRES"]
483    #[inline(always)]
484    pub fn strscanres(&mut self) -> STRSCANRES_W {
485        STRSCANRES_W::new(self)
486    }
487    #[doc = "Bit 19 - Result Buffer Interrupt and DMA Trigger Level"]
488    #[inline(always)]
489    pub fn bufidl(&mut self) -> BUFIDL_W {
490        BUFIDL_W::new(self)
491    }
492    #[doc = "Bits 20:21 - DMA Wake-up From EM2"]
493    #[inline(always)]
494    pub fn dmawu(&mut self) -> DMAWU_W {
495        DMAWU_W::new(self)
496    }
497    #[doc = "Bit 22 - Debug Mode Run Enable"]
498    #[inline(always)]
499    pub fn debugrun(&mut self) -> DEBUGRUN_W {
500        DEBUGRUN_W::new(self)
501    }
502    #[doc = "Writes raw bits to the register."]
503    #[inline(always)]
504    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
505        self.0.bits(bits);
506        self
507    }
508}
509#[doc = "Control Register\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 [ctrl](index.html) module"]
510pub struct CTRL_SPEC;
511impl crate::RegisterSpec for CTRL_SPEC {
512    type Ux = u32;
513}
514#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
515impl crate::Readable for CTRL_SPEC {
516    type Reader = R;
517}
518#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
519impl crate::Writable for CTRL_SPEC {
520    type Writer = W;
521}
522#[doc = "`reset()` method sets CTRL to value 0"]
523impl crate::Resettable for CTRL_SPEC {
524    #[inline(always)]
525    fn reset_value() -> Self::Ux {
526        0
527    }
528}