avr_device/devices/atmega4809/usart2/
ctrlc.rs

1#[doc = "Register `CTRLC` reader"]
2pub struct R(crate::R<CTRLC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLC` writer"]
17pub struct W(crate::W<CTRLC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLC_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<CTRLC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `NORMAL_CHSIZE` reader - Character Size"]
38pub type NORMAL_CHSIZE_R = crate::FieldReader<u8, NORMAL_CHSIZE_A>;
39#[doc = "Character Size\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum NORMAL_CHSIZE_A {
43    #[doc = "0: Character size: 5 bit"]
44    _5BIT = 0,
45    #[doc = "1: Character size: 6 bit"]
46    _6BIT = 1,
47    #[doc = "2: Character size: 7 bit"]
48    _7BIT = 2,
49    #[doc = "3: Character size: 8 bit"]
50    _8BIT = 3,
51    #[doc = "6: Character size: 9 bit read low byte first"]
52    _9BITL = 6,
53    #[doc = "7: Character size: 9 bit read high byte first"]
54    _9BITH = 7,
55}
56impl From<NORMAL_CHSIZE_A> for u8 {
57    #[inline(always)]
58    fn from(variant: NORMAL_CHSIZE_A) -> Self {
59        variant as _
60    }
61}
62impl NORMAL_CHSIZE_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<NORMAL_CHSIZE_A> {
66        match self.bits {
67            0 => Some(NORMAL_CHSIZE_A::_5BIT),
68            1 => Some(NORMAL_CHSIZE_A::_6BIT),
69            2 => Some(NORMAL_CHSIZE_A::_7BIT),
70            3 => Some(NORMAL_CHSIZE_A::_8BIT),
71            6 => Some(NORMAL_CHSIZE_A::_9BITL),
72            7 => Some(NORMAL_CHSIZE_A::_9BITH),
73            _ => None,
74        }
75    }
76    #[doc = "Checks if the value of the field is `_5BIT`"]
77    #[inline(always)]
78    pub fn is_5bit(&self) -> bool {
79        *self == NORMAL_CHSIZE_A::_5BIT
80    }
81    #[doc = "Checks if the value of the field is `_6BIT`"]
82    #[inline(always)]
83    pub fn is_6bit(&self) -> bool {
84        *self == NORMAL_CHSIZE_A::_6BIT
85    }
86    #[doc = "Checks if the value of the field is `_7BIT`"]
87    #[inline(always)]
88    pub fn is_7bit(&self) -> bool {
89        *self == NORMAL_CHSIZE_A::_7BIT
90    }
91    #[doc = "Checks if the value of the field is `_8BIT`"]
92    #[inline(always)]
93    pub fn is_8bit(&self) -> bool {
94        *self == NORMAL_CHSIZE_A::_8BIT
95    }
96    #[doc = "Checks if the value of the field is `_9BITL`"]
97    #[inline(always)]
98    pub fn is_9bitl(&self) -> bool {
99        *self == NORMAL_CHSIZE_A::_9BITL
100    }
101    #[doc = "Checks if the value of the field is `_9BITH`"]
102    #[inline(always)]
103    pub fn is_9bith(&self) -> bool {
104        *self == NORMAL_CHSIZE_A::_9BITH
105    }
106}
107#[doc = "Field `NORMAL_CHSIZE` writer - Character Size"]
108pub type NORMAL_CHSIZE_W<'a, const O: u8> =
109    crate::FieldWriter<'a, u8, CTRLC_SPEC, u8, NORMAL_CHSIZE_A, 3, O>;
110impl<'a, const O: u8> NORMAL_CHSIZE_W<'a, O> {
111    #[doc = "Character size: 5 bit"]
112    #[inline(always)]
113    pub fn _5bit(self) -> &'a mut W {
114        self.variant(NORMAL_CHSIZE_A::_5BIT)
115    }
116    #[doc = "Character size: 6 bit"]
117    #[inline(always)]
118    pub fn _6bit(self) -> &'a mut W {
119        self.variant(NORMAL_CHSIZE_A::_6BIT)
120    }
121    #[doc = "Character size: 7 bit"]
122    #[inline(always)]
123    pub fn _7bit(self) -> &'a mut W {
124        self.variant(NORMAL_CHSIZE_A::_7BIT)
125    }
126    #[doc = "Character size: 8 bit"]
127    #[inline(always)]
128    pub fn _8bit(self) -> &'a mut W {
129        self.variant(NORMAL_CHSIZE_A::_8BIT)
130    }
131    #[doc = "Character size: 9 bit read low byte first"]
132    #[inline(always)]
133    pub fn _9bitl(self) -> &'a mut W {
134        self.variant(NORMAL_CHSIZE_A::_9BITL)
135    }
136    #[doc = "Character size: 9 bit read high byte first"]
137    #[inline(always)]
138    pub fn _9bith(self) -> &'a mut W {
139        self.variant(NORMAL_CHSIZE_A::_9BITH)
140    }
141}
142#[doc = "Field `MSPI_UCPHA` reader - SPI Master Mode, Clock Phase"]
143pub type MSPI_UCPHA_R = crate::BitReader<bool>;
144#[doc = "Field `MSPI_UCPHA` writer - SPI Master Mode, Clock Phase"]
145pub type MSPI_UCPHA_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLC_SPEC, bool, O>;
146#[doc = "Field `MSPI_UDORD` reader - SPI Master Mode, Data Order"]
147pub type MSPI_UDORD_R = crate::BitReader<bool>;
148#[doc = "Field `MSPI_UDORD` writer - SPI Master Mode, Data Order"]
149pub type MSPI_UDORD_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLC_SPEC, bool, O>;
150#[doc = "Field `NORMAL_SBMODE` reader - Stop Bit Mode"]
151pub type NORMAL_SBMODE_R = crate::BitReader<NORMAL_SBMODE_A>;
152#[doc = "Stop Bit Mode\n\nValue on reset: 0"]
153#[derive(Clone, Copy, Debug, PartialEq, Eq)]
154pub enum NORMAL_SBMODE_A {
155    #[doc = "0: 1 stop bit"]
156    _1BIT = 0,
157    #[doc = "1: 2 stop bits"]
158    _2BIT = 1,
159}
160impl From<NORMAL_SBMODE_A> for bool {
161    #[inline(always)]
162    fn from(variant: NORMAL_SBMODE_A) -> Self {
163        variant as u8 != 0
164    }
165}
166impl NORMAL_SBMODE_R {
167    #[doc = "Get enumerated values variant"]
168    #[inline(always)]
169    pub fn variant(&self) -> NORMAL_SBMODE_A {
170        match self.bits {
171            false => NORMAL_SBMODE_A::_1BIT,
172            true => NORMAL_SBMODE_A::_2BIT,
173        }
174    }
175    #[doc = "Checks if the value of the field is `_1BIT`"]
176    #[inline(always)]
177    pub fn is_1bit(&self) -> bool {
178        *self == NORMAL_SBMODE_A::_1BIT
179    }
180    #[doc = "Checks if the value of the field is `_2BIT`"]
181    #[inline(always)]
182    pub fn is_2bit(&self) -> bool {
183        *self == NORMAL_SBMODE_A::_2BIT
184    }
185}
186#[doc = "Field `NORMAL_SBMODE` writer - Stop Bit Mode"]
187pub type NORMAL_SBMODE_W<'a, const O: u8> =
188    crate::BitWriter<'a, u8, CTRLC_SPEC, NORMAL_SBMODE_A, O>;
189impl<'a, const O: u8> NORMAL_SBMODE_W<'a, O> {
190    #[doc = "1 stop bit"]
191    #[inline(always)]
192    pub fn _1bit(self) -> &'a mut W {
193        self.variant(NORMAL_SBMODE_A::_1BIT)
194    }
195    #[doc = "2 stop bits"]
196    #[inline(always)]
197    pub fn _2bit(self) -> &'a mut W {
198        self.variant(NORMAL_SBMODE_A::_2BIT)
199    }
200}
201#[doc = "Field `NORMAL_PMODE` reader - Parity Mode"]
202pub type NORMAL_PMODE_R = crate::FieldReader<u8, NORMAL_PMODE_A>;
203#[doc = "Parity Mode\n\nValue on reset: 0"]
204#[derive(Clone, Copy, Debug, PartialEq, Eq)]
205#[repr(u8)]
206pub enum NORMAL_PMODE_A {
207    #[doc = "0: No Parity"]
208    DISABLED = 0,
209    #[doc = "2: Even Parity"]
210    EVEN = 2,
211    #[doc = "3: Odd Parity"]
212    ODD = 3,
213}
214impl From<NORMAL_PMODE_A> for u8 {
215    #[inline(always)]
216    fn from(variant: NORMAL_PMODE_A) -> Self {
217        variant as _
218    }
219}
220impl NORMAL_PMODE_R {
221    #[doc = "Get enumerated values variant"]
222    #[inline(always)]
223    pub fn variant(&self) -> Option<NORMAL_PMODE_A> {
224        match self.bits {
225            0 => Some(NORMAL_PMODE_A::DISABLED),
226            2 => Some(NORMAL_PMODE_A::EVEN),
227            3 => Some(NORMAL_PMODE_A::ODD),
228            _ => None,
229        }
230    }
231    #[doc = "Checks if the value of the field is `DISABLED`"]
232    #[inline(always)]
233    pub fn is_disabled(&self) -> bool {
234        *self == NORMAL_PMODE_A::DISABLED
235    }
236    #[doc = "Checks if the value of the field is `EVEN`"]
237    #[inline(always)]
238    pub fn is_even(&self) -> bool {
239        *self == NORMAL_PMODE_A::EVEN
240    }
241    #[doc = "Checks if the value of the field is `ODD`"]
242    #[inline(always)]
243    pub fn is_odd(&self) -> bool {
244        *self == NORMAL_PMODE_A::ODD
245    }
246}
247#[doc = "Field `NORMAL_PMODE` writer - Parity Mode"]
248pub type NORMAL_PMODE_W<'a, const O: u8> =
249    crate::FieldWriter<'a, u8, CTRLC_SPEC, u8, NORMAL_PMODE_A, 2, O>;
250impl<'a, const O: u8> NORMAL_PMODE_W<'a, O> {
251    #[doc = "No Parity"]
252    #[inline(always)]
253    pub fn disabled(self) -> &'a mut W {
254        self.variant(NORMAL_PMODE_A::DISABLED)
255    }
256    #[doc = "Even Parity"]
257    #[inline(always)]
258    pub fn even(self) -> &'a mut W {
259        self.variant(NORMAL_PMODE_A::EVEN)
260    }
261    #[doc = "Odd Parity"]
262    #[inline(always)]
263    pub fn odd(self) -> &'a mut W {
264        self.variant(NORMAL_PMODE_A::ODD)
265    }
266}
267#[doc = "Field `MSPI_CMODE` reader - Communication Mode"]
268pub type MSPI_CMODE_R = crate::FieldReader<u8, MSPI_CMODE_A>;
269#[doc = "Communication Mode\n\nValue on reset: 0"]
270#[derive(Clone, Copy, Debug, PartialEq, Eq)]
271#[repr(u8)]
272pub enum MSPI_CMODE_A {
273    #[doc = "0: Asynchronous Mode"]
274    ASYNCHRONOUS = 0,
275    #[doc = "1: Synchronous Mode"]
276    SYNCHRONOUS = 1,
277    #[doc = "2: Infrared Communication"]
278    IRCOM = 2,
279    #[doc = "3: Master SPI Mode"]
280    MSPI = 3,
281}
282impl From<MSPI_CMODE_A> for u8 {
283    #[inline(always)]
284    fn from(variant: MSPI_CMODE_A) -> Self {
285        variant as _
286    }
287}
288impl MSPI_CMODE_R {
289    #[doc = "Get enumerated values variant"]
290    #[inline(always)]
291    pub fn variant(&self) -> MSPI_CMODE_A {
292        match self.bits {
293            0 => MSPI_CMODE_A::ASYNCHRONOUS,
294            1 => MSPI_CMODE_A::SYNCHRONOUS,
295            2 => MSPI_CMODE_A::IRCOM,
296            3 => MSPI_CMODE_A::MSPI,
297            _ => unreachable!(),
298        }
299    }
300    #[doc = "Checks if the value of the field is `ASYNCHRONOUS`"]
301    #[inline(always)]
302    pub fn is_asynchronous(&self) -> bool {
303        *self == MSPI_CMODE_A::ASYNCHRONOUS
304    }
305    #[doc = "Checks if the value of the field is `SYNCHRONOUS`"]
306    #[inline(always)]
307    pub fn is_synchronous(&self) -> bool {
308        *self == MSPI_CMODE_A::SYNCHRONOUS
309    }
310    #[doc = "Checks if the value of the field is `IRCOM`"]
311    #[inline(always)]
312    pub fn is_ircom(&self) -> bool {
313        *self == MSPI_CMODE_A::IRCOM
314    }
315    #[doc = "Checks if the value of the field is `MSPI`"]
316    #[inline(always)]
317    pub fn is_mspi(&self) -> bool {
318        *self == MSPI_CMODE_A::MSPI
319    }
320}
321#[doc = "Field `MSPI_CMODE` writer - Communication Mode"]
322pub type MSPI_CMODE_W<'a, const O: u8> =
323    crate::FieldWriterSafe<'a, u8, CTRLC_SPEC, u8, MSPI_CMODE_A, 2, O>;
324impl<'a, const O: u8> MSPI_CMODE_W<'a, O> {
325    #[doc = "Asynchronous Mode"]
326    #[inline(always)]
327    pub fn asynchronous(self) -> &'a mut W {
328        self.variant(MSPI_CMODE_A::ASYNCHRONOUS)
329    }
330    #[doc = "Synchronous Mode"]
331    #[inline(always)]
332    pub fn synchronous(self) -> &'a mut W {
333        self.variant(MSPI_CMODE_A::SYNCHRONOUS)
334    }
335    #[doc = "Infrared Communication"]
336    #[inline(always)]
337    pub fn ircom(self) -> &'a mut W {
338        self.variant(MSPI_CMODE_A::IRCOM)
339    }
340    #[doc = "Master SPI Mode"]
341    #[inline(always)]
342    pub fn mspi(self) -> &'a mut W {
343        self.variant(MSPI_CMODE_A::MSPI)
344    }
345}
346#[doc = "Field `NORMAL_CMODE` reader - Communication Mode"]
347pub type NORMAL_CMODE_R = crate::FieldReader<u8, NORMAL_CMODE_A>;
348#[doc = "Communication Mode\n\nValue on reset: 0"]
349#[derive(Clone, Copy, Debug, PartialEq, Eq)]
350#[repr(u8)]
351pub enum NORMAL_CMODE_A {
352    #[doc = "0: Asynchronous Mode"]
353    ASYNCHRONOUS = 0,
354    #[doc = "1: Synchronous Mode"]
355    SYNCHRONOUS = 1,
356    #[doc = "2: Infrared Communication"]
357    IRCOM = 2,
358    #[doc = "3: Master SPI Mode"]
359    MSPI = 3,
360}
361impl From<NORMAL_CMODE_A> for u8 {
362    #[inline(always)]
363    fn from(variant: NORMAL_CMODE_A) -> Self {
364        variant as _
365    }
366}
367impl NORMAL_CMODE_R {
368    #[doc = "Get enumerated values variant"]
369    #[inline(always)]
370    pub fn variant(&self) -> NORMAL_CMODE_A {
371        match self.bits {
372            0 => NORMAL_CMODE_A::ASYNCHRONOUS,
373            1 => NORMAL_CMODE_A::SYNCHRONOUS,
374            2 => NORMAL_CMODE_A::IRCOM,
375            3 => NORMAL_CMODE_A::MSPI,
376            _ => unreachable!(),
377        }
378    }
379    #[doc = "Checks if the value of the field is `ASYNCHRONOUS`"]
380    #[inline(always)]
381    pub fn is_asynchronous(&self) -> bool {
382        *self == NORMAL_CMODE_A::ASYNCHRONOUS
383    }
384    #[doc = "Checks if the value of the field is `SYNCHRONOUS`"]
385    #[inline(always)]
386    pub fn is_synchronous(&self) -> bool {
387        *self == NORMAL_CMODE_A::SYNCHRONOUS
388    }
389    #[doc = "Checks if the value of the field is `IRCOM`"]
390    #[inline(always)]
391    pub fn is_ircom(&self) -> bool {
392        *self == NORMAL_CMODE_A::IRCOM
393    }
394    #[doc = "Checks if the value of the field is `MSPI`"]
395    #[inline(always)]
396    pub fn is_mspi(&self) -> bool {
397        *self == NORMAL_CMODE_A::MSPI
398    }
399}
400#[doc = "Field `NORMAL_CMODE` writer - Communication Mode"]
401pub type NORMAL_CMODE_W<'a, const O: u8> =
402    crate::FieldWriterSafe<'a, u8, CTRLC_SPEC, u8, NORMAL_CMODE_A, 2, O>;
403impl<'a, const O: u8> NORMAL_CMODE_W<'a, O> {
404    #[doc = "Asynchronous Mode"]
405    #[inline(always)]
406    pub fn asynchronous(self) -> &'a mut W {
407        self.variant(NORMAL_CMODE_A::ASYNCHRONOUS)
408    }
409    #[doc = "Synchronous Mode"]
410    #[inline(always)]
411    pub fn synchronous(self) -> &'a mut W {
412        self.variant(NORMAL_CMODE_A::SYNCHRONOUS)
413    }
414    #[doc = "Infrared Communication"]
415    #[inline(always)]
416    pub fn ircom(self) -> &'a mut W {
417        self.variant(NORMAL_CMODE_A::IRCOM)
418    }
419    #[doc = "Master SPI Mode"]
420    #[inline(always)]
421    pub fn mspi(self) -> &'a mut W {
422        self.variant(NORMAL_CMODE_A::MSPI)
423    }
424}
425impl R {
426    #[doc = "Bits 0:2 - Character Size"]
427    #[inline(always)]
428    pub fn normal_chsize(&self) -> NORMAL_CHSIZE_R {
429        NORMAL_CHSIZE_R::new(self.bits & 7)
430    }
431    #[doc = "Bit 1 - SPI Master Mode, Clock Phase"]
432    #[inline(always)]
433    pub fn mspi_ucpha(&self) -> MSPI_UCPHA_R {
434        MSPI_UCPHA_R::new(((self.bits >> 1) & 1) != 0)
435    }
436    #[doc = "Bit 2 - SPI Master Mode, Data Order"]
437    #[inline(always)]
438    pub fn mspi_udord(&self) -> MSPI_UDORD_R {
439        MSPI_UDORD_R::new(((self.bits >> 2) & 1) != 0)
440    }
441    #[doc = "Bit 3 - Stop Bit Mode"]
442    #[inline(always)]
443    pub fn normal_sbmode(&self) -> NORMAL_SBMODE_R {
444        NORMAL_SBMODE_R::new(((self.bits >> 3) & 1) != 0)
445    }
446    #[doc = "Bits 4:5 - Parity Mode"]
447    #[inline(always)]
448    pub fn normal_pmode(&self) -> NORMAL_PMODE_R {
449        NORMAL_PMODE_R::new((self.bits >> 4) & 3)
450    }
451    #[doc = "Bits 6:7 - Communication Mode"]
452    #[inline(always)]
453    pub fn mspi_cmode(&self) -> MSPI_CMODE_R {
454        MSPI_CMODE_R::new((self.bits >> 6) & 3)
455    }
456    #[doc = "Bits 6:7 - Communication Mode"]
457    #[inline(always)]
458    pub fn normal_cmode(&self) -> NORMAL_CMODE_R {
459        NORMAL_CMODE_R::new((self.bits >> 6) & 3)
460    }
461}
462impl W {
463    #[doc = "Bits 0:2 - Character Size"]
464    #[inline(always)]
465    #[must_use]
466    pub fn normal_chsize(&mut self) -> NORMAL_CHSIZE_W<0> {
467        NORMAL_CHSIZE_W::new(self)
468    }
469    #[doc = "Bit 1 - SPI Master Mode, Clock Phase"]
470    #[inline(always)]
471    #[must_use]
472    pub fn mspi_ucpha(&mut self) -> MSPI_UCPHA_W<1> {
473        MSPI_UCPHA_W::new(self)
474    }
475    #[doc = "Bit 2 - SPI Master Mode, Data Order"]
476    #[inline(always)]
477    #[must_use]
478    pub fn mspi_udord(&mut self) -> MSPI_UDORD_W<2> {
479        MSPI_UDORD_W::new(self)
480    }
481    #[doc = "Bit 3 - Stop Bit Mode"]
482    #[inline(always)]
483    #[must_use]
484    pub fn normal_sbmode(&mut self) -> NORMAL_SBMODE_W<3> {
485        NORMAL_SBMODE_W::new(self)
486    }
487    #[doc = "Bits 4:5 - Parity Mode"]
488    #[inline(always)]
489    #[must_use]
490    pub fn normal_pmode(&mut self) -> NORMAL_PMODE_W<4> {
491        NORMAL_PMODE_W::new(self)
492    }
493    #[doc = "Bits 6:7 - Communication Mode"]
494    #[inline(always)]
495    #[must_use]
496    pub fn mspi_cmode(&mut self) -> MSPI_CMODE_W<6> {
497        MSPI_CMODE_W::new(self)
498    }
499    #[doc = "Bits 6:7 - Communication Mode"]
500    #[inline(always)]
501    #[must_use]
502    pub fn normal_cmode(&mut self) -> NORMAL_CMODE_W<6> {
503        NORMAL_CMODE_W::new(self)
504    }
505    #[doc = "Writes raw bits to the register."]
506    #[inline(always)]
507    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
508        self.0.bits(bits);
509        self
510    }
511}
512#[doc = "Control C\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 [ctrlc](index.html) module"]
513pub struct CTRLC_SPEC;
514impl crate::RegisterSpec for CTRLC_SPEC {
515    type Ux = u8;
516}
517#[doc = "`read()` method returns [ctrlc::R](R) reader structure"]
518impl crate::Readable for CTRLC_SPEC {
519    type Reader = R;
520}
521#[doc = "`write(|w| ..)` method takes [ctrlc::W](W) writer structure"]
522impl crate::Writable for CTRLC_SPEC {
523    type Writer = W;
524    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
525    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
526}
527#[doc = "`reset()` method sets CTRLC to value 0"]
528impl crate::Resettable for CTRLC_SPEC {
529    const RESET_VALUE: Self::Ux = 0;
530}