efm32pg12_pac/usart0/
frame.rs

1#[doc = "Reader of register FRAME"]
2pub type R = crate::R<u32, super::FRAME>;
3#[doc = "Writer for register FRAME"]
4pub type W = crate::W<u32, super::FRAME>;
5#[doc = "Register FRAME `reset()`'s with value 0x1005"]
6impl crate::ResetValue for super::FRAME {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0x1005
11    }
12}
13#[doc = "Data-Bit Mode\n\nValue on reset: 5"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum DATABITS_A {
17    #[doc = "1: Each frame contains 4 data bits"]
18    FOUR = 1,
19    #[doc = "2: Each frame contains 5 data bits"]
20    FIVE = 2,
21    #[doc = "3: Each frame contains 6 data bits"]
22    SIX = 3,
23    #[doc = "4: Each frame contains 7 data bits"]
24    SEVEN = 4,
25    #[doc = "5: Each frame contains 8 data bits"]
26    EIGHT = 5,
27    #[doc = "6: Each frame contains 9 data bits"]
28    NINE = 6,
29    #[doc = "7: Each frame contains 10 data bits"]
30    TEN = 7,
31    #[doc = "8: Each frame contains 11 data bits"]
32    ELEVEN = 8,
33    #[doc = "9: Each frame contains 12 data bits"]
34    TWELVE = 9,
35    #[doc = "10: Each frame contains 13 data bits"]
36    THIRTEEN = 10,
37    #[doc = "11: Each frame contains 14 data bits"]
38    FOURTEEN = 11,
39    #[doc = "12: Each frame contains 15 data bits"]
40    FIFTEEN = 12,
41    #[doc = "13: Each frame contains 16 data bits"]
42    SIXTEEN = 13,
43}
44impl From<DATABITS_A> for u8 {
45    #[inline(always)]
46    fn from(variant: DATABITS_A) -> Self {
47        variant as _
48    }
49}
50#[doc = "Reader of field `DATABITS`"]
51pub type DATABITS_R = crate::R<u8, DATABITS_A>;
52impl DATABITS_R {
53    #[doc = r"Get enumerated values variant"]
54    #[inline(always)]
55    pub fn variant(&self) -> crate::Variant<u8, DATABITS_A> {
56        use crate::Variant::*;
57        match self.bits {
58            1 => Val(DATABITS_A::FOUR),
59            2 => Val(DATABITS_A::FIVE),
60            3 => Val(DATABITS_A::SIX),
61            4 => Val(DATABITS_A::SEVEN),
62            5 => Val(DATABITS_A::EIGHT),
63            6 => Val(DATABITS_A::NINE),
64            7 => Val(DATABITS_A::TEN),
65            8 => Val(DATABITS_A::ELEVEN),
66            9 => Val(DATABITS_A::TWELVE),
67            10 => Val(DATABITS_A::THIRTEEN),
68            11 => Val(DATABITS_A::FOURTEEN),
69            12 => Val(DATABITS_A::FIFTEEN),
70            13 => Val(DATABITS_A::SIXTEEN),
71            i => Res(i),
72        }
73    }
74    #[doc = "Checks if the value of the field is `FOUR`"]
75    #[inline(always)]
76    pub fn is_four(&self) -> bool {
77        *self == DATABITS_A::FOUR
78    }
79    #[doc = "Checks if the value of the field is `FIVE`"]
80    #[inline(always)]
81    pub fn is_five(&self) -> bool {
82        *self == DATABITS_A::FIVE
83    }
84    #[doc = "Checks if the value of the field is `SIX`"]
85    #[inline(always)]
86    pub fn is_six(&self) -> bool {
87        *self == DATABITS_A::SIX
88    }
89    #[doc = "Checks if the value of the field is `SEVEN`"]
90    #[inline(always)]
91    pub fn is_seven(&self) -> bool {
92        *self == DATABITS_A::SEVEN
93    }
94    #[doc = "Checks if the value of the field is `EIGHT`"]
95    #[inline(always)]
96    pub fn is_eight(&self) -> bool {
97        *self == DATABITS_A::EIGHT
98    }
99    #[doc = "Checks if the value of the field is `NINE`"]
100    #[inline(always)]
101    pub fn is_nine(&self) -> bool {
102        *self == DATABITS_A::NINE
103    }
104    #[doc = "Checks if the value of the field is `TEN`"]
105    #[inline(always)]
106    pub fn is_ten(&self) -> bool {
107        *self == DATABITS_A::TEN
108    }
109    #[doc = "Checks if the value of the field is `ELEVEN`"]
110    #[inline(always)]
111    pub fn is_eleven(&self) -> bool {
112        *self == DATABITS_A::ELEVEN
113    }
114    #[doc = "Checks if the value of the field is `TWELVE`"]
115    #[inline(always)]
116    pub fn is_twelve(&self) -> bool {
117        *self == DATABITS_A::TWELVE
118    }
119    #[doc = "Checks if the value of the field is `THIRTEEN`"]
120    #[inline(always)]
121    pub fn is_thirteen(&self) -> bool {
122        *self == DATABITS_A::THIRTEEN
123    }
124    #[doc = "Checks if the value of the field is `FOURTEEN`"]
125    #[inline(always)]
126    pub fn is_fourteen(&self) -> bool {
127        *self == DATABITS_A::FOURTEEN
128    }
129    #[doc = "Checks if the value of the field is `FIFTEEN`"]
130    #[inline(always)]
131    pub fn is_fifteen(&self) -> bool {
132        *self == DATABITS_A::FIFTEEN
133    }
134    #[doc = "Checks if the value of the field is `SIXTEEN`"]
135    #[inline(always)]
136    pub fn is_sixteen(&self) -> bool {
137        *self == DATABITS_A::SIXTEEN
138    }
139}
140#[doc = "Write proxy for field `DATABITS`"]
141pub struct DATABITS_W<'a> {
142    w: &'a mut W,
143}
144impl<'a> DATABITS_W<'a> {
145    #[doc = r"Writes `variant` to the field"]
146    #[inline(always)]
147    pub fn variant(self, variant: DATABITS_A) -> &'a mut W {
148        unsafe { self.bits(variant.into()) }
149    }
150    #[doc = "Each frame contains 4 data bits"]
151    #[inline(always)]
152    pub fn four(self) -> &'a mut W {
153        self.variant(DATABITS_A::FOUR)
154    }
155    #[doc = "Each frame contains 5 data bits"]
156    #[inline(always)]
157    pub fn five(self) -> &'a mut W {
158        self.variant(DATABITS_A::FIVE)
159    }
160    #[doc = "Each frame contains 6 data bits"]
161    #[inline(always)]
162    pub fn six(self) -> &'a mut W {
163        self.variant(DATABITS_A::SIX)
164    }
165    #[doc = "Each frame contains 7 data bits"]
166    #[inline(always)]
167    pub fn seven(self) -> &'a mut W {
168        self.variant(DATABITS_A::SEVEN)
169    }
170    #[doc = "Each frame contains 8 data bits"]
171    #[inline(always)]
172    pub fn eight(self) -> &'a mut W {
173        self.variant(DATABITS_A::EIGHT)
174    }
175    #[doc = "Each frame contains 9 data bits"]
176    #[inline(always)]
177    pub fn nine(self) -> &'a mut W {
178        self.variant(DATABITS_A::NINE)
179    }
180    #[doc = "Each frame contains 10 data bits"]
181    #[inline(always)]
182    pub fn ten(self) -> &'a mut W {
183        self.variant(DATABITS_A::TEN)
184    }
185    #[doc = "Each frame contains 11 data bits"]
186    #[inline(always)]
187    pub fn eleven(self) -> &'a mut W {
188        self.variant(DATABITS_A::ELEVEN)
189    }
190    #[doc = "Each frame contains 12 data bits"]
191    #[inline(always)]
192    pub fn twelve(self) -> &'a mut W {
193        self.variant(DATABITS_A::TWELVE)
194    }
195    #[doc = "Each frame contains 13 data bits"]
196    #[inline(always)]
197    pub fn thirteen(self) -> &'a mut W {
198        self.variant(DATABITS_A::THIRTEEN)
199    }
200    #[doc = "Each frame contains 14 data bits"]
201    #[inline(always)]
202    pub fn fourteen(self) -> &'a mut W {
203        self.variant(DATABITS_A::FOURTEEN)
204    }
205    #[doc = "Each frame contains 15 data bits"]
206    #[inline(always)]
207    pub fn fifteen(self) -> &'a mut W {
208        self.variant(DATABITS_A::FIFTEEN)
209    }
210    #[doc = "Each frame contains 16 data bits"]
211    #[inline(always)]
212    pub fn sixteen(self) -> &'a mut W {
213        self.variant(DATABITS_A::SIXTEEN)
214    }
215    #[doc = r"Writes raw bits to the field"]
216    #[inline(always)]
217    pub unsafe fn bits(self, value: u8) -> &'a mut W {
218        self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
219        self.w
220    }
221}
222#[doc = "Parity-Bit Mode\n\nValue on reset: 0"]
223#[derive(Clone, Copy, Debug, PartialEq)]
224#[repr(u8)]
225pub enum PARITY_A {
226    #[doc = "0: Parity bits are not used"]
227    NONE = 0,
228    #[doc = "2: Even parity are used. Parity bits are automatically generated and checked by hardware."]
229    EVEN = 2,
230    #[doc = "3: Odd parity is used. Parity bits are automatically generated and checked by hardware."]
231    ODD = 3,
232}
233impl From<PARITY_A> for u8 {
234    #[inline(always)]
235    fn from(variant: PARITY_A) -> Self {
236        variant as _
237    }
238}
239#[doc = "Reader of field `PARITY`"]
240pub type PARITY_R = crate::R<u8, PARITY_A>;
241impl PARITY_R {
242    #[doc = r"Get enumerated values variant"]
243    #[inline(always)]
244    pub fn variant(&self) -> crate::Variant<u8, PARITY_A> {
245        use crate::Variant::*;
246        match self.bits {
247            0 => Val(PARITY_A::NONE),
248            2 => Val(PARITY_A::EVEN),
249            3 => Val(PARITY_A::ODD),
250            i => Res(i),
251        }
252    }
253    #[doc = "Checks if the value of the field is `NONE`"]
254    #[inline(always)]
255    pub fn is_none(&self) -> bool {
256        *self == PARITY_A::NONE
257    }
258    #[doc = "Checks if the value of the field is `EVEN`"]
259    #[inline(always)]
260    pub fn is_even(&self) -> bool {
261        *self == PARITY_A::EVEN
262    }
263    #[doc = "Checks if the value of the field is `ODD`"]
264    #[inline(always)]
265    pub fn is_odd(&self) -> bool {
266        *self == PARITY_A::ODD
267    }
268}
269#[doc = "Write proxy for field `PARITY`"]
270pub struct PARITY_W<'a> {
271    w: &'a mut W,
272}
273impl<'a> PARITY_W<'a> {
274    #[doc = r"Writes `variant` to the field"]
275    #[inline(always)]
276    pub fn variant(self, variant: PARITY_A) -> &'a mut W {
277        unsafe { self.bits(variant.into()) }
278    }
279    #[doc = "Parity bits are not used"]
280    #[inline(always)]
281    pub fn none(self) -> &'a mut W {
282        self.variant(PARITY_A::NONE)
283    }
284    #[doc = "Even parity are used. Parity bits are automatically generated and checked by hardware."]
285    #[inline(always)]
286    pub fn even(self) -> &'a mut W {
287        self.variant(PARITY_A::EVEN)
288    }
289    #[doc = "Odd parity is used. Parity bits are automatically generated and checked by hardware."]
290    #[inline(always)]
291    pub fn odd(self) -> &'a mut W {
292        self.variant(PARITY_A::ODD)
293    }
294    #[doc = r"Writes raw bits to the field"]
295    #[inline(always)]
296    pub unsafe fn bits(self, value: u8) -> &'a mut W {
297        self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
298        self.w
299    }
300}
301#[doc = "Stop-Bit Mode\n\nValue on reset: 1"]
302#[derive(Clone, Copy, Debug, PartialEq)]
303#[repr(u8)]
304pub enum STOPBITS_A {
305    #[doc = "0: The transmitter generates a half stop bit. Stop-bits are not verified by receiver"]
306    HALF = 0,
307    #[doc = "1: One stop bit is generated and verified"]
308    ONE = 1,
309    #[doc = "2: The transmitter generates one and a half stop bit. The receiver verifies the first stop bit"]
310    ONEANDAHALF = 2,
311    #[doc = "3: The transmitter generates two stop bits. The receiver checks the first stop-bit only"]
312    TWO = 3,
313}
314impl From<STOPBITS_A> for u8 {
315    #[inline(always)]
316    fn from(variant: STOPBITS_A) -> Self {
317        variant as _
318    }
319}
320#[doc = "Reader of field `STOPBITS`"]
321pub type STOPBITS_R = crate::R<u8, STOPBITS_A>;
322impl STOPBITS_R {
323    #[doc = r"Get enumerated values variant"]
324    #[inline(always)]
325    pub fn variant(&self) -> STOPBITS_A {
326        match self.bits {
327            0 => STOPBITS_A::HALF,
328            1 => STOPBITS_A::ONE,
329            2 => STOPBITS_A::ONEANDAHALF,
330            3 => STOPBITS_A::TWO,
331            _ => unreachable!(),
332        }
333    }
334    #[doc = "Checks if the value of the field is `HALF`"]
335    #[inline(always)]
336    pub fn is_half(&self) -> bool {
337        *self == STOPBITS_A::HALF
338    }
339    #[doc = "Checks if the value of the field is `ONE`"]
340    #[inline(always)]
341    pub fn is_one(&self) -> bool {
342        *self == STOPBITS_A::ONE
343    }
344    #[doc = "Checks if the value of the field is `ONEANDAHALF`"]
345    #[inline(always)]
346    pub fn is_oneandahalf(&self) -> bool {
347        *self == STOPBITS_A::ONEANDAHALF
348    }
349    #[doc = "Checks if the value of the field is `TWO`"]
350    #[inline(always)]
351    pub fn is_two(&self) -> bool {
352        *self == STOPBITS_A::TWO
353    }
354}
355#[doc = "Write proxy for field `STOPBITS`"]
356pub struct STOPBITS_W<'a> {
357    w: &'a mut W,
358}
359impl<'a> STOPBITS_W<'a> {
360    #[doc = r"Writes `variant` to the field"]
361    #[inline(always)]
362    pub fn variant(self, variant: STOPBITS_A) -> &'a mut W {
363        {
364            self.bits(variant.into())
365        }
366    }
367    #[doc = "The transmitter generates a half stop bit. Stop-bits are not verified by receiver"]
368    #[inline(always)]
369    pub fn half(self) -> &'a mut W {
370        self.variant(STOPBITS_A::HALF)
371    }
372    #[doc = "One stop bit is generated and verified"]
373    #[inline(always)]
374    pub fn one(self) -> &'a mut W {
375        self.variant(STOPBITS_A::ONE)
376    }
377    #[doc = "The transmitter generates one and a half stop bit. The receiver verifies the first stop bit"]
378    #[inline(always)]
379    pub fn oneandahalf(self) -> &'a mut W {
380        self.variant(STOPBITS_A::ONEANDAHALF)
381    }
382    #[doc = "The transmitter generates two stop bits. The receiver checks the first stop-bit only"]
383    #[inline(always)]
384    pub fn two(self) -> &'a mut W {
385        self.variant(STOPBITS_A::TWO)
386    }
387    #[doc = r"Writes raw bits to the field"]
388    #[inline(always)]
389    pub fn bits(self, value: u8) -> &'a mut W {
390        self.w.bits = (self.w.bits & !(0x03 << 12)) | (((value as u32) & 0x03) << 12);
391        self.w
392    }
393}
394impl R {
395    #[doc = "Bits 0:3 - Data-Bit Mode"]
396    #[inline(always)]
397    pub fn databits(&self) -> DATABITS_R {
398        DATABITS_R::new((self.bits & 0x0f) as u8)
399    }
400    #[doc = "Bits 8:9 - Parity-Bit Mode"]
401    #[inline(always)]
402    pub fn parity(&self) -> PARITY_R {
403        PARITY_R::new(((self.bits >> 8) & 0x03) as u8)
404    }
405    #[doc = "Bits 12:13 - Stop-Bit Mode"]
406    #[inline(always)]
407    pub fn stopbits(&self) -> STOPBITS_R {
408        STOPBITS_R::new(((self.bits >> 12) & 0x03) as u8)
409    }
410}
411impl W {
412    #[doc = "Bits 0:3 - Data-Bit Mode"]
413    #[inline(always)]
414    pub fn databits(&mut self) -> DATABITS_W {
415        DATABITS_W { w: self }
416    }
417    #[doc = "Bits 8:9 - Parity-Bit Mode"]
418    #[inline(always)]
419    pub fn parity(&mut self) -> PARITY_W {
420        PARITY_W { w: self }
421    }
422    #[doc = "Bits 12:13 - Stop-Bit Mode"]
423    #[inline(always)]
424    pub fn stopbits(&mut self) -> STOPBITS_W {
425        STOPBITS_W { w: self }
426    }
427}