efm32tg11b_pac/efm32tg11b120/csen/
emactrl.rs

1#[doc = "Register `EMACTRL` reader"]
2pub struct R(crate::R<EMACTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EMACTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EMACTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EMACTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EMACTRL` writer"]
17pub struct W(crate::W<EMACTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EMACTRL_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<EMACTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EMACTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EMASAMPLE` reader - EMA Sample Weight"]
38pub type EMASAMPLE_R = crate::FieldReader<u8, EMASAMPLE_A>;
39#[doc = "EMA Sample Weight\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum EMASAMPLE_A {
43    #[doc = "0: EMA weight (N) is 1."]
44    W1 = 0,
45    #[doc = "1: EMA weight (N) is 2."]
46    W2 = 1,
47    #[doc = "2: EMA weight (N) is 4."]
48    W4 = 2,
49    #[doc = "3: EMA weight (N) is 8."]
50    W8 = 3,
51    #[doc = "4: EMA weight (N) is 16."]
52    W16 = 4,
53    #[doc = "5: EMA weight (N) is 32."]
54    W32 = 5,
55    #[doc = "6: EMA weight (N) is 64."]
56    W64 = 6,
57}
58impl From<EMASAMPLE_A> for u8 {
59    #[inline(always)]
60    fn from(variant: EMASAMPLE_A) -> Self {
61        variant as _
62    }
63}
64impl EMASAMPLE_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<EMASAMPLE_A> {
68        match self.bits {
69            0 => Some(EMASAMPLE_A::W1),
70            1 => Some(EMASAMPLE_A::W2),
71            2 => Some(EMASAMPLE_A::W4),
72            3 => Some(EMASAMPLE_A::W8),
73            4 => Some(EMASAMPLE_A::W16),
74            5 => Some(EMASAMPLE_A::W32),
75            6 => Some(EMASAMPLE_A::W64),
76            _ => None,
77        }
78    }
79    #[doc = "Checks if the value of the field is `W1`"]
80    #[inline(always)]
81    pub fn is_w1(&self) -> bool {
82        *self == EMASAMPLE_A::W1
83    }
84    #[doc = "Checks if the value of the field is `W2`"]
85    #[inline(always)]
86    pub fn is_w2(&self) -> bool {
87        *self == EMASAMPLE_A::W2
88    }
89    #[doc = "Checks if the value of the field is `W4`"]
90    #[inline(always)]
91    pub fn is_w4(&self) -> bool {
92        *self == EMASAMPLE_A::W4
93    }
94    #[doc = "Checks if the value of the field is `W8`"]
95    #[inline(always)]
96    pub fn is_w8(&self) -> bool {
97        *self == EMASAMPLE_A::W8
98    }
99    #[doc = "Checks if the value of the field is `W16`"]
100    #[inline(always)]
101    pub fn is_w16(&self) -> bool {
102        *self == EMASAMPLE_A::W16
103    }
104    #[doc = "Checks if the value of the field is `W32`"]
105    #[inline(always)]
106    pub fn is_w32(&self) -> bool {
107        *self == EMASAMPLE_A::W32
108    }
109    #[doc = "Checks if the value of the field is `W64`"]
110    #[inline(always)]
111    pub fn is_w64(&self) -> bool {
112        *self == EMASAMPLE_A::W64
113    }
114}
115#[doc = "Field `EMASAMPLE` writer - EMA Sample Weight"]
116pub type EMASAMPLE_W<'a, const O: u8> =
117    crate::FieldWriter<'a, u32, EMACTRL_SPEC, u8, EMASAMPLE_A, 3, O>;
118impl<'a, const O: u8> EMASAMPLE_W<'a, O> {
119    #[doc = "EMA weight (N) is 1."]
120    #[inline(always)]
121    pub fn w1(self) -> &'a mut W {
122        self.variant(EMASAMPLE_A::W1)
123    }
124    #[doc = "EMA weight (N) is 2."]
125    #[inline(always)]
126    pub fn w2(self) -> &'a mut W {
127        self.variant(EMASAMPLE_A::W2)
128    }
129    #[doc = "EMA weight (N) is 4."]
130    #[inline(always)]
131    pub fn w4(self) -> &'a mut W {
132        self.variant(EMASAMPLE_A::W4)
133    }
134    #[doc = "EMA weight (N) is 8."]
135    #[inline(always)]
136    pub fn w8(self) -> &'a mut W {
137        self.variant(EMASAMPLE_A::W8)
138    }
139    #[doc = "EMA weight (N) is 16."]
140    #[inline(always)]
141    pub fn w16(self) -> &'a mut W {
142        self.variant(EMASAMPLE_A::W16)
143    }
144    #[doc = "EMA weight (N) is 32."]
145    #[inline(always)]
146    pub fn w32(self) -> &'a mut W {
147        self.variant(EMASAMPLE_A::W32)
148    }
149    #[doc = "EMA weight (N) is 64."]
150    #[inline(always)]
151    pub fn w64(self) -> &'a mut W {
152        self.variant(EMASAMPLE_A::W64)
153    }
154}
155impl R {
156    #[doc = "Bits 0:2 - EMA Sample Weight"]
157    #[inline(always)]
158    pub fn emasample(&self) -> EMASAMPLE_R {
159        EMASAMPLE_R::new((self.bits & 7) as u8)
160    }
161}
162impl W {
163    #[doc = "Bits 0:2 - EMA Sample Weight"]
164    #[inline(always)]
165    #[must_use]
166    pub fn emasample(&mut self) -> EMASAMPLE_W<0> {
167        EMASAMPLE_W::new(self)
168    }
169    #[doc = "Writes raw bits to the register."]
170    #[inline(always)]
171    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
172        self.0.bits(bits);
173        self
174    }
175}
176#[doc = "Exponential Moving Average Control\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 [emactrl](index.html) module"]
177pub struct EMACTRL_SPEC;
178impl crate::RegisterSpec for EMACTRL_SPEC {
179    type Ux = u32;
180}
181#[doc = "`read()` method returns [emactrl::R](R) reader structure"]
182impl crate::Readable for EMACTRL_SPEC {
183    type Reader = R;
184}
185#[doc = "`write(|w| ..)` method takes [emactrl::W](W) writer structure"]
186impl crate::Writable for EMACTRL_SPEC {
187    type Writer = W;
188    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
189    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
190}
191#[doc = "`reset()` method sets EMACTRL to value 0"]
192impl crate::Resettable for EMACTRL_SPEC {
193    const RESET_VALUE: Self::Ux = 0;
194}