efm32g230_pac/usart2/
frame.rs

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