efm32gg_pac/efm32gg230/usart2/
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<bool>;
47#[doc = "Field `JUSTIFY` writer - Justification of I2S Data"]
48pub type JUSTIFY_W<'a, const O: u8> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, I2SCTRL_SPEC, bool, O>;
57#[doc = "Field `FORMAT` reader - I2S Word Format"]
58pub type FORMAT_R = crate::FieldReader<u8, FORMAT_A>;
59#[doc = "I2S Word Format\n\nValue on reset: 0"]
60#[derive(Clone, Copy, Debug, PartialEq, Eq)]
61#[repr(u8)]
62pub enum FORMAT_A {
63 #[doc = "0: 32-bit word, 32-bit data"]
64 W32D32 = 0,
65 #[doc = "1: 32-bit word, 32-bit data with 8 lsb masked"]
66 W32D24M = 1,
67 #[doc = "2: 32-bit word, 24-bit data"]
68 W32D24 = 2,
69 #[doc = "3: 32-bit word, 16-bit data"]
70 W32D16 = 3,
71 #[doc = "4: 32-bit word, 8-bit data"]
72 W32D8 = 4,
73 #[doc = "5: 16-bit word, 16-bit data"]
74 W16D16 = 5,
75 #[doc = "6: 16-bit word, 8-bit data"]
76 W16D8 = 6,
77 #[doc = "7: 8-bit word, 8-bit data"]
78 W8D8 = 7,
79}
80impl From<FORMAT_A> for u8 {
81 #[inline(always)]
82 fn from(variant: FORMAT_A) -> Self {
83 variant as _
84 }
85}
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, const O: u8> =
145 crate::FieldWriterSafe<'a, u32, I2SCTRL_SPEC, u8, FORMAT_A, 3, O>;
146impl<'a, const O: u8> FORMAT_W<'a, O> {
147 #[doc = "32-bit word, 32-bit data"]
148 #[inline(always)]
149 pub fn w32d32(self) -> &'a mut W {
150 self.variant(FORMAT_A::W32D32)
151 }
152 #[doc = "32-bit word, 32-bit data with 8 lsb masked"]
153 #[inline(always)]
154 pub fn w32d24m(self) -> &'a mut W {
155 self.variant(FORMAT_A::W32D24M)
156 }
157 #[doc = "32-bit word, 24-bit data"]
158 #[inline(always)]
159 pub fn w32d24(self) -> &'a mut W {
160 self.variant(FORMAT_A::W32D24)
161 }
162 #[doc = "32-bit word, 16-bit data"]
163 #[inline(always)]
164 pub fn w32d16(self) -> &'a mut W {
165 self.variant(FORMAT_A::W32D16)
166 }
167 #[doc = "32-bit word, 8-bit data"]
168 #[inline(always)]
169 pub fn w32d8(self) -> &'a mut W {
170 self.variant(FORMAT_A::W32D8)
171 }
172 #[doc = "16-bit word, 16-bit data"]
173 #[inline(always)]
174 pub fn w16d16(self) -> &'a mut W {
175 self.variant(FORMAT_A::W16D16)
176 }
177 #[doc = "16-bit word, 8-bit data"]
178 #[inline(always)]
179 pub fn w16d8(self) -> &'a mut W {
180 self.variant(FORMAT_A::W16D8)
181 }
182 #[doc = "8-bit word, 8-bit data"]
183 #[inline(always)]
184 pub fn w8d8(self) -> &'a mut W {
185 self.variant(FORMAT_A::W8D8)
186 }
187}
188impl R {
189 #[doc = "Bit 0 - Enable I2S Mode"]
190 #[inline(always)]
191 pub fn en(&self) -> EN_R {
192 EN_R::new((self.bits & 1) != 0)
193 }
194 #[doc = "Bit 1 - Stero or Mono"]
195 #[inline(always)]
196 pub fn mono(&self) -> MONO_R {
197 MONO_R::new(((self.bits >> 1) & 1) != 0)
198 }
199 #[doc = "Bit 2 - Justification of I2S Data"]
200 #[inline(always)]
201 pub fn justify(&self) -> JUSTIFY_R {
202 JUSTIFY_R::new(((self.bits >> 2) & 1) != 0)
203 }
204 #[doc = "Bit 3 - Separate DMA Request For Left/Right Data"]
205 #[inline(always)]
206 pub fn dmasplit(&self) -> DMASPLIT_R {
207 DMASPLIT_R::new(((self.bits >> 3) & 1) != 0)
208 }
209 #[doc = "Bit 4 - Delay on I2S data"]
210 #[inline(always)]
211 pub fn delay(&self) -> DELAY_R {
212 DELAY_R::new(((self.bits >> 4) & 1) != 0)
213 }
214 #[doc = "Bits 8:10 - I2S Word Format"]
215 #[inline(always)]
216 pub fn format(&self) -> FORMAT_R {
217 FORMAT_R::new(((self.bits >> 8) & 7) as u8)
218 }
219}
220impl W {
221 #[doc = "Bit 0 - Enable I2S Mode"]
222 #[inline(always)]
223 #[must_use]
224 pub fn en(&mut self) -> EN_W<0> {
225 EN_W::new(self)
226 }
227 #[doc = "Bit 1 - Stero or Mono"]
228 #[inline(always)]
229 #[must_use]
230 pub fn mono(&mut self) -> MONO_W<1> {
231 MONO_W::new(self)
232 }
233 #[doc = "Bit 2 - Justification of I2S Data"]
234 #[inline(always)]
235 #[must_use]
236 pub fn justify(&mut self) -> JUSTIFY_W<2> {
237 JUSTIFY_W::new(self)
238 }
239 #[doc = "Bit 3 - Separate DMA Request For Left/Right Data"]
240 #[inline(always)]
241 #[must_use]
242 pub fn dmasplit(&mut self) -> DMASPLIT_W<3> {
243 DMASPLIT_W::new(self)
244 }
245 #[doc = "Bit 4 - Delay on I2S data"]
246 #[inline(always)]
247 #[must_use]
248 pub fn delay(&mut self) -> DELAY_W<4> {
249 DELAY_W::new(self)
250 }
251 #[doc = "Bits 8:10 - I2S Word Format"]
252 #[inline(always)]
253 #[must_use]
254 pub fn format(&mut self) -> FORMAT_W<8> {
255 FORMAT_W::new(self)
256 }
257 #[doc = "Writes raw bits to the register."]
258 #[inline(always)]
259 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
260 self.0.bits(bits);
261 self
262 }
263}
264#[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"]
265pub struct I2SCTRL_SPEC;
266impl crate::RegisterSpec for I2SCTRL_SPEC {
267 type Ux = u32;
268}
269#[doc = "`read()` method returns [i2sctrl::R](R) reader structure"]
270impl crate::Readable for I2SCTRL_SPEC {
271 type Reader = R;
272}
273#[doc = "`write(|w| ..)` method takes [i2sctrl::W](W) writer structure"]
274impl crate::Writable for I2SCTRL_SPEC {
275 type Writer = W;
276 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
277 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
278}
279#[doc = "`reset()` method sets I2SCTRL to value 0"]
280impl crate::Resettable for I2SCTRL_SPEC {
281 const RESET_VALUE: Self::Ux = 0;
282}