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