efm32gg12b330_pac/csen/
emactrl.rs1#[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 = "EMA Sample Weight\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum EMASAMPLE_A {
41 #[doc = "0: EMA weight (N) is 1."]
42 W1 = 0,
43 #[doc = "1: EMA weight (N) is 2."]
44 W2 = 1,
45 #[doc = "2: EMA weight (N) is 4."]
46 W4 = 2,
47 #[doc = "3: EMA weight (N) is 8."]
48 W8 = 3,
49 #[doc = "4: EMA weight (N) is 16."]
50 W16 = 4,
51 #[doc = "5: EMA weight (N) is 32."]
52 W32 = 5,
53 #[doc = "6: EMA weight (N) is 64."]
54 W64 = 6,
55}
56impl From<EMASAMPLE_A> for u8 {
57 #[inline(always)]
58 fn from(variant: EMASAMPLE_A) -> Self {
59 variant as _
60 }
61}
62#[doc = "Field `EMASAMPLE` reader - EMA Sample Weight"]
63pub type EMASAMPLE_R = crate::FieldReader<u8, EMASAMPLE_A>;
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> = crate::FieldWriter<'a, u32, EMACTRL_SPEC, u8, EMASAMPLE_A, 3, 0>;
117impl<'a> EMASAMPLE_W<'a> {
118 #[doc = "EMA weight (N) is 1."]
119 #[inline(always)]
120 pub fn w1(self) -> &'a mut W {
121 self.variant(EMASAMPLE_A::W1)
122 }
123 #[doc = "EMA weight (N) is 2."]
124 #[inline(always)]
125 pub fn w2(self) -> &'a mut W {
126 self.variant(EMASAMPLE_A::W2)
127 }
128 #[doc = "EMA weight (N) is 4."]
129 #[inline(always)]
130 pub fn w4(self) -> &'a mut W {
131 self.variant(EMASAMPLE_A::W4)
132 }
133 #[doc = "EMA weight (N) is 8."]
134 #[inline(always)]
135 pub fn w8(self) -> &'a mut W {
136 self.variant(EMASAMPLE_A::W8)
137 }
138 #[doc = "EMA weight (N) is 16."]
139 #[inline(always)]
140 pub fn w16(self) -> &'a mut W {
141 self.variant(EMASAMPLE_A::W16)
142 }
143 #[doc = "EMA weight (N) is 32."]
144 #[inline(always)]
145 pub fn w32(self) -> &'a mut W {
146 self.variant(EMASAMPLE_A::W32)
147 }
148 #[doc = "EMA weight (N) is 64."]
149 #[inline(always)]
150 pub fn w64(self) -> &'a mut W {
151 self.variant(EMASAMPLE_A::W64)
152 }
153}
154impl R {
155 #[doc = "Bits 0:2 - EMA Sample Weight"]
156 #[inline(always)]
157 pub fn emasample(&self) -> EMASAMPLE_R {
158 EMASAMPLE_R::new((self.bits & 7) as u8)
159 }
160}
161impl W {
162 #[doc = "Bits 0:2 - EMA Sample Weight"]
163 #[inline(always)]
164 pub fn emasample(&mut self) -> EMASAMPLE_W {
165 EMASAMPLE_W::new(self)
166 }
167 #[doc = "Writes raw bits to the register."]
168 #[inline(always)]
169 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
170 self.0.bits(bits);
171 self
172 }
173}
174#[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"]
175pub struct EMACTRL_SPEC;
176impl crate::RegisterSpec for EMACTRL_SPEC {
177 type Ux = u32;
178}
179#[doc = "`read()` method returns [emactrl::R](R) reader structure"]
180impl crate::Readable for EMACTRL_SPEC {
181 type Reader = R;
182}
183#[doc = "`write(|w| ..)` method takes [emactrl::W](W) writer structure"]
184impl crate::Writable for EMACTRL_SPEC {
185 type Writer = W;
186}
187#[doc = "`reset()` method sets EMACTRL to value 0"]
188impl crate::Resettable for EMACTRL_SPEC {
189 #[inline(always)]
190 fn reset_value() -> Self::Ux {
191 0
192 }
193}