atsam4s16c_pac/uart1/
mr.rs

1#[doc = "Register `MR` reader"]
2pub struct R(crate::R<MR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<MR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<MR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<MR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `MR` writer"]
17pub struct W(crate::W<MR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<MR_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<MR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<MR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PAR` reader - Parity Type"]
38pub type PAR_R = crate::FieldReader<u8, PAR_A>;
39#[doc = "Parity Type\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum PAR_A {
43    #[doc = "0: Even Parity"]
44    EVEN = 0,
45    #[doc = "1: Odd Parity"]
46    ODD = 1,
47    #[doc = "2: Space: parity forced to 0"]
48    SPACE = 2,
49    #[doc = "3: Mark: parity forced to 1"]
50    MARK = 3,
51    #[doc = "4: No parity"]
52    NO = 4,
53}
54impl From<PAR_A> for u8 {
55    #[inline(always)]
56    fn from(variant: PAR_A) -> Self {
57        variant as _
58    }
59}
60impl PAR_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<PAR_A> {
64        match self.bits {
65            0 => Some(PAR_A::EVEN),
66            1 => Some(PAR_A::ODD),
67            2 => Some(PAR_A::SPACE),
68            3 => Some(PAR_A::MARK),
69            4 => Some(PAR_A::NO),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `EVEN`"]
74    #[inline(always)]
75    pub fn is_even(&self) -> bool {
76        *self == PAR_A::EVEN
77    }
78    #[doc = "Checks if the value of the field is `ODD`"]
79    #[inline(always)]
80    pub fn is_odd(&self) -> bool {
81        *self == PAR_A::ODD
82    }
83    #[doc = "Checks if the value of the field is `SPACE`"]
84    #[inline(always)]
85    pub fn is_space(&self) -> bool {
86        *self == PAR_A::SPACE
87    }
88    #[doc = "Checks if the value of the field is `MARK`"]
89    #[inline(always)]
90    pub fn is_mark(&self) -> bool {
91        *self == PAR_A::MARK
92    }
93    #[doc = "Checks if the value of the field is `NO`"]
94    #[inline(always)]
95    pub fn is_no(&self) -> bool {
96        *self == PAR_A::NO
97    }
98}
99#[doc = "Field `PAR` writer - Parity Type"]
100pub type PAR_W<'a, const O: u8> = crate::FieldWriter<'a, u32, MR_SPEC, u8, PAR_A, 3, O>;
101impl<'a, const O: u8> PAR_W<'a, O> {
102    #[doc = "Even Parity"]
103    #[inline(always)]
104    pub fn even(self) -> &'a mut W {
105        self.variant(PAR_A::EVEN)
106    }
107    #[doc = "Odd Parity"]
108    #[inline(always)]
109    pub fn odd(self) -> &'a mut W {
110        self.variant(PAR_A::ODD)
111    }
112    #[doc = "Space: parity forced to 0"]
113    #[inline(always)]
114    pub fn space(self) -> &'a mut W {
115        self.variant(PAR_A::SPACE)
116    }
117    #[doc = "Mark: parity forced to 1"]
118    #[inline(always)]
119    pub fn mark(self) -> &'a mut W {
120        self.variant(PAR_A::MARK)
121    }
122    #[doc = "No parity"]
123    #[inline(always)]
124    pub fn no(self) -> &'a mut W {
125        self.variant(PAR_A::NO)
126    }
127}
128#[doc = "Field `CHMODE` reader - Channel Mode"]
129pub type CHMODE_R = crate::FieldReader<u8, CHMODE_A>;
130#[doc = "Channel Mode\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132#[repr(u8)]
133pub enum CHMODE_A {
134    #[doc = "0: Normal mode"]
135    NORMAL = 0,
136    #[doc = "1: Automatic echo"]
137    AUTOMATIC = 1,
138    #[doc = "2: Local loopback"]
139    LOCAL_LOOPBACK = 2,
140    #[doc = "3: Remote loopback"]
141    REMOTE_LOOPBACK = 3,
142}
143impl From<CHMODE_A> for u8 {
144    #[inline(always)]
145    fn from(variant: CHMODE_A) -> Self {
146        variant as _
147    }
148}
149impl CHMODE_R {
150    #[doc = "Get enumerated values variant"]
151    #[inline(always)]
152    pub fn variant(&self) -> CHMODE_A {
153        match self.bits {
154            0 => CHMODE_A::NORMAL,
155            1 => CHMODE_A::AUTOMATIC,
156            2 => CHMODE_A::LOCAL_LOOPBACK,
157            3 => CHMODE_A::REMOTE_LOOPBACK,
158            _ => unreachable!(),
159        }
160    }
161    #[doc = "Checks if the value of the field is `NORMAL`"]
162    #[inline(always)]
163    pub fn is_normal(&self) -> bool {
164        *self == CHMODE_A::NORMAL
165    }
166    #[doc = "Checks if the value of the field is `AUTOMATIC`"]
167    #[inline(always)]
168    pub fn is_automatic(&self) -> bool {
169        *self == CHMODE_A::AUTOMATIC
170    }
171    #[doc = "Checks if the value of the field is `LOCAL_LOOPBACK`"]
172    #[inline(always)]
173    pub fn is_local_loopback(&self) -> bool {
174        *self == CHMODE_A::LOCAL_LOOPBACK
175    }
176    #[doc = "Checks if the value of the field is `REMOTE_LOOPBACK`"]
177    #[inline(always)]
178    pub fn is_remote_loopback(&self) -> bool {
179        *self == CHMODE_A::REMOTE_LOOPBACK
180    }
181}
182#[doc = "Field `CHMODE` writer - Channel Mode"]
183pub type CHMODE_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, MR_SPEC, u8, CHMODE_A, 2, O>;
184impl<'a, const O: u8> CHMODE_W<'a, O> {
185    #[doc = "Normal mode"]
186    #[inline(always)]
187    pub fn normal(self) -> &'a mut W {
188        self.variant(CHMODE_A::NORMAL)
189    }
190    #[doc = "Automatic echo"]
191    #[inline(always)]
192    pub fn automatic(self) -> &'a mut W {
193        self.variant(CHMODE_A::AUTOMATIC)
194    }
195    #[doc = "Local loopback"]
196    #[inline(always)]
197    pub fn local_loopback(self) -> &'a mut W {
198        self.variant(CHMODE_A::LOCAL_LOOPBACK)
199    }
200    #[doc = "Remote loopback"]
201    #[inline(always)]
202    pub fn remote_loopback(self) -> &'a mut W {
203        self.variant(CHMODE_A::REMOTE_LOOPBACK)
204    }
205}
206impl R {
207    #[doc = "Bits 9:11 - Parity Type"]
208    #[inline(always)]
209    pub fn par(&self) -> PAR_R {
210        PAR_R::new(((self.bits >> 9) & 7) as u8)
211    }
212    #[doc = "Bits 14:15 - Channel Mode"]
213    #[inline(always)]
214    pub fn chmode(&self) -> CHMODE_R {
215        CHMODE_R::new(((self.bits >> 14) & 3) as u8)
216    }
217}
218impl W {
219    #[doc = "Bits 9:11 - Parity Type"]
220    #[inline(always)]
221    #[must_use]
222    pub fn par(&mut self) -> PAR_W<9> {
223        PAR_W::new(self)
224    }
225    #[doc = "Bits 14:15 - Channel Mode"]
226    #[inline(always)]
227    #[must_use]
228    pub fn chmode(&mut self) -> CHMODE_W<14> {
229        CHMODE_W::new(self)
230    }
231    #[doc = "Writes raw bits to the register."]
232    #[inline(always)]
233    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
234        self.0.bits(bits);
235        self
236    }
237}
238#[doc = "Mode 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 [mr](index.html) module"]
239pub struct MR_SPEC;
240impl crate::RegisterSpec for MR_SPEC {
241    type Ux = u32;
242}
243#[doc = "`read()` method returns [mr::R](R) reader structure"]
244impl crate::Readable for MR_SPEC {
245    type Reader = R;
246}
247#[doc = "`write(|w| ..)` method takes [mr::W](W) writer structure"]
248impl crate::Writable for MR_SPEC {
249    type Writer = W;
250    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
251    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
252}
253#[doc = "`reset()` method sets MR to value 0"]
254impl crate::Resettable for MR_SPEC {
255    const RESET_VALUE: Self::Ux = 0;
256}