efm32pg12_pac/csen/
dmcfg.rs1#[doc = "Reader of register DMCFG"]
2pub type R = crate::R<u32, super::DMCFG>;
3#[doc = "Writer for register DMCFG"]
4pub type W = crate::W<u32, super::DMCFG>;
5#[doc = "Register DMCFG `reset()`'s with value 0"]
6impl crate::ResetValue for super::DMCFG {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Reader of field `DMG`"]
14pub type DMG_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `DMG`"]
16pub struct DMG_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> DMG_W<'a> {
20 #[doc = r"Writes raw bits to the field"]
21 #[inline(always)]
22 pub unsafe fn bits(self, value: u8) -> &'a mut W {
23 self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff);
24 self.w
25 }
26}
27#[doc = "Reader of field `DMR`"]
28pub type DMR_R = crate::R<u8, u8>;
29#[doc = "Write proxy for field `DMR`"]
30pub struct DMR_W<'a> {
31 w: &'a mut W,
32}
33impl<'a> DMR_W<'a> {
34 #[doc = r"Writes raw bits to the field"]
35 #[inline(always)]
36 pub unsafe fn bits(self, value: u8) -> &'a mut W {
37 self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
38 self.w
39 }
40}
41#[doc = "Reader of field `DMCR`"]
42pub type DMCR_R = crate::R<u8, u8>;
43#[doc = "Write proxy for field `DMCR`"]
44pub struct DMCR_W<'a> {
45 w: &'a mut W,
46}
47impl<'a> DMCR_W<'a> {
48 #[doc = r"Writes raw bits to the field"]
49 #[inline(always)]
50 pub unsafe fn bits(self, value: u8) -> &'a mut W {
51 self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
52 self.w
53 }
54}
55#[doc = "Delta Modulator Conversion Resolution.\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq)]
57#[repr(u8)]
58pub enum CRMODE_A {
59 #[doc = "0: 10-bit delta modulator"]
60 DM10 = 0,
61 #[doc = "1: 12-bit delta modulator"]
62 DM12 = 1,
63 #[doc = "2: 14-bit delta modulator"]
64 DM14 = 2,
65 #[doc = "3: 16-bit delta modulator"]
66 DM16 = 3,
67}
68impl From<CRMODE_A> for u8 {
69 #[inline(always)]
70 fn from(variant: CRMODE_A) -> Self {
71 variant as _
72 }
73}
74#[doc = "Reader of field `CRMODE`"]
75pub type CRMODE_R = crate::R<u8, CRMODE_A>;
76impl CRMODE_R {
77 #[doc = r"Get enumerated values variant"]
78 #[inline(always)]
79 pub fn variant(&self) -> CRMODE_A {
80 match self.bits {
81 0 => CRMODE_A::DM10,
82 1 => CRMODE_A::DM12,
83 2 => CRMODE_A::DM14,
84 3 => CRMODE_A::DM16,
85 _ => unreachable!(),
86 }
87 }
88 #[doc = "Checks if the value of the field is `DM10`"]
89 #[inline(always)]
90 pub fn is_dm10(&self) -> bool {
91 *self == CRMODE_A::DM10
92 }
93 #[doc = "Checks if the value of the field is `DM12`"]
94 #[inline(always)]
95 pub fn is_dm12(&self) -> bool {
96 *self == CRMODE_A::DM12
97 }
98 #[doc = "Checks if the value of the field is `DM14`"]
99 #[inline(always)]
100 pub fn is_dm14(&self) -> bool {
101 *self == CRMODE_A::DM14
102 }
103 #[doc = "Checks if the value of the field is `DM16`"]
104 #[inline(always)]
105 pub fn is_dm16(&self) -> bool {
106 *self == CRMODE_A::DM16
107 }
108}
109#[doc = "Write proxy for field `CRMODE`"]
110pub struct CRMODE_W<'a> {
111 w: &'a mut W,
112}
113impl<'a> CRMODE_W<'a> {
114 #[doc = r"Writes `variant` to the field"]
115 #[inline(always)]
116 pub fn variant(self, variant: CRMODE_A) -> &'a mut W {
117 {
118 self.bits(variant.into())
119 }
120 }
121 #[doc = "10-bit delta modulator"]
122 #[inline(always)]
123 pub fn dm10(self) -> &'a mut W {
124 self.variant(CRMODE_A::DM10)
125 }
126 #[doc = "12-bit delta modulator"]
127 #[inline(always)]
128 pub fn dm12(self) -> &'a mut W {
129 self.variant(CRMODE_A::DM12)
130 }
131 #[doc = "14-bit delta modulator"]
132 #[inline(always)]
133 pub fn dm14(self) -> &'a mut W {
134 self.variant(CRMODE_A::DM14)
135 }
136 #[doc = "16-bit delta modulator"]
137 #[inline(always)]
138 pub fn dm16(self) -> &'a mut W {
139 self.variant(CRMODE_A::DM16)
140 }
141 #[doc = r"Writes raw bits to the field"]
142 #[inline(always)]
143 pub fn bits(self, value: u8) -> &'a mut W {
144 self.w.bits = (self.w.bits & !(0x03 << 20)) | (((value as u32) & 0x03) << 20);
145 self.w
146 }
147}
148#[doc = "Reader of field `DMGRDIS`"]
149pub type DMGRDIS_R = crate::R<bool, bool>;
150#[doc = "Write proxy for field `DMGRDIS`"]
151pub struct DMGRDIS_W<'a> {
152 w: &'a mut W,
153}
154impl<'a> DMGRDIS_W<'a> {
155 #[doc = r"Sets the field bit"]
156 #[inline(always)]
157 pub fn set_bit(self) -> &'a mut W {
158 self.bit(true)
159 }
160 #[doc = r"Clears the field bit"]
161 #[inline(always)]
162 pub fn clear_bit(self) -> &'a mut W {
163 self.bit(false)
164 }
165 #[doc = r"Writes raw bits to the field"]
166 #[inline(always)]
167 pub fn bit(self, value: bool) -> &'a mut W {
168 self.w.bits = (self.w.bits & !(0x01 << 28)) | (((value as u32) & 0x01) << 28);
169 self.w
170 }
171}
172impl R {
173 #[doc = "Bits 0:7 - Delta Modulator Gain Step"]
174 #[inline(always)]
175 pub fn dmg(&self) -> DMG_R {
176 DMG_R::new((self.bits & 0xff) as u8)
177 }
178 #[doc = "Bits 8:11 - Delta Modulator Gain Reduction Interval"]
179 #[inline(always)]
180 pub fn dmr(&self) -> DMR_R {
181 DMR_R::new(((self.bits >> 8) & 0x0f) as u8)
182 }
183 #[doc = "Bits 16:19 - Delta Modulator Conversion Rate"]
184 #[inline(always)]
185 pub fn dmcr(&self) -> DMCR_R {
186 DMCR_R::new(((self.bits >> 16) & 0x0f) as u8)
187 }
188 #[doc = "Bits 20:21 - Delta Modulator Conversion Resolution."]
189 #[inline(always)]
190 pub fn crmode(&self) -> CRMODE_R {
191 CRMODE_R::new(((self.bits >> 20) & 0x03) as u8)
192 }
193 #[doc = "Bit 28 - Delta Modulation Gain Step Reduction Disable"]
194 #[inline(always)]
195 pub fn dmgrdis(&self) -> DMGRDIS_R {
196 DMGRDIS_R::new(((self.bits >> 28) & 0x01) != 0)
197 }
198}
199impl W {
200 #[doc = "Bits 0:7 - Delta Modulator Gain Step"]
201 #[inline(always)]
202 pub fn dmg(&mut self) -> DMG_W {
203 DMG_W { w: self }
204 }
205 #[doc = "Bits 8:11 - Delta Modulator Gain Reduction Interval"]
206 #[inline(always)]
207 pub fn dmr(&mut self) -> DMR_W {
208 DMR_W { w: self }
209 }
210 #[doc = "Bits 16:19 - Delta Modulator Conversion Rate"]
211 #[inline(always)]
212 pub fn dmcr(&mut self) -> DMCR_W {
213 DMCR_W { w: self }
214 }
215 #[doc = "Bits 20:21 - Delta Modulator Conversion Resolution."]
216 #[inline(always)]
217 pub fn crmode(&mut self) -> CRMODE_W {
218 CRMODE_W { w: self }
219 }
220 #[doc = "Bit 28 - Delta Modulation Gain Step Reduction Disable"]
221 #[inline(always)]
222 pub fn dmgrdis(&mut self) -> DMGRDIS_W {
223 DMGRDIS_W { w: self }
224 }
225}