atsame54p20a/sercom0/usart_int/
ctrlb.rs

1#[doc = "Reader of register CTRLB"]
2pub type R = crate::R<u32, super::CTRLB>;
3#[doc = "Writer for register CTRLB"]
4pub type W = crate::W<u32, super::CTRLB>;
5#[doc = "Register CTRLB `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRLB {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Character Size\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum CHSIZE_A {
17    #[doc = "0: 8 Bits"]
18    _8_BIT = 0,
19    #[doc = "1: 9 Bits"]
20    _9_BIT = 1,
21    #[doc = "5: 5 Bits"]
22    _5_BIT = 5,
23    #[doc = "6: 6 Bits"]
24    _6_BIT = 6,
25    #[doc = "7: 7 Bits"]
26    _7_BIT = 7,
27}
28impl From<CHSIZE_A> for u8 {
29    #[inline(always)]
30    fn from(variant: CHSIZE_A) -> Self {
31        variant as _
32    }
33}
34#[doc = "Reader of field `CHSIZE`"]
35pub type CHSIZE_R = crate::R<u8, CHSIZE_A>;
36impl CHSIZE_R {
37    #[doc = r"Get enumerated values variant"]
38    #[inline(always)]
39    pub fn variant(&self) -> crate::Variant<u8, CHSIZE_A> {
40        use crate::Variant::*;
41        match self.bits {
42            0 => Val(CHSIZE_A::_8_BIT),
43            1 => Val(CHSIZE_A::_9_BIT),
44            5 => Val(CHSIZE_A::_5_BIT),
45            6 => Val(CHSIZE_A::_6_BIT),
46            7 => Val(CHSIZE_A::_7_BIT),
47            i => Res(i),
48        }
49    }
50    #[doc = "Checks if the value of the field is `_8_BIT`"]
51    #[inline(always)]
52    pub fn is_8_bit(&self) -> bool {
53        *self == CHSIZE_A::_8_BIT
54    }
55    #[doc = "Checks if the value of the field is `_9_BIT`"]
56    #[inline(always)]
57    pub fn is_9_bit(&self) -> bool {
58        *self == CHSIZE_A::_9_BIT
59    }
60    #[doc = "Checks if the value of the field is `_5_BIT`"]
61    #[inline(always)]
62    pub fn is_5_bit(&self) -> bool {
63        *self == CHSIZE_A::_5_BIT
64    }
65    #[doc = "Checks if the value of the field is `_6_BIT`"]
66    #[inline(always)]
67    pub fn is_6_bit(&self) -> bool {
68        *self == CHSIZE_A::_6_BIT
69    }
70    #[doc = "Checks if the value of the field is `_7_BIT`"]
71    #[inline(always)]
72    pub fn is_7_bit(&self) -> bool {
73        *self == CHSIZE_A::_7_BIT
74    }
75}
76#[doc = "Write proxy for field `CHSIZE`"]
77pub struct CHSIZE_W<'a> {
78    w: &'a mut W,
79}
80impl<'a> CHSIZE_W<'a> {
81    #[doc = r"Writes `variant` to the field"]
82    #[inline(always)]
83    pub fn variant(self, variant: CHSIZE_A) -> &'a mut W {
84        unsafe { self.bits(variant.into()) }
85    }
86    #[doc = "8 Bits"]
87    #[inline(always)]
88    pub fn _8_bit(self) -> &'a mut W {
89        self.variant(CHSIZE_A::_8_BIT)
90    }
91    #[doc = "9 Bits"]
92    #[inline(always)]
93    pub fn _9_bit(self) -> &'a mut W {
94        self.variant(CHSIZE_A::_9_BIT)
95    }
96    #[doc = "5 Bits"]
97    #[inline(always)]
98    pub fn _5_bit(self) -> &'a mut W {
99        self.variant(CHSIZE_A::_5_BIT)
100    }
101    #[doc = "6 Bits"]
102    #[inline(always)]
103    pub fn _6_bit(self) -> &'a mut W {
104        self.variant(CHSIZE_A::_6_BIT)
105    }
106    #[doc = "7 Bits"]
107    #[inline(always)]
108    pub fn _7_bit(self) -> &'a mut W {
109        self.variant(CHSIZE_A::_7_BIT)
110    }
111    #[doc = r"Writes raw bits to the field"]
112    #[inline(always)]
113    pub unsafe fn bits(self, value: u8) -> &'a mut W {
114        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
115        self.w
116    }
117}
118#[doc = "Stop Bit Mode\n\nValue on reset: 0"]
119#[derive(Clone, Copy, Debug, PartialEq)]
120pub enum SBMODE_A {
121    #[doc = "0: One Stop Bit"]
122    _1_BIT = 0,
123    #[doc = "1: Two Stop Bits"]
124    _2_BIT = 1,
125}
126impl From<SBMODE_A> for bool {
127    #[inline(always)]
128    fn from(variant: SBMODE_A) -> Self {
129        variant as u8 != 0
130    }
131}
132#[doc = "Reader of field `SBMODE`"]
133pub type SBMODE_R = crate::R<bool, SBMODE_A>;
134impl SBMODE_R {
135    #[doc = r"Get enumerated values variant"]
136    #[inline(always)]
137    pub fn variant(&self) -> SBMODE_A {
138        match self.bits {
139            false => SBMODE_A::_1_BIT,
140            true => SBMODE_A::_2_BIT,
141        }
142    }
143    #[doc = "Checks if the value of the field is `_1_BIT`"]
144    #[inline(always)]
145    pub fn is_1_bit(&self) -> bool {
146        *self == SBMODE_A::_1_BIT
147    }
148    #[doc = "Checks if the value of the field is `_2_BIT`"]
149    #[inline(always)]
150    pub fn is_2_bit(&self) -> bool {
151        *self == SBMODE_A::_2_BIT
152    }
153}
154#[doc = "Write proxy for field `SBMODE`"]
155pub struct SBMODE_W<'a> {
156    w: &'a mut W,
157}
158impl<'a> SBMODE_W<'a> {
159    #[doc = r"Writes `variant` to the field"]
160    #[inline(always)]
161    pub fn variant(self, variant: SBMODE_A) -> &'a mut W {
162        {
163            self.bit(variant.into())
164        }
165    }
166    #[doc = "One Stop Bit"]
167    #[inline(always)]
168    pub fn _1_bit(self) -> &'a mut W {
169        self.variant(SBMODE_A::_1_BIT)
170    }
171    #[doc = "Two Stop Bits"]
172    #[inline(always)]
173    pub fn _2_bit(self) -> &'a mut W {
174        self.variant(SBMODE_A::_2_BIT)
175    }
176    #[doc = r"Sets the field bit"]
177    #[inline(always)]
178    pub fn set_bit(self) -> &'a mut W {
179        self.bit(true)
180    }
181    #[doc = r"Clears the field bit"]
182    #[inline(always)]
183    pub fn clear_bit(self) -> &'a mut W {
184        self.bit(false)
185    }
186    #[doc = r"Writes raw bits to the field"]
187    #[inline(always)]
188    pub fn bit(self, value: bool) -> &'a mut W {
189        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
190        self.w
191    }
192}
193#[doc = "Reader of field `COLDEN`"]
194pub type COLDEN_R = crate::R<bool, bool>;
195#[doc = "Write proxy for field `COLDEN`"]
196pub struct COLDEN_W<'a> {
197    w: &'a mut W,
198}
199impl<'a> COLDEN_W<'a> {
200    #[doc = r"Sets the field bit"]
201    #[inline(always)]
202    pub fn set_bit(self) -> &'a mut W {
203        self.bit(true)
204    }
205    #[doc = r"Clears the field bit"]
206    #[inline(always)]
207    pub fn clear_bit(self) -> &'a mut W {
208        self.bit(false)
209    }
210    #[doc = r"Writes raw bits to the field"]
211    #[inline(always)]
212    pub fn bit(self, value: bool) -> &'a mut W {
213        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
214        self.w
215    }
216}
217#[doc = "Reader of field `SFDE`"]
218pub type SFDE_R = crate::R<bool, bool>;
219#[doc = "Write proxy for field `SFDE`"]
220pub struct SFDE_W<'a> {
221    w: &'a mut W,
222}
223impl<'a> SFDE_W<'a> {
224    #[doc = r"Sets the field bit"]
225    #[inline(always)]
226    pub fn set_bit(self) -> &'a mut W {
227        self.bit(true)
228    }
229    #[doc = r"Clears the field bit"]
230    #[inline(always)]
231    pub fn clear_bit(self) -> &'a mut W {
232        self.bit(false)
233    }
234    #[doc = r"Writes raw bits to the field"]
235    #[inline(always)]
236    pub fn bit(self, value: bool) -> &'a mut W {
237        self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
238        self.w
239    }
240}
241#[doc = "Reader of field `ENC`"]
242pub type ENC_R = crate::R<bool, bool>;
243#[doc = "Write proxy for field `ENC`"]
244pub struct ENC_W<'a> {
245    w: &'a mut W,
246}
247impl<'a> ENC_W<'a> {
248    #[doc = r"Sets the field bit"]
249    #[inline(always)]
250    pub fn set_bit(self) -> &'a mut W {
251        self.bit(true)
252    }
253    #[doc = r"Clears the field bit"]
254    #[inline(always)]
255    pub fn clear_bit(self) -> &'a mut W {
256        self.bit(false)
257    }
258    #[doc = r"Writes raw bits to the field"]
259    #[inline(always)]
260    pub fn bit(self, value: bool) -> &'a mut W {
261        self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
262        self.w
263    }
264}
265#[doc = "Parity Mode\n\nValue on reset: 0"]
266#[derive(Clone, Copy, Debug, PartialEq)]
267pub enum PMODE_A {
268    #[doc = "0: Even Parity"]
269    EVEN = 0,
270    #[doc = "1: Odd Parity"]
271    ODD = 1,
272}
273impl From<PMODE_A> for bool {
274    #[inline(always)]
275    fn from(variant: PMODE_A) -> Self {
276        variant as u8 != 0
277    }
278}
279#[doc = "Reader of field `PMODE`"]
280pub type PMODE_R = crate::R<bool, PMODE_A>;
281impl PMODE_R {
282    #[doc = r"Get enumerated values variant"]
283    #[inline(always)]
284    pub fn variant(&self) -> PMODE_A {
285        match self.bits {
286            false => PMODE_A::EVEN,
287            true => PMODE_A::ODD,
288        }
289    }
290    #[doc = "Checks if the value of the field is `EVEN`"]
291    #[inline(always)]
292    pub fn is_even(&self) -> bool {
293        *self == PMODE_A::EVEN
294    }
295    #[doc = "Checks if the value of the field is `ODD`"]
296    #[inline(always)]
297    pub fn is_odd(&self) -> bool {
298        *self == PMODE_A::ODD
299    }
300}
301#[doc = "Write proxy for field `PMODE`"]
302pub struct PMODE_W<'a> {
303    w: &'a mut W,
304}
305impl<'a> PMODE_W<'a> {
306    #[doc = r"Writes `variant` to the field"]
307    #[inline(always)]
308    pub fn variant(self, variant: PMODE_A) -> &'a mut W {
309        {
310            self.bit(variant.into())
311        }
312    }
313    #[doc = "Even Parity"]
314    #[inline(always)]
315    pub fn even(self) -> &'a mut W {
316        self.variant(PMODE_A::EVEN)
317    }
318    #[doc = "Odd Parity"]
319    #[inline(always)]
320    pub fn odd(self) -> &'a mut W {
321        self.variant(PMODE_A::ODD)
322    }
323    #[doc = r"Sets the field bit"]
324    #[inline(always)]
325    pub fn set_bit(self) -> &'a mut W {
326        self.bit(true)
327    }
328    #[doc = r"Clears the field bit"]
329    #[inline(always)]
330    pub fn clear_bit(self) -> &'a mut W {
331        self.bit(false)
332    }
333    #[doc = r"Writes raw bits to the field"]
334    #[inline(always)]
335    pub fn bit(self, value: bool) -> &'a mut W {
336        self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
337        self.w
338    }
339}
340#[doc = "Reader of field `TXEN`"]
341pub type TXEN_R = crate::R<bool, bool>;
342#[doc = "Write proxy for field `TXEN`"]
343pub struct TXEN_W<'a> {
344    w: &'a mut W,
345}
346impl<'a> TXEN_W<'a> {
347    #[doc = r"Sets the field bit"]
348    #[inline(always)]
349    pub fn set_bit(self) -> &'a mut W {
350        self.bit(true)
351    }
352    #[doc = r"Clears the field bit"]
353    #[inline(always)]
354    pub fn clear_bit(self) -> &'a mut W {
355        self.bit(false)
356    }
357    #[doc = r"Writes raw bits to the field"]
358    #[inline(always)]
359    pub fn bit(self, value: bool) -> &'a mut W {
360        self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
361        self.w
362    }
363}
364#[doc = "Reader of field `RXEN`"]
365pub type RXEN_R = crate::R<bool, bool>;
366#[doc = "Write proxy for field `RXEN`"]
367pub struct RXEN_W<'a> {
368    w: &'a mut W,
369}
370impl<'a> RXEN_W<'a> {
371    #[doc = r"Sets the field bit"]
372    #[inline(always)]
373    pub fn set_bit(self) -> &'a mut W {
374        self.bit(true)
375    }
376    #[doc = r"Clears the field bit"]
377    #[inline(always)]
378    pub fn clear_bit(self) -> &'a mut W {
379        self.bit(false)
380    }
381    #[doc = r"Writes raw bits to the field"]
382    #[inline(always)]
383    pub fn bit(self, value: bool) -> &'a mut W {
384        self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17);
385        self.w
386    }
387}
388#[doc = "Reader of field `LINCMD`"]
389pub type LINCMD_R = crate::R<u8, u8>;
390#[doc = "Write proxy for field `LINCMD`"]
391pub struct LINCMD_W<'a> {
392    w: &'a mut W,
393}
394impl<'a> LINCMD_W<'a> {
395    #[doc = r"Writes raw bits to the field"]
396    #[inline(always)]
397    pub unsafe fn bits(self, value: u8) -> &'a mut W {
398        self.w.bits = (self.w.bits & !(0x03 << 24)) | (((value as u32) & 0x03) << 24);
399        self.w
400    }
401}
402impl R {
403    #[doc = "Bits 0:2 - Character Size"]
404    #[inline(always)]
405    pub fn chsize(&self) -> CHSIZE_R {
406        CHSIZE_R::new((self.bits & 0x07) as u8)
407    }
408    #[doc = "Bit 6 - Stop Bit Mode"]
409    #[inline(always)]
410    pub fn sbmode(&self) -> SBMODE_R {
411        SBMODE_R::new(((self.bits >> 6) & 0x01) != 0)
412    }
413    #[doc = "Bit 8 - Collision Detection Enable"]
414    #[inline(always)]
415    pub fn colden(&self) -> COLDEN_R {
416        COLDEN_R::new(((self.bits >> 8) & 0x01) != 0)
417    }
418    #[doc = "Bit 9 - Start of Frame Detection Enable"]
419    #[inline(always)]
420    pub fn sfde(&self) -> SFDE_R {
421        SFDE_R::new(((self.bits >> 9) & 0x01) != 0)
422    }
423    #[doc = "Bit 10 - Encoding Format"]
424    #[inline(always)]
425    pub fn enc(&self) -> ENC_R {
426        ENC_R::new(((self.bits >> 10) & 0x01) != 0)
427    }
428    #[doc = "Bit 13 - Parity Mode"]
429    #[inline(always)]
430    pub fn pmode(&self) -> PMODE_R {
431        PMODE_R::new(((self.bits >> 13) & 0x01) != 0)
432    }
433    #[doc = "Bit 16 - Transmitter Enable"]
434    #[inline(always)]
435    pub fn txen(&self) -> TXEN_R {
436        TXEN_R::new(((self.bits >> 16) & 0x01) != 0)
437    }
438    #[doc = "Bit 17 - Receiver Enable"]
439    #[inline(always)]
440    pub fn rxen(&self) -> RXEN_R {
441        RXEN_R::new(((self.bits >> 17) & 0x01) != 0)
442    }
443    #[doc = "Bits 24:25 - LIN Command"]
444    #[inline(always)]
445    pub fn lincmd(&self) -> LINCMD_R {
446        LINCMD_R::new(((self.bits >> 24) & 0x03) as u8)
447    }
448}
449impl W {
450    #[doc = "Bits 0:2 - Character Size"]
451    #[inline(always)]
452    pub fn chsize(&mut self) -> CHSIZE_W {
453        CHSIZE_W { w: self }
454    }
455    #[doc = "Bit 6 - Stop Bit Mode"]
456    #[inline(always)]
457    pub fn sbmode(&mut self) -> SBMODE_W {
458        SBMODE_W { w: self }
459    }
460    #[doc = "Bit 8 - Collision Detection Enable"]
461    #[inline(always)]
462    pub fn colden(&mut self) -> COLDEN_W {
463        COLDEN_W { w: self }
464    }
465    #[doc = "Bit 9 - Start of Frame Detection Enable"]
466    #[inline(always)]
467    pub fn sfde(&mut self) -> SFDE_W {
468        SFDE_W { w: self }
469    }
470    #[doc = "Bit 10 - Encoding Format"]
471    #[inline(always)]
472    pub fn enc(&mut self) -> ENC_W {
473        ENC_W { w: self }
474    }
475    #[doc = "Bit 13 - Parity Mode"]
476    #[inline(always)]
477    pub fn pmode(&mut self) -> PMODE_W {
478        PMODE_W { w: self }
479    }
480    #[doc = "Bit 16 - Transmitter Enable"]
481    #[inline(always)]
482    pub fn txen(&mut self) -> TXEN_W {
483        TXEN_W { w: self }
484    }
485    #[doc = "Bit 17 - Receiver Enable"]
486    #[inline(always)]
487    pub fn rxen(&mut self) -> RXEN_W {
488        RXEN_W { w: self }
489    }
490    #[doc = "Bits 24:25 - LIN Command"]
491    #[inline(always)]
492    pub fn lincmd(&mut self) -> LINCMD_W {
493        LINCMD_W { w: self }
494    }
495}