atsam3s8c/usart1/
man.rs

1#[doc = "Register `MAN` reader"]
2pub type R = crate::R<ManSpec>;
3#[doc = "Register `MAN` writer"]
4pub type W = crate::W<ManSpec>;
5#[doc = "Field `TX_PL` reader - Transmitter Preamble Length"]
6pub type TxPlR = crate::FieldReader;
7#[doc = "Field `TX_PL` writer - Transmitter Preamble Length"]
8pub type TxPlW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
9#[doc = "Transmitter Preamble Pattern\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum TxPp {
13    #[doc = "0: The preamble is composed of '1's"]
14    AllOne = 0,
15    #[doc = "1: The preamble is composed of '0's"]
16    AllZero = 1,
17    #[doc = "2: The preamble is composed of '01's"]
18    ZeroOne = 2,
19    #[doc = "3: The preamble is composed of '10's"]
20    OneZero = 3,
21}
22impl From<TxPp> for u8 {
23    #[inline(always)]
24    fn from(variant: TxPp) -> Self {
25        variant as _
26    }
27}
28impl crate::FieldSpec for TxPp {
29    type Ux = u8;
30}
31impl crate::IsEnum for TxPp {}
32#[doc = "Field `TX_PP` reader - Transmitter Preamble Pattern"]
33pub type TxPpR = crate::FieldReader<TxPp>;
34impl TxPpR {
35    #[doc = "Get enumerated values variant"]
36    #[inline(always)]
37    pub const fn variant(&self) -> TxPp {
38        match self.bits {
39            0 => TxPp::AllOne,
40            1 => TxPp::AllZero,
41            2 => TxPp::ZeroOne,
42            3 => TxPp::OneZero,
43            _ => unreachable!(),
44        }
45    }
46    #[doc = "The preamble is composed of '1's"]
47    #[inline(always)]
48    pub fn is_all_one(&self) -> bool {
49        *self == TxPp::AllOne
50    }
51    #[doc = "The preamble is composed of '0's"]
52    #[inline(always)]
53    pub fn is_all_zero(&self) -> bool {
54        *self == TxPp::AllZero
55    }
56    #[doc = "The preamble is composed of '01's"]
57    #[inline(always)]
58    pub fn is_zero_one(&self) -> bool {
59        *self == TxPp::ZeroOne
60    }
61    #[doc = "The preamble is composed of '10's"]
62    #[inline(always)]
63    pub fn is_one_zero(&self) -> bool {
64        *self == TxPp::OneZero
65    }
66}
67#[doc = "Field `TX_PP` writer - Transmitter Preamble Pattern"]
68pub type TxPpW<'a, REG> = crate::FieldWriter<'a, REG, 2, TxPp, crate::Safe>;
69impl<'a, REG> TxPpW<'a, REG>
70where
71    REG: crate::Writable + crate::RegisterSpec,
72    REG::Ux: From<u8>,
73{
74    #[doc = "The preamble is composed of '1's"]
75    #[inline(always)]
76    pub fn all_one(self) -> &'a mut crate::W<REG> {
77        self.variant(TxPp::AllOne)
78    }
79    #[doc = "The preamble is composed of '0's"]
80    #[inline(always)]
81    pub fn all_zero(self) -> &'a mut crate::W<REG> {
82        self.variant(TxPp::AllZero)
83    }
84    #[doc = "The preamble is composed of '01's"]
85    #[inline(always)]
86    pub fn zero_one(self) -> &'a mut crate::W<REG> {
87        self.variant(TxPp::ZeroOne)
88    }
89    #[doc = "The preamble is composed of '10's"]
90    #[inline(always)]
91    pub fn one_zero(self) -> &'a mut crate::W<REG> {
92        self.variant(TxPp::OneZero)
93    }
94}
95#[doc = "Field `TX_MPOL` reader - Transmitter Manchester Polarity"]
96pub type TxMpolR = crate::BitReader;
97#[doc = "Field `TX_MPOL` writer - Transmitter Manchester Polarity"]
98pub type TxMpolW<'a, REG> = crate::BitWriter<'a, REG>;
99#[doc = "Field `RX_PL` reader - Receiver Preamble Length"]
100pub type RxPlR = crate::FieldReader;
101#[doc = "Field `RX_PL` writer - Receiver Preamble Length"]
102pub type RxPlW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
103#[doc = "Receiver Preamble Pattern detected\n\nValue on reset: 0"]
104#[derive(Clone, Copy, Debug, PartialEq, Eq)]
105#[repr(u8)]
106pub enum RxPp {
107    #[doc = "0: The preamble is composed of '1's"]
108    AllOne = 0,
109    #[doc = "1: The preamble is composed of '0's"]
110    AllZero = 1,
111    #[doc = "2: The preamble is composed of '01's"]
112    ZeroOne = 2,
113    #[doc = "3: The preamble is composed of '10's"]
114    OneZero = 3,
115}
116impl From<RxPp> for u8 {
117    #[inline(always)]
118    fn from(variant: RxPp) -> Self {
119        variant as _
120    }
121}
122impl crate::FieldSpec for RxPp {
123    type Ux = u8;
124}
125impl crate::IsEnum for RxPp {}
126#[doc = "Field `RX_PP` reader - Receiver Preamble Pattern detected"]
127pub type RxPpR = crate::FieldReader<RxPp>;
128impl RxPpR {
129    #[doc = "Get enumerated values variant"]
130    #[inline(always)]
131    pub const fn variant(&self) -> RxPp {
132        match self.bits {
133            0 => RxPp::AllOne,
134            1 => RxPp::AllZero,
135            2 => RxPp::ZeroOne,
136            3 => RxPp::OneZero,
137            _ => unreachable!(),
138        }
139    }
140    #[doc = "The preamble is composed of '1's"]
141    #[inline(always)]
142    pub fn is_all_one(&self) -> bool {
143        *self == RxPp::AllOne
144    }
145    #[doc = "The preamble is composed of '0's"]
146    #[inline(always)]
147    pub fn is_all_zero(&self) -> bool {
148        *self == RxPp::AllZero
149    }
150    #[doc = "The preamble is composed of '01's"]
151    #[inline(always)]
152    pub fn is_zero_one(&self) -> bool {
153        *self == RxPp::ZeroOne
154    }
155    #[doc = "The preamble is composed of '10's"]
156    #[inline(always)]
157    pub fn is_one_zero(&self) -> bool {
158        *self == RxPp::OneZero
159    }
160}
161#[doc = "Field `RX_PP` writer - Receiver Preamble Pattern detected"]
162pub type RxPpW<'a, REG> = crate::FieldWriter<'a, REG, 2, RxPp, crate::Safe>;
163impl<'a, REG> RxPpW<'a, REG>
164where
165    REG: crate::Writable + crate::RegisterSpec,
166    REG::Ux: From<u8>,
167{
168    #[doc = "The preamble is composed of '1's"]
169    #[inline(always)]
170    pub fn all_one(self) -> &'a mut crate::W<REG> {
171        self.variant(RxPp::AllOne)
172    }
173    #[doc = "The preamble is composed of '0's"]
174    #[inline(always)]
175    pub fn all_zero(self) -> &'a mut crate::W<REG> {
176        self.variant(RxPp::AllZero)
177    }
178    #[doc = "The preamble is composed of '01's"]
179    #[inline(always)]
180    pub fn zero_one(self) -> &'a mut crate::W<REG> {
181        self.variant(RxPp::ZeroOne)
182    }
183    #[doc = "The preamble is composed of '10's"]
184    #[inline(always)]
185    pub fn one_zero(self) -> &'a mut crate::W<REG> {
186        self.variant(RxPp::OneZero)
187    }
188}
189#[doc = "Field `RX_MPOL` reader - Receiver Manchester Polarity"]
190pub type RxMpolR = crate::BitReader;
191#[doc = "Field `RX_MPOL` writer - Receiver Manchester Polarity"]
192pub type RxMpolW<'a, REG> = crate::BitWriter<'a, REG>;
193#[doc = "Field `ONE` reader - Must Be Set to 1"]
194pub type OneR = crate::BitReader;
195#[doc = "Field `ONE` writer - Must Be Set to 1"]
196pub type OneW<'a, REG> = crate::BitWriter<'a, REG>;
197#[doc = "Field `DRIFT` reader - Drift compensation"]
198pub type DriftR = crate::BitReader;
199#[doc = "Field `DRIFT` writer - Drift compensation"]
200pub type DriftW<'a, REG> = crate::BitWriter<'a, REG>;
201impl R {
202    #[doc = "Bits 0:3 - Transmitter Preamble Length"]
203    #[inline(always)]
204    pub fn tx_pl(&self) -> TxPlR {
205        TxPlR::new((self.bits & 0x0f) as u8)
206    }
207    #[doc = "Bits 8:9 - Transmitter Preamble Pattern"]
208    #[inline(always)]
209    pub fn tx_pp(&self) -> TxPpR {
210        TxPpR::new(((self.bits >> 8) & 3) as u8)
211    }
212    #[doc = "Bit 12 - Transmitter Manchester Polarity"]
213    #[inline(always)]
214    pub fn tx_mpol(&self) -> TxMpolR {
215        TxMpolR::new(((self.bits >> 12) & 1) != 0)
216    }
217    #[doc = "Bits 16:19 - Receiver Preamble Length"]
218    #[inline(always)]
219    pub fn rx_pl(&self) -> RxPlR {
220        RxPlR::new(((self.bits >> 16) & 0x0f) as u8)
221    }
222    #[doc = "Bits 24:25 - Receiver Preamble Pattern detected"]
223    #[inline(always)]
224    pub fn rx_pp(&self) -> RxPpR {
225        RxPpR::new(((self.bits >> 24) & 3) as u8)
226    }
227    #[doc = "Bit 28 - Receiver Manchester Polarity"]
228    #[inline(always)]
229    pub fn rx_mpol(&self) -> RxMpolR {
230        RxMpolR::new(((self.bits >> 28) & 1) != 0)
231    }
232    #[doc = "Bit 29 - Must Be Set to 1"]
233    #[inline(always)]
234    pub fn one(&self) -> OneR {
235        OneR::new(((self.bits >> 29) & 1) != 0)
236    }
237    #[doc = "Bit 30 - Drift compensation"]
238    #[inline(always)]
239    pub fn drift(&self) -> DriftR {
240        DriftR::new(((self.bits >> 30) & 1) != 0)
241    }
242}
243impl W {
244    #[doc = "Bits 0:3 - Transmitter Preamble Length"]
245    #[inline(always)]
246    #[must_use]
247    pub fn tx_pl(&mut self) -> TxPlW<ManSpec> {
248        TxPlW::new(self, 0)
249    }
250    #[doc = "Bits 8:9 - Transmitter Preamble Pattern"]
251    #[inline(always)]
252    #[must_use]
253    pub fn tx_pp(&mut self) -> TxPpW<ManSpec> {
254        TxPpW::new(self, 8)
255    }
256    #[doc = "Bit 12 - Transmitter Manchester Polarity"]
257    #[inline(always)]
258    #[must_use]
259    pub fn tx_mpol(&mut self) -> TxMpolW<ManSpec> {
260        TxMpolW::new(self, 12)
261    }
262    #[doc = "Bits 16:19 - Receiver Preamble Length"]
263    #[inline(always)]
264    #[must_use]
265    pub fn rx_pl(&mut self) -> RxPlW<ManSpec> {
266        RxPlW::new(self, 16)
267    }
268    #[doc = "Bits 24:25 - Receiver Preamble Pattern detected"]
269    #[inline(always)]
270    #[must_use]
271    pub fn rx_pp(&mut self) -> RxPpW<ManSpec> {
272        RxPpW::new(self, 24)
273    }
274    #[doc = "Bit 28 - Receiver Manchester Polarity"]
275    #[inline(always)]
276    #[must_use]
277    pub fn rx_mpol(&mut self) -> RxMpolW<ManSpec> {
278        RxMpolW::new(self, 28)
279    }
280    #[doc = "Bit 29 - Must Be Set to 1"]
281    #[inline(always)]
282    #[must_use]
283    pub fn one(&mut self) -> OneW<ManSpec> {
284        OneW::new(self, 29)
285    }
286    #[doc = "Bit 30 - Drift compensation"]
287    #[inline(always)]
288    #[must_use]
289    pub fn drift(&mut self) -> DriftW<ManSpec> {
290        DriftW::new(self, 30)
291    }
292}
293#[doc = "Manchester Encoder Decoder Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`man::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`man::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
294pub struct ManSpec;
295impl crate::RegisterSpec for ManSpec {
296    type Ux = u32;
297}
298#[doc = "`read()` method returns [`man::R`](R) reader structure"]
299impl crate::Readable for ManSpec {}
300#[doc = "`write(|w| ..)` method takes [`man::W`](W) writer structure"]
301impl crate::Writable for ManSpec {
302    type Safety = crate::Unsafe;
303    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
304    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
305}
306#[doc = "`reset()` method sets MAN to value 0xb001_1004"]
307impl crate::Resettable for ManSpec {
308    const RESET_VALUE: u32 = 0xb001_1004;
309}