efm32wg230_pac/usart0/
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> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, 0>;
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> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, 1>;
45#[doc = "Field `JUSTIFY` reader - Justification of I2S Data"]
46pub type JUSTIFY_R = crate::BitReader<bool>;
47#[doc = "Field `JUSTIFY` writer - Justification of I2S Data"]
48pub type JUSTIFY_W<'a> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, 2>;
49#[doc = "Field `DMASPLIT` reader - Separate DMA Request For Left/Right Data"]
50pub type DMASPLIT_R = crate::BitReader<bool>;
51#[doc = "Field `DMASPLIT` writer - Separate DMA Request For Left/Right Data"]
52pub type DMASPLIT_W<'a> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, 3>;
53#[doc = "Field `DELAY` reader - Delay on I2S data"]
54pub type DELAY_R = crate::BitReader<bool>;
55#[doc = "Field `DELAY` writer - Delay on I2S data"]
56pub type DELAY_W<'a> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, 4>;
57#[doc = "I2S Word Format\n\nValue on reset: 0"]
58#[derive(Clone, Copy, Debug, PartialEq)]
59#[repr(u8)]
60pub enum FORMAT_A {
61 #[doc = "0: 32-bit word, 32-bit data"]
62 W32D32 = 0,
63 #[doc = "1: 32-bit word, 32-bit data with 8 lsb masked"]
64 W32D24M = 1,
65 #[doc = "2: 32-bit word, 24-bit data"]
66 W32D24 = 2,
67 #[doc = "3: 32-bit word, 16-bit data"]
68 W32D16 = 3,
69 #[doc = "4: 32-bit word, 8-bit data"]
70 W32D8 = 4,
71 #[doc = "5: 16-bit word, 16-bit data"]
72 W16D16 = 5,
73 #[doc = "6: 16-bit word, 8-bit data"]
74 W16D8 = 6,
75 #[doc = "7: 8-bit word, 8-bit data"]
76 W8D8 = 7,
77}
78impl From<FORMAT_A> for u8 {
79 #[inline(always)]
80 fn from(variant: FORMAT_A) -> Self {
81 variant as _
82 }
83}
84#[doc = "Field `FORMAT` reader - I2S Word Format"]
85pub type FORMAT_R = crate::FieldReader<u8, FORMAT_A>;
86impl FORMAT_R {
87 #[doc = "Get enumerated values variant"]
88 #[inline(always)]
89 pub fn variant(&self) -> FORMAT_A {
90 match self.bits {
91 0 => FORMAT_A::W32D32,
92 1 => FORMAT_A::W32D24M,
93 2 => FORMAT_A::W32D24,
94 3 => FORMAT_A::W32D16,
95 4 => FORMAT_A::W32D8,
96 5 => FORMAT_A::W16D16,
97 6 => FORMAT_A::W16D8,
98 7 => FORMAT_A::W8D8,
99 _ => unreachable!(),
100 }
101 }
102 #[doc = "Checks if the value of the field is `W32D32`"]
103 #[inline(always)]
104 pub fn is_w32d32(&self) -> bool {
105 *self == FORMAT_A::W32D32
106 }
107 #[doc = "Checks if the value of the field is `W32D24M`"]
108 #[inline(always)]
109 pub fn is_w32d24m(&self) -> bool {
110 *self == FORMAT_A::W32D24M
111 }
112 #[doc = "Checks if the value of the field is `W32D24`"]
113 #[inline(always)]
114 pub fn is_w32d24(&self) -> bool {
115 *self == FORMAT_A::W32D24
116 }
117 #[doc = "Checks if the value of the field is `W32D16`"]
118 #[inline(always)]
119 pub fn is_w32d16(&self) -> bool {
120 *self == FORMAT_A::W32D16
121 }
122 #[doc = "Checks if the value of the field is `W32D8`"]
123 #[inline(always)]
124 pub fn is_w32d8(&self) -> bool {
125 *self == FORMAT_A::W32D8
126 }
127 #[doc = "Checks if the value of the field is `W16D16`"]
128 #[inline(always)]
129 pub fn is_w16d16(&self) -> bool {
130 *self == FORMAT_A::W16D16
131 }
132 #[doc = "Checks if the value of the field is `W16D8`"]
133 #[inline(always)]
134 pub fn is_w16d8(&self) -> bool {
135 *self == FORMAT_A::W16D8
136 }
137 #[doc = "Checks if the value of the field is `W8D8`"]
138 #[inline(always)]
139 pub fn is_w8d8(&self) -> bool {
140 *self == FORMAT_A::W8D8
141 }
142}
143#[doc = "Field `FORMAT` writer - I2S Word Format"]
144pub type FORMAT_W<'a> = crate::FieldWriterSafe<'a, u32, I2SCTRL_SPEC, u8, FORMAT_A, 3, 8>;
145impl<'a> FORMAT_W<'a> {
146 #[doc = "32-bit word, 32-bit data"]
147 #[inline(always)]
148 pub fn w32d32(self) -> &'a mut W {
149 self.variant(FORMAT_A::W32D32)
150 }
151 #[doc = "32-bit word, 32-bit data with 8 lsb masked"]
152 #[inline(always)]
153 pub fn w32d24m(self) -> &'a mut W {
154 self.variant(FORMAT_A::W32D24M)
155 }
156 #[doc = "32-bit word, 24-bit data"]
157 #[inline(always)]
158 pub fn w32d24(self) -> &'a mut W {
159 self.variant(FORMAT_A::W32D24)
160 }
161 #[doc = "32-bit word, 16-bit data"]
162 #[inline(always)]
163 pub fn w32d16(self) -> &'a mut W {
164 self.variant(FORMAT_A::W32D16)
165 }
166 #[doc = "32-bit word, 8-bit data"]
167 #[inline(always)]
168 pub fn w32d8(self) -> &'a mut W {
169 self.variant(FORMAT_A::W32D8)
170 }
171 #[doc = "16-bit word, 16-bit data"]
172 #[inline(always)]
173 pub fn w16d16(self) -> &'a mut W {
174 self.variant(FORMAT_A::W16D16)
175 }
176 #[doc = "16-bit word, 8-bit data"]
177 #[inline(always)]
178 pub fn w16d8(self) -> &'a mut W {
179 self.variant(FORMAT_A::W16D8)
180 }
181 #[doc = "8-bit word, 8-bit data"]
182 #[inline(always)]
183 pub fn w8d8(self) -> &'a mut W {
184 self.variant(FORMAT_A::W8D8)
185 }
186}
187impl R {
188 #[doc = "Bit 0 - Enable I2S Mode"]
189 #[inline(always)]
190 pub fn en(&self) -> EN_R {
191 EN_R::new((self.bits & 1) != 0)
192 }
193 #[doc = "Bit 1 - Stero or Mono"]
194 #[inline(always)]
195 pub fn mono(&self) -> MONO_R {
196 MONO_R::new(((self.bits >> 1) & 1) != 0)
197 }
198 #[doc = "Bit 2 - Justification of I2S Data"]
199 #[inline(always)]
200 pub fn justify(&self) -> JUSTIFY_R {
201 JUSTIFY_R::new(((self.bits >> 2) & 1) != 0)
202 }
203 #[doc = "Bit 3 - Separate DMA Request For Left/Right Data"]
204 #[inline(always)]
205 pub fn dmasplit(&self) -> DMASPLIT_R {
206 DMASPLIT_R::new(((self.bits >> 3) & 1) != 0)
207 }
208 #[doc = "Bit 4 - Delay on I2S data"]
209 #[inline(always)]
210 pub fn delay(&self) -> DELAY_R {
211 DELAY_R::new(((self.bits >> 4) & 1) != 0)
212 }
213 #[doc = "Bits 8:10 - I2S Word Format"]
214 #[inline(always)]
215 pub fn format(&self) -> FORMAT_R {
216 FORMAT_R::new(((self.bits >> 8) & 7) as u8)
217 }
218}
219impl W {
220 #[doc = "Bit 0 - Enable I2S Mode"]
221 #[inline(always)]
222 pub fn en(&mut self) -> EN_W {
223 EN_W::new(self)
224 }
225 #[doc = "Bit 1 - Stero or Mono"]
226 #[inline(always)]
227 pub fn mono(&mut self) -> MONO_W {
228 MONO_W::new(self)
229 }
230 #[doc = "Bit 2 - Justification of I2S Data"]
231 #[inline(always)]
232 pub fn justify(&mut self) -> JUSTIFY_W {
233 JUSTIFY_W::new(self)
234 }
235 #[doc = "Bit 3 - Separate DMA Request For Left/Right Data"]
236 #[inline(always)]
237 pub fn dmasplit(&mut self) -> DMASPLIT_W {
238 DMASPLIT_W::new(self)
239 }
240 #[doc = "Bit 4 - Delay on I2S data"]
241 #[inline(always)]
242 pub fn delay(&mut self) -> DELAY_W {
243 DELAY_W::new(self)
244 }
245 #[doc = "Bits 8:10 - I2S Word Format"]
246 #[inline(always)]
247 pub fn format(&mut self) -> FORMAT_W {
248 FORMAT_W::new(self)
249 }
250 #[doc = "Writes raw bits to the register."]
251 #[inline(always)]
252 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
253 self.0.bits(bits);
254 self
255 }
256}
257#[doc = "I2S Control Register\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"]
258pub struct I2SCTRL_SPEC;
259impl crate::RegisterSpec for I2SCTRL_SPEC {
260 type Ux = u32;
261}
262#[doc = "`read()` method returns [i2sctrl::R](R) reader structure"]
263impl crate::Readable for I2SCTRL_SPEC {
264 type Reader = R;
265}
266#[doc = "`write(|w| ..)` method takes [i2sctrl::W](W) writer structure"]
267impl crate::Writable for I2SCTRL_SPEC {
268 type Writer = W;
269}
270#[doc = "`reset()` method sets I2SCTRL to value 0"]
271impl crate::Resettable for I2SCTRL_SPEC {
272 #[inline(always)]
273 fn reset_value() -> Self::Ux {
274 0
275 }
276}