efm32gg12b530_pac/usart1/
irctrl.rs1#[doc = "Register `IRCTRL` reader"]
2pub struct R(crate::R<IRCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<IRCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<IRCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<IRCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `IRCTRL` writer"]
17pub struct W(crate::W<IRCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<IRCTRL_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<IRCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<IRCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `IREN` reader - Enable IrDA Module"]
38pub type IREN_R = crate::BitReader<bool>;
39#[doc = "Field `IREN` writer - Enable IrDA Module"]
40pub type IREN_W<'a> = crate::BitWriter<'a, u32, IRCTRL_SPEC, bool, 0>;
41#[doc = "IrDA TX Pulse Width\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum IRPW_A {
45 #[doc = "0: IrDA pulse width is 1/16 for OVS=0 and 1/8 for OVS=1"]
46 ONE = 0,
47 #[doc = "1: IrDA pulse width is 2/16 for OVS=0 and 2/8 for OVS=1"]
48 TWO = 1,
49 #[doc = "2: IrDA pulse width is 3/16 for OVS=0 and 3/8 for OVS=1"]
50 THREE = 2,
51 #[doc = "3: IrDA pulse width is 4/16 for OVS=0 and 4/8 for OVS=1"]
52 FOUR = 3,
53}
54impl From<IRPW_A> for u8 {
55 #[inline(always)]
56 fn from(variant: IRPW_A) -> Self {
57 variant as _
58 }
59}
60#[doc = "Field `IRPW` reader - IrDA TX Pulse Width"]
61pub type IRPW_R = crate::FieldReader<u8, IRPW_A>;
62impl IRPW_R {
63 #[doc = "Get enumerated values variant"]
64 #[inline(always)]
65 pub fn variant(&self) -> IRPW_A {
66 match self.bits {
67 0 => IRPW_A::ONE,
68 1 => IRPW_A::TWO,
69 2 => IRPW_A::THREE,
70 3 => IRPW_A::FOUR,
71 _ => unreachable!(),
72 }
73 }
74 #[doc = "Checks if the value of the field is `ONE`"]
75 #[inline(always)]
76 pub fn is_one(&self) -> bool {
77 *self == IRPW_A::ONE
78 }
79 #[doc = "Checks if the value of the field is `TWO`"]
80 #[inline(always)]
81 pub fn is_two(&self) -> bool {
82 *self == IRPW_A::TWO
83 }
84 #[doc = "Checks if the value of the field is `THREE`"]
85 #[inline(always)]
86 pub fn is_three(&self) -> bool {
87 *self == IRPW_A::THREE
88 }
89 #[doc = "Checks if the value of the field is `FOUR`"]
90 #[inline(always)]
91 pub fn is_four(&self) -> bool {
92 *self == IRPW_A::FOUR
93 }
94}
95#[doc = "Field `IRPW` writer - IrDA TX Pulse Width"]
96pub type IRPW_W<'a> = crate::FieldWriterSafe<'a, u32, IRCTRL_SPEC, u8, IRPW_A, 2, 1>;
97impl<'a> IRPW_W<'a> {
98 #[doc = "IrDA pulse width is 1/16 for OVS=0 and 1/8 for OVS=1"]
99 #[inline(always)]
100 pub fn one(self) -> &'a mut W {
101 self.variant(IRPW_A::ONE)
102 }
103 #[doc = "IrDA pulse width is 2/16 for OVS=0 and 2/8 for OVS=1"]
104 #[inline(always)]
105 pub fn two(self) -> &'a mut W {
106 self.variant(IRPW_A::TWO)
107 }
108 #[doc = "IrDA pulse width is 3/16 for OVS=0 and 3/8 for OVS=1"]
109 #[inline(always)]
110 pub fn three(self) -> &'a mut W {
111 self.variant(IRPW_A::THREE)
112 }
113 #[doc = "IrDA pulse width is 4/16 for OVS=0 and 4/8 for OVS=1"]
114 #[inline(always)]
115 pub fn four(self) -> &'a mut W {
116 self.variant(IRPW_A::FOUR)
117 }
118}
119#[doc = "Field `IRFILT` reader - IrDA RX Filter"]
120pub type IRFILT_R = crate::BitReader<bool>;
121#[doc = "Field `IRFILT` writer - IrDA RX Filter"]
122pub type IRFILT_W<'a> = crate::BitWriter<'a, u32, IRCTRL_SPEC, bool, 3>;
123#[doc = "Field `IRPRSEN` reader - IrDA PRS Channel Enable"]
124pub type IRPRSEN_R = crate::BitReader<bool>;
125#[doc = "Field `IRPRSEN` writer - IrDA PRS Channel Enable"]
126pub type IRPRSEN_W<'a> = crate::BitWriter<'a, u32, IRCTRL_SPEC, bool, 7>;
127#[doc = "IrDA PRS Channel Select\n\nValue on reset: 0"]
128#[derive(Clone, Copy, Debug, PartialEq)]
129#[repr(u8)]
130pub enum IRPRSSEL_A {
131 #[doc = "0: PRS Channel 0 selected"]
132 PRSCH0 = 0,
133 #[doc = "1: PRS Channel 1 selected"]
134 PRSCH1 = 1,
135 #[doc = "2: PRS Channel 2 selected"]
136 PRSCH2 = 2,
137 #[doc = "3: PRS Channel 3 selected"]
138 PRSCH3 = 3,
139 #[doc = "4: PRS Channel 4 selected"]
140 PRSCH4 = 4,
141 #[doc = "5: PRS Channel 5 selected"]
142 PRSCH5 = 5,
143 #[doc = "6: PRS Channel 6 selected"]
144 PRSCH6 = 6,
145 #[doc = "7: PRS Channel 7 selected"]
146 PRSCH7 = 7,
147 #[doc = "8: PRS Channel 8 selected"]
148 PRSCH8 = 8,
149 #[doc = "9: PRS Channel 9 selected"]
150 PRSCH9 = 9,
151 #[doc = "10: PRS Channel 10 selected"]
152 PRSCH10 = 10,
153 #[doc = "11: PRS Channel 11 selected"]
154 PRSCH11 = 11,
155 #[doc = "12: PRS Channel 12 selected"]
156 PRSCH12 = 12,
157 #[doc = "13: PRS Channel 13 selected"]
158 PRSCH13 = 13,
159 #[doc = "14: PRS Channel 14 selected"]
160 PRSCH14 = 14,
161 #[doc = "15: PRS Channel 15 selected"]
162 PRSCH15 = 15,
163}
164impl From<IRPRSSEL_A> for u8 {
165 #[inline(always)]
166 fn from(variant: IRPRSSEL_A) -> Self {
167 variant as _
168 }
169}
170#[doc = "Field `IRPRSSEL` reader - IrDA PRS Channel Select"]
171pub type IRPRSSEL_R = crate::FieldReader<u8, IRPRSSEL_A>;
172impl IRPRSSEL_R {
173 #[doc = "Get enumerated values variant"]
174 #[inline(always)]
175 pub fn variant(&self) -> IRPRSSEL_A {
176 match self.bits {
177 0 => IRPRSSEL_A::PRSCH0,
178 1 => IRPRSSEL_A::PRSCH1,
179 2 => IRPRSSEL_A::PRSCH2,
180 3 => IRPRSSEL_A::PRSCH3,
181 4 => IRPRSSEL_A::PRSCH4,
182 5 => IRPRSSEL_A::PRSCH5,
183 6 => IRPRSSEL_A::PRSCH6,
184 7 => IRPRSSEL_A::PRSCH7,
185 8 => IRPRSSEL_A::PRSCH8,
186 9 => IRPRSSEL_A::PRSCH9,
187 10 => IRPRSSEL_A::PRSCH10,
188 11 => IRPRSSEL_A::PRSCH11,
189 12 => IRPRSSEL_A::PRSCH12,
190 13 => IRPRSSEL_A::PRSCH13,
191 14 => IRPRSSEL_A::PRSCH14,
192 15 => IRPRSSEL_A::PRSCH15,
193 _ => unreachable!(),
194 }
195 }
196 #[doc = "Checks if the value of the field is `PRSCH0`"]
197 #[inline(always)]
198 pub fn is_prsch0(&self) -> bool {
199 *self == IRPRSSEL_A::PRSCH0
200 }
201 #[doc = "Checks if the value of the field is `PRSCH1`"]
202 #[inline(always)]
203 pub fn is_prsch1(&self) -> bool {
204 *self == IRPRSSEL_A::PRSCH1
205 }
206 #[doc = "Checks if the value of the field is `PRSCH2`"]
207 #[inline(always)]
208 pub fn is_prsch2(&self) -> bool {
209 *self == IRPRSSEL_A::PRSCH2
210 }
211 #[doc = "Checks if the value of the field is `PRSCH3`"]
212 #[inline(always)]
213 pub fn is_prsch3(&self) -> bool {
214 *self == IRPRSSEL_A::PRSCH3
215 }
216 #[doc = "Checks if the value of the field is `PRSCH4`"]
217 #[inline(always)]
218 pub fn is_prsch4(&self) -> bool {
219 *self == IRPRSSEL_A::PRSCH4
220 }
221 #[doc = "Checks if the value of the field is `PRSCH5`"]
222 #[inline(always)]
223 pub fn is_prsch5(&self) -> bool {
224 *self == IRPRSSEL_A::PRSCH5
225 }
226 #[doc = "Checks if the value of the field is `PRSCH6`"]
227 #[inline(always)]
228 pub fn is_prsch6(&self) -> bool {
229 *self == IRPRSSEL_A::PRSCH6
230 }
231 #[doc = "Checks if the value of the field is `PRSCH7`"]
232 #[inline(always)]
233 pub fn is_prsch7(&self) -> bool {
234 *self == IRPRSSEL_A::PRSCH7
235 }
236 #[doc = "Checks if the value of the field is `PRSCH8`"]
237 #[inline(always)]
238 pub fn is_prsch8(&self) -> bool {
239 *self == IRPRSSEL_A::PRSCH8
240 }
241 #[doc = "Checks if the value of the field is `PRSCH9`"]
242 #[inline(always)]
243 pub fn is_prsch9(&self) -> bool {
244 *self == IRPRSSEL_A::PRSCH9
245 }
246 #[doc = "Checks if the value of the field is `PRSCH10`"]
247 #[inline(always)]
248 pub fn is_prsch10(&self) -> bool {
249 *self == IRPRSSEL_A::PRSCH10
250 }
251 #[doc = "Checks if the value of the field is `PRSCH11`"]
252 #[inline(always)]
253 pub fn is_prsch11(&self) -> bool {
254 *self == IRPRSSEL_A::PRSCH11
255 }
256 #[doc = "Checks if the value of the field is `PRSCH12`"]
257 #[inline(always)]
258 pub fn is_prsch12(&self) -> bool {
259 *self == IRPRSSEL_A::PRSCH12
260 }
261 #[doc = "Checks if the value of the field is `PRSCH13`"]
262 #[inline(always)]
263 pub fn is_prsch13(&self) -> bool {
264 *self == IRPRSSEL_A::PRSCH13
265 }
266 #[doc = "Checks if the value of the field is `PRSCH14`"]
267 #[inline(always)]
268 pub fn is_prsch14(&self) -> bool {
269 *self == IRPRSSEL_A::PRSCH14
270 }
271 #[doc = "Checks if the value of the field is `PRSCH15`"]
272 #[inline(always)]
273 pub fn is_prsch15(&self) -> bool {
274 *self == IRPRSSEL_A::PRSCH15
275 }
276}
277#[doc = "Field `IRPRSSEL` writer - IrDA PRS Channel Select"]
278pub type IRPRSSEL_W<'a> = crate::FieldWriterSafe<'a, u32, IRCTRL_SPEC, u8, IRPRSSEL_A, 4, 8>;
279impl<'a> IRPRSSEL_W<'a> {
280 #[doc = "PRS Channel 0 selected"]
281 #[inline(always)]
282 pub fn prsch0(self) -> &'a mut W {
283 self.variant(IRPRSSEL_A::PRSCH0)
284 }
285 #[doc = "PRS Channel 1 selected"]
286 #[inline(always)]
287 pub fn prsch1(self) -> &'a mut W {
288 self.variant(IRPRSSEL_A::PRSCH1)
289 }
290 #[doc = "PRS Channel 2 selected"]
291 #[inline(always)]
292 pub fn prsch2(self) -> &'a mut W {
293 self.variant(IRPRSSEL_A::PRSCH2)
294 }
295 #[doc = "PRS Channel 3 selected"]
296 #[inline(always)]
297 pub fn prsch3(self) -> &'a mut W {
298 self.variant(IRPRSSEL_A::PRSCH3)
299 }
300 #[doc = "PRS Channel 4 selected"]
301 #[inline(always)]
302 pub fn prsch4(self) -> &'a mut W {
303 self.variant(IRPRSSEL_A::PRSCH4)
304 }
305 #[doc = "PRS Channel 5 selected"]
306 #[inline(always)]
307 pub fn prsch5(self) -> &'a mut W {
308 self.variant(IRPRSSEL_A::PRSCH5)
309 }
310 #[doc = "PRS Channel 6 selected"]
311 #[inline(always)]
312 pub fn prsch6(self) -> &'a mut W {
313 self.variant(IRPRSSEL_A::PRSCH6)
314 }
315 #[doc = "PRS Channel 7 selected"]
316 #[inline(always)]
317 pub fn prsch7(self) -> &'a mut W {
318 self.variant(IRPRSSEL_A::PRSCH7)
319 }
320 #[doc = "PRS Channel 8 selected"]
321 #[inline(always)]
322 pub fn prsch8(self) -> &'a mut W {
323 self.variant(IRPRSSEL_A::PRSCH8)
324 }
325 #[doc = "PRS Channel 9 selected"]
326 #[inline(always)]
327 pub fn prsch9(self) -> &'a mut W {
328 self.variant(IRPRSSEL_A::PRSCH9)
329 }
330 #[doc = "PRS Channel 10 selected"]
331 #[inline(always)]
332 pub fn prsch10(self) -> &'a mut W {
333 self.variant(IRPRSSEL_A::PRSCH10)
334 }
335 #[doc = "PRS Channel 11 selected"]
336 #[inline(always)]
337 pub fn prsch11(self) -> &'a mut W {
338 self.variant(IRPRSSEL_A::PRSCH11)
339 }
340 #[doc = "PRS Channel 12 selected"]
341 #[inline(always)]
342 pub fn prsch12(self) -> &'a mut W {
343 self.variant(IRPRSSEL_A::PRSCH12)
344 }
345 #[doc = "PRS Channel 13 selected"]
346 #[inline(always)]
347 pub fn prsch13(self) -> &'a mut W {
348 self.variant(IRPRSSEL_A::PRSCH13)
349 }
350 #[doc = "PRS Channel 14 selected"]
351 #[inline(always)]
352 pub fn prsch14(self) -> &'a mut W {
353 self.variant(IRPRSSEL_A::PRSCH14)
354 }
355 #[doc = "PRS Channel 15 selected"]
356 #[inline(always)]
357 pub fn prsch15(self) -> &'a mut W {
358 self.variant(IRPRSSEL_A::PRSCH15)
359 }
360}
361impl R {
362 #[doc = "Bit 0 - Enable IrDA Module"]
363 #[inline(always)]
364 pub fn iren(&self) -> IREN_R {
365 IREN_R::new((self.bits & 1) != 0)
366 }
367 #[doc = "Bits 1:2 - IrDA TX Pulse Width"]
368 #[inline(always)]
369 pub fn irpw(&self) -> IRPW_R {
370 IRPW_R::new(((self.bits >> 1) & 3) as u8)
371 }
372 #[doc = "Bit 3 - IrDA RX Filter"]
373 #[inline(always)]
374 pub fn irfilt(&self) -> IRFILT_R {
375 IRFILT_R::new(((self.bits >> 3) & 1) != 0)
376 }
377 #[doc = "Bit 7 - IrDA PRS Channel Enable"]
378 #[inline(always)]
379 pub fn irprsen(&self) -> IRPRSEN_R {
380 IRPRSEN_R::new(((self.bits >> 7) & 1) != 0)
381 }
382 #[doc = "Bits 8:11 - IrDA PRS Channel Select"]
383 #[inline(always)]
384 pub fn irprssel(&self) -> IRPRSSEL_R {
385 IRPRSSEL_R::new(((self.bits >> 8) & 0x0f) as u8)
386 }
387}
388impl W {
389 #[doc = "Bit 0 - Enable IrDA Module"]
390 #[inline(always)]
391 pub fn iren(&mut self) -> IREN_W {
392 IREN_W::new(self)
393 }
394 #[doc = "Bits 1:2 - IrDA TX Pulse Width"]
395 #[inline(always)]
396 pub fn irpw(&mut self) -> IRPW_W {
397 IRPW_W::new(self)
398 }
399 #[doc = "Bit 3 - IrDA RX Filter"]
400 #[inline(always)]
401 pub fn irfilt(&mut self) -> IRFILT_W {
402 IRFILT_W::new(self)
403 }
404 #[doc = "Bit 7 - IrDA PRS Channel Enable"]
405 #[inline(always)]
406 pub fn irprsen(&mut self) -> IRPRSEN_W {
407 IRPRSEN_W::new(self)
408 }
409 #[doc = "Bits 8:11 - IrDA PRS Channel Select"]
410 #[inline(always)]
411 pub fn irprssel(&mut self) -> IRPRSSEL_W {
412 IRPRSSEL_W::new(self)
413 }
414 #[doc = "Writes raw bits to the register."]
415 #[inline(always)]
416 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
417 self.0.bits(bits);
418 self
419 }
420}
421#[doc = "IrDA 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 [irctrl](index.html) module"]
422pub struct IRCTRL_SPEC;
423impl crate::RegisterSpec for IRCTRL_SPEC {
424 type Ux = u32;
425}
426#[doc = "`read()` method returns [irctrl::R](R) reader structure"]
427impl crate::Readable for IRCTRL_SPEC {
428 type Reader = R;
429}
430#[doc = "`write(|w| ..)` method takes [irctrl::W](W) writer structure"]
431impl crate::Writable for IRCTRL_SPEC {
432 type Writer = W;
433}
434#[doc = "`reset()` method sets IRCTRL to value 0"]
435impl crate::Resettable for IRCTRL_SPEC {
436 #[inline(always)]
437 fn reset_value() -> Self::Ux {
438 0
439 }
440}