efm32gg11b820/usart3/
i2sctrl.rs1#[doc = "Reader of register I2SCTRL"]
2pub type R = crate::R<u32, super::I2SCTRL>;
3#[doc = "Writer for register I2SCTRL"]
4pub type W = crate::W<u32, super::I2SCTRL>;
5#[doc = "Register I2SCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::I2SCTRL {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Reader of field `EN`"]
14pub type EN_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `EN`"]
16pub struct EN_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> EN_W<'a> {
20 #[doc = r"Sets the field bit"]
21 #[inline(always)]
22 pub fn set_bit(self) -> &'a mut W {
23 self.bit(true)
24 }
25 #[doc = r"Clears the field bit"]
26 #[inline(always)]
27 pub fn clear_bit(self) -> &'a mut W {
28 self.bit(false)
29 }
30 #[doc = r"Writes raw bits to the field"]
31 #[inline(always)]
32 pub fn bit(self, value: bool) -> &'a mut W {
33 self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `MONO`"]
38pub type MONO_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `MONO`"]
40pub struct MONO_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> MONO_W<'a> {
44 #[doc = r"Sets the field bit"]
45 #[inline(always)]
46 pub fn set_bit(self) -> &'a mut W {
47 self.bit(true)
48 }
49 #[doc = r"Clears the field bit"]
50 #[inline(always)]
51 pub fn clear_bit(self) -> &'a mut W {
52 self.bit(false)
53 }
54 #[doc = r"Writes raw bits to the field"]
55 #[inline(always)]
56 pub fn bit(self, value: bool) -> &'a mut W {
57 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
58 self.w
59 }
60}
61#[doc = "Reader of field `JUSTIFY`"]
62pub type JUSTIFY_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `JUSTIFY`"]
64pub struct JUSTIFY_W<'a> {
65 w: &'a mut W,
66}
67impl<'a> JUSTIFY_W<'a> {
68 #[doc = r"Sets the field bit"]
69 #[inline(always)]
70 pub fn set_bit(self) -> &'a mut W {
71 self.bit(true)
72 }
73 #[doc = r"Clears the field bit"]
74 #[inline(always)]
75 pub fn clear_bit(self) -> &'a mut W {
76 self.bit(false)
77 }
78 #[doc = r"Writes raw bits to the field"]
79 #[inline(always)]
80 pub fn bit(self, value: bool) -> &'a mut W {
81 self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
82 self.w
83 }
84}
85#[doc = "Reader of field `DMASPLIT`"]
86pub type DMASPLIT_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `DMASPLIT`"]
88pub struct DMASPLIT_W<'a> {
89 w: &'a mut W,
90}
91impl<'a> DMASPLIT_W<'a> {
92 #[doc = r"Sets the field bit"]
93 #[inline(always)]
94 pub fn set_bit(self) -> &'a mut W {
95 self.bit(true)
96 }
97 #[doc = r"Clears the field bit"]
98 #[inline(always)]
99 pub fn clear_bit(self) -> &'a mut W {
100 self.bit(false)
101 }
102 #[doc = r"Writes raw bits to the field"]
103 #[inline(always)]
104 pub fn bit(self, value: bool) -> &'a mut W {
105 self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
106 self.w
107 }
108}
109#[doc = "Reader of field `DELAY`"]
110pub type DELAY_R = crate::R<bool, bool>;
111#[doc = "Write proxy for field `DELAY`"]
112pub struct DELAY_W<'a> {
113 w: &'a mut W,
114}
115impl<'a> DELAY_W<'a> {
116 #[doc = r"Sets the field bit"]
117 #[inline(always)]
118 pub fn set_bit(self) -> &'a mut W {
119 self.bit(true)
120 }
121 #[doc = r"Clears the field bit"]
122 #[inline(always)]
123 pub fn clear_bit(self) -> &'a mut W {
124 self.bit(false)
125 }
126 #[doc = r"Writes raw bits to the field"]
127 #[inline(always)]
128 pub fn bit(self, value: bool) -> &'a mut W {
129 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
130 self.w
131 }
132}
133#[doc = "I2S Word Format\n\nValue on reset: 0"]
134#[derive(Clone, Copy, Debug, PartialEq)]
135#[repr(u8)]
136pub enum FORMAT_A {
137 #[doc = "0: 32-bit word, 32-bit data"]
138 W32D32 = 0,
139 #[doc = "1: 32-bit word, 32-bit data with 8 lsb masked"]
140 W32D24M = 1,
141 #[doc = "2: 32-bit word, 24-bit data"]
142 W32D24 = 2,
143 #[doc = "3: 32-bit word, 16-bit data"]
144 W32D16 = 3,
145 #[doc = "4: 32-bit word, 8-bit data"]
146 W32D8 = 4,
147 #[doc = "5: 16-bit word, 16-bit data"]
148 W16D16 = 5,
149 #[doc = "6: 16-bit word, 8-bit data"]
150 W16D8 = 6,
151 #[doc = "7: 8-bit word, 8-bit data"]
152 W8D8 = 7,
153}
154impl From<FORMAT_A> for u8 {
155 #[inline(always)]
156 fn from(variant: FORMAT_A) -> Self {
157 variant as _
158 }
159}
160#[doc = "Reader of field `FORMAT`"]
161pub type FORMAT_R = crate::R<u8, FORMAT_A>;
162impl FORMAT_R {
163 #[doc = r"Get enumerated values variant"]
164 #[inline(always)]
165 pub fn variant(&self) -> FORMAT_A {
166 match self.bits {
167 0 => FORMAT_A::W32D32,
168 1 => FORMAT_A::W32D24M,
169 2 => FORMAT_A::W32D24,
170 3 => FORMAT_A::W32D16,
171 4 => FORMAT_A::W32D8,
172 5 => FORMAT_A::W16D16,
173 6 => FORMAT_A::W16D8,
174 7 => FORMAT_A::W8D8,
175 _ => unreachable!(),
176 }
177 }
178 #[doc = "Checks if the value of the field is `W32D32`"]
179 #[inline(always)]
180 pub fn is_w32d32(&self) -> bool {
181 *self == FORMAT_A::W32D32
182 }
183 #[doc = "Checks if the value of the field is `W32D24M`"]
184 #[inline(always)]
185 pub fn is_w32d24m(&self) -> bool {
186 *self == FORMAT_A::W32D24M
187 }
188 #[doc = "Checks if the value of the field is `W32D24`"]
189 #[inline(always)]
190 pub fn is_w32d24(&self) -> bool {
191 *self == FORMAT_A::W32D24
192 }
193 #[doc = "Checks if the value of the field is `W32D16`"]
194 #[inline(always)]
195 pub fn is_w32d16(&self) -> bool {
196 *self == FORMAT_A::W32D16
197 }
198 #[doc = "Checks if the value of the field is `W32D8`"]
199 #[inline(always)]
200 pub fn is_w32d8(&self) -> bool {
201 *self == FORMAT_A::W32D8
202 }
203 #[doc = "Checks if the value of the field is `W16D16`"]
204 #[inline(always)]
205 pub fn is_w16d16(&self) -> bool {
206 *self == FORMAT_A::W16D16
207 }
208 #[doc = "Checks if the value of the field is `W16D8`"]
209 #[inline(always)]
210 pub fn is_w16d8(&self) -> bool {
211 *self == FORMAT_A::W16D8
212 }
213 #[doc = "Checks if the value of the field is `W8D8`"]
214 #[inline(always)]
215 pub fn is_w8d8(&self) -> bool {
216 *self == FORMAT_A::W8D8
217 }
218}
219#[doc = "Write proxy for field `FORMAT`"]
220pub struct FORMAT_W<'a> {
221 w: &'a mut W,
222}
223impl<'a> FORMAT_W<'a> {
224 #[doc = r"Writes `variant` to the field"]
225 #[inline(always)]
226 pub fn variant(self, variant: FORMAT_A) -> &'a mut W {
227 {
228 self.bits(variant.into())
229 }
230 }
231 #[doc = "32-bit word, 32-bit data"]
232 #[inline(always)]
233 pub fn w32d32(self) -> &'a mut W {
234 self.variant(FORMAT_A::W32D32)
235 }
236 #[doc = "32-bit word, 32-bit data with 8 lsb masked"]
237 #[inline(always)]
238 pub fn w32d24m(self) -> &'a mut W {
239 self.variant(FORMAT_A::W32D24M)
240 }
241 #[doc = "32-bit word, 24-bit data"]
242 #[inline(always)]
243 pub fn w32d24(self) -> &'a mut W {
244 self.variant(FORMAT_A::W32D24)
245 }
246 #[doc = "32-bit word, 16-bit data"]
247 #[inline(always)]
248 pub fn w32d16(self) -> &'a mut W {
249 self.variant(FORMAT_A::W32D16)
250 }
251 #[doc = "32-bit word, 8-bit data"]
252 #[inline(always)]
253 pub fn w32d8(self) -> &'a mut W {
254 self.variant(FORMAT_A::W32D8)
255 }
256 #[doc = "16-bit word, 16-bit data"]
257 #[inline(always)]
258 pub fn w16d16(self) -> &'a mut W {
259 self.variant(FORMAT_A::W16D16)
260 }
261 #[doc = "16-bit word, 8-bit data"]
262 #[inline(always)]
263 pub fn w16d8(self) -> &'a mut W {
264 self.variant(FORMAT_A::W16D8)
265 }
266 #[doc = "8-bit word, 8-bit data"]
267 #[inline(always)]
268 pub fn w8d8(self) -> &'a mut W {
269 self.variant(FORMAT_A::W8D8)
270 }
271 #[doc = r"Writes raw bits to the field"]
272 #[inline(always)]
273 pub fn bits(self, value: u8) -> &'a mut W {
274 self.w.bits = (self.w.bits & !(0x07 << 8)) | (((value as u32) & 0x07) << 8);
275 self.w
276 }
277}
278impl R {
279 #[doc = "Bit 0 - Enable I2S Mode"]
280 #[inline(always)]
281 pub fn en(&self) -> EN_R {
282 EN_R::new((self.bits & 0x01) != 0)
283 }
284 #[doc = "Bit 1 - Stero or Mono"]
285 #[inline(always)]
286 pub fn mono(&self) -> MONO_R {
287 MONO_R::new(((self.bits >> 1) & 0x01) != 0)
288 }
289 #[doc = "Bit 2 - Justification of I2S Data"]
290 #[inline(always)]
291 pub fn justify(&self) -> JUSTIFY_R {
292 JUSTIFY_R::new(((self.bits >> 2) & 0x01) != 0)
293 }
294 #[doc = "Bit 3 - Separate DMA Request for Left/Right Data"]
295 #[inline(always)]
296 pub fn dmasplit(&self) -> DMASPLIT_R {
297 DMASPLIT_R::new(((self.bits >> 3) & 0x01) != 0)
298 }
299 #[doc = "Bit 4 - Delay on I2S Data"]
300 #[inline(always)]
301 pub fn delay(&self) -> DELAY_R {
302 DELAY_R::new(((self.bits >> 4) & 0x01) != 0)
303 }
304 #[doc = "Bits 8:10 - I2S Word Format"]
305 #[inline(always)]
306 pub fn format(&self) -> FORMAT_R {
307 FORMAT_R::new(((self.bits >> 8) & 0x07) as u8)
308 }
309}
310impl W {
311 #[doc = "Bit 0 - Enable I2S Mode"]
312 #[inline(always)]
313 pub fn en(&mut self) -> EN_W {
314 EN_W { w: self }
315 }
316 #[doc = "Bit 1 - Stero or Mono"]
317 #[inline(always)]
318 pub fn mono(&mut self) -> MONO_W {
319 MONO_W { w: self }
320 }
321 #[doc = "Bit 2 - Justification of I2S Data"]
322 #[inline(always)]
323 pub fn justify(&mut self) -> JUSTIFY_W {
324 JUSTIFY_W { w: self }
325 }
326 #[doc = "Bit 3 - Separate DMA Request for Left/Right Data"]
327 #[inline(always)]
328 pub fn dmasplit(&mut self) -> DMASPLIT_W {
329 DMASPLIT_W { w: self }
330 }
331 #[doc = "Bit 4 - Delay on I2S Data"]
332 #[inline(always)]
333 pub fn delay(&mut self) -> DELAY_W {
334 DELAY_W { w: self }
335 }
336 #[doc = "Bits 8:10 - I2S Word Format"]
337 #[inline(always)]
338 pub fn format(&mut self) -> FORMAT_W {
339 FORMAT_W { w: self }
340 }
341}