k22f/uart2/
pfifo.rs

1#[doc = "Reader of register PFIFO"]
2pub type R = crate::R<u8, super::PFIFO>;
3#[doc = "Writer for register PFIFO"]
4pub type W = crate::W<u8, super::PFIFO>;
5#[doc = "Register PFIFO `reset()`'s with value 0"]
6impl crate::ResetValue for super::PFIFO {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Receive FIFO. Buffer Depth\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum RXFIFOSIZE_A {
17    #[doc = "0: Receive FIFO/Buffer depth = 1 dataword."]
18    _000 = 0,
19    #[doc = "1: Receive FIFO/Buffer depth = 4 datawords."]
20    _001 = 1,
21    #[doc = "2: Receive FIFO/Buffer depth = 8 datawords."]
22    _010 = 2,
23    #[doc = "3: Receive FIFO/Buffer depth = 16 datawords."]
24    _011 = 3,
25    #[doc = "4: Receive FIFO/Buffer depth = 32 datawords."]
26    _100 = 4,
27    #[doc = "5: Receive FIFO/Buffer depth = 64 datawords."]
28    _101 = 5,
29    #[doc = "6: Receive FIFO/Buffer depth = 128 datawords."]
30    _110 = 6,
31}
32impl From<RXFIFOSIZE_A> for u8 {
33    #[inline(always)]
34    fn from(variant: RXFIFOSIZE_A) -> Self {
35        variant as _
36    }
37}
38#[doc = "Reader of field `RXFIFOSIZE`"]
39pub type RXFIFOSIZE_R = crate::R<u8, RXFIFOSIZE_A>;
40impl RXFIFOSIZE_R {
41    #[doc = r"Get enumerated values variant"]
42    #[inline(always)]
43    pub fn variant(&self) -> crate::Variant<u8, RXFIFOSIZE_A> {
44        use crate::Variant::*;
45        match self.bits {
46            0 => Val(RXFIFOSIZE_A::_000),
47            1 => Val(RXFIFOSIZE_A::_001),
48            2 => Val(RXFIFOSIZE_A::_010),
49            3 => Val(RXFIFOSIZE_A::_011),
50            4 => Val(RXFIFOSIZE_A::_100),
51            5 => Val(RXFIFOSIZE_A::_101),
52            6 => Val(RXFIFOSIZE_A::_110),
53            i => Res(i),
54        }
55    }
56    #[doc = "Checks if the value of the field is `_000`"]
57    #[inline(always)]
58    pub fn is_000(&self) -> bool {
59        *self == RXFIFOSIZE_A::_000
60    }
61    #[doc = "Checks if the value of the field is `_001`"]
62    #[inline(always)]
63    pub fn is_001(&self) -> bool {
64        *self == RXFIFOSIZE_A::_001
65    }
66    #[doc = "Checks if the value of the field is `_010`"]
67    #[inline(always)]
68    pub fn is_010(&self) -> bool {
69        *self == RXFIFOSIZE_A::_010
70    }
71    #[doc = "Checks if the value of the field is `_011`"]
72    #[inline(always)]
73    pub fn is_011(&self) -> bool {
74        *self == RXFIFOSIZE_A::_011
75    }
76    #[doc = "Checks if the value of the field is `_100`"]
77    #[inline(always)]
78    pub fn is_100(&self) -> bool {
79        *self == RXFIFOSIZE_A::_100
80    }
81    #[doc = "Checks if the value of the field is `_101`"]
82    #[inline(always)]
83    pub fn is_101(&self) -> bool {
84        *self == RXFIFOSIZE_A::_101
85    }
86    #[doc = "Checks if the value of the field is `_110`"]
87    #[inline(always)]
88    pub fn is_110(&self) -> bool {
89        *self == RXFIFOSIZE_A::_110
90    }
91}
92#[doc = "Receive FIFO Enable\n\nValue on reset: 0"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum RXFE_A {
95    #[doc = "0: Receive FIFO is not enabled. Buffer is depth 1. (Legacy support)"]
96    _0 = 0,
97    #[doc = "1: Receive FIFO is enabled. Buffer is depth indicted by RXFIFOSIZE."]
98    _1 = 1,
99}
100impl From<RXFE_A> for bool {
101    #[inline(always)]
102    fn from(variant: RXFE_A) -> Self {
103        variant as u8 != 0
104    }
105}
106#[doc = "Reader of field `RXFE`"]
107pub type RXFE_R = crate::R<bool, RXFE_A>;
108impl RXFE_R {
109    #[doc = r"Get enumerated values variant"]
110    #[inline(always)]
111    pub fn variant(&self) -> RXFE_A {
112        match self.bits {
113            false => RXFE_A::_0,
114            true => RXFE_A::_1,
115        }
116    }
117    #[doc = "Checks if the value of the field is `_0`"]
118    #[inline(always)]
119    pub fn is_0(&self) -> bool {
120        *self == RXFE_A::_0
121    }
122    #[doc = "Checks if the value of the field is `_1`"]
123    #[inline(always)]
124    pub fn is_1(&self) -> bool {
125        *self == RXFE_A::_1
126    }
127}
128#[doc = "Write proxy for field `RXFE`"]
129pub struct RXFE_W<'a> {
130    w: &'a mut W,
131}
132impl<'a> RXFE_W<'a> {
133    #[doc = r"Writes `variant` to the field"]
134    #[inline(always)]
135    pub fn variant(self, variant: RXFE_A) -> &'a mut W {
136        {
137            self.bit(variant.into())
138        }
139    }
140    #[doc = "Receive FIFO is not enabled. Buffer is depth 1. (Legacy support)"]
141    #[inline(always)]
142    pub fn _0(self) -> &'a mut W {
143        self.variant(RXFE_A::_0)
144    }
145    #[doc = "Receive FIFO is enabled. Buffer is depth indicted by RXFIFOSIZE."]
146    #[inline(always)]
147    pub fn _1(self) -> &'a mut W {
148        self.variant(RXFE_A::_1)
149    }
150    #[doc = r"Sets the field bit"]
151    #[inline(always)]
152    pub fn set_bit(self) -> &'a mut W {
153        self.bit(true)
154    }
155    #[doc = r"Clears the field bit"]
156    #[inline(always)]
157    pub fn clear_bit(self) -> &'a mut W {
158        self.bit(false)
159    }
160    #[doc = r"Writes raw bits to the field"]
161    #[inline(always)]
162    pub fn bit(self, value: bool) -> &'a mut W {
163        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u8) & 0x01) << 3);
164        self.w
165    }
166}
167#[doc = "Transmit FIFO. Buffer Depth\n\nValue on reset: 0"]
168#[derive(Clone, Copy, Debug, PartialEq)]
169#[repr(u8)]
170pub enum TXFIFOSIZE_A {
171    #[doc = "0: Transmit FIFO/Buffer depth = 1 dataword."]
172    _000 = 0,
173    #[doc = "1: Transmit FIFO/Buffer depth = 4 datawords."]
174    _001 = 1,
175    #[doc = "2: Transmit FIFO/Buffer depth = 8 datawords."]
176    _010 = 2,
177    #[doc = "3: Transmit FIFO/Buffer depth = 16 datawords."]
178    _011 = 3,
179    #[doc = "4: Transmit FIFO/Buffer depth = 32 datawords."]
180    _100 = 4,
181    #[doc = "5: Transmit FIFO/Buffer depth = 64 datawords."]
182    _101 = 5,
183    #[doc = "6: Transmit FIFO/Buffer depth = 128 datawords."]
184    _110 = 6,
185}
186impl From<TXFIFOSIZE_A> for u8 {
187    #[inline(always)]
188    fn from(variant: TXFIFOSIZE_A) -> Self {
189        variant as _
190    }
191}
192#[doc = "Reader of field `TXFIFOSIZE`"]
193pub type TXFIFOSIZE_R = crate::R<u8, TXFIFOSIZE_A>;
194impl TXFIFOSIZE_R {
195    #[doc = r"Get enumerated values variant"]
196    #[inline(always)]
197    pub fn variant(&self) -> crate::Variant<u8, TXFIFOSIZE_A> {
198        use crate::Variant::*;
199        match self.bits {
200            0 => Val(TXFIFOSIZE_A::_000),
201            1 => Val(TXFIFOSIZE_A::_001),
202            2 => Val(TXFIFOSIZE_A::_010),
203            3 => Val(TXFIFOSIZE_A::_011),
204            4 => Val(TXFIFOSIZE_A::_100),
205            5 => Val(TXFIFOSIZE_A::_101),
206            6 => Val(TXFIFOSIZE_A::_110),
207            i => Res(i),
208        }
209    }
210    #[doc = "Checks if the value of the field is `_000`"]
211    #[inline(always)]
212    pub fn is_000(&self) -> bool {
213        *self == TXFIFOSIZE_A::_000
214    }
215    #[doc = "Checks if the value of the field is `_001`"]
216    #[inline(always)]
217    pub fn is_001(&self) -> bool {
218        *self == TXFIFOSIZE_A::_001
219    }
220    #[doc = "Checks if the value of the field is `_010`"]
221    #[inline(always)]
222    pub fn is_010(&self) -> bool {
223        *self == TXFIFOSIZE_A::_010
224    }
225    #[doc = "Checks if the value of the field is `_011`"]
226    #[inline(always)]
227    pub fn is_011(&self) -> bool {
228        *self == TXFIFOSIZE_A::_011
229    }
230    #[doc = "Checks if the value of the field is `_100`"]
231    #[inline(always)]
232    pub fn is_100(&self) -> bool {
233        *self == TXFIFOSIZE_A::_100
234    }
235    #[doc = "Checks if the value of the field is `_101`"]
236    #[inline(always)]
237    pub fn is_101(&self) -> bool {
238        *self == TXFIFOSIZE_A::_101
239    }
240    #[doc = "Checks if the value of the field is `_110`"]
241    #[inline(always)]
242    pub fn is_110(&self) -> bool {
243        *self == TXFIFOSIZE_A::_110
244    }
245}
246#[doc = "Transmit FIFO Enable\n\nValue on reset: 0"]
247#[derive(Clone, Copy, Debug, PartialEq)]
248pub enum TXFE_A {
249    #[doc = "0: Transmit FIFO is not enabled. Buffer is depth 1. (Legacy support)."]
250    _0 = 0,
251    #[doc = "1: Transmit FIFO is enabled. Buffer is depth indicated by TXFIFOSIZE."]
252    _1 = 1,
253}
254impl From<TXFE_A> for bool {
255    #[inline(always)]
256    fn from(variant: TXFE_A) -> Self {
257        variant as u8 != 0
258    }
259}
260#[doc = "Reader of field `TXFE`"]
261pub type TXFE_R = crate::R<bool, TXFE_A>;
262impl TXFE_R {
263    #[doc = r"Get enumerated values variant"]
264    #[inline(always)]
265    pub fn variant(&self) -> TXFE_A {
266        match self.bits {
267            false => TXFE_A::_0,
268            true => TXFE_A::_1,
269        }
270    }
271    #[doc = "Checks if the value of the field is `_0`"]
272    #[inline(always)]
273    pub fn is_0(&self) -> bool {
274        *self == TXFE_A::_0
275    }
276    #[doc = "Checks if the value of the field is `_1`"]
277    #[inline(always)]
278    pub fn is_1(&self) -> bool {
279        *self == TXFE_A::_1
280    }
281}
282#[doc = "Write proxy for field `TXFE`"]
283pub struct TXFE_W<'a> {
284    w: &'a mut W,
285}
286impl<'a> TXFE_W<'a> {
287    #[doc = r"Writes `variant` to the field"]
288    #[inline(always)]
289    pub fn variant(self, variant: TXFE_A) -> &'a mut W {
290        {
291            self.bit(variant.into())
292        }
293    }
294    #[doc = "Transmit FIFO is not enabled. Buffer is depth 1. (Legacy support)."]
295    #[inline(always)]
296    pub fn _0(self) -> &'a mut W {
297        self.variant(TXFE_A::_0)
298    }
299    #[doc = "Transmit FIFO is enabled. Buffer is depth indicated by TXFIFOSIZE."]
300    #[inline(always)]
301    pub fn _1(self) -> &'a mut W {
302        self.variant(TXFE_A::_1)
303    }
304    #[doc = r"Sets the field bit"]
305    #[inline(always)]
306    pub fn set_bit(self) -> &'a mut W {
307        self.bit(true)
308    }
309    #[doc = r"Clears the field bit"]
310    #[inline(always)]
311    pub fn clear_bit(self) -> &'a mut W {
312        self.bit(false)
313    }
314    #[doc = r"Writes raw bits to the field"]
315    #[inline(always)]
316    pub fn bit(self, value: bool) -> &'a mut W {
317        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
318        self.w
319    }
320}
321impl R {
322    #[doc = "Bits 0:2 - Receive FIFO. Buffer Depth"]
323    #[inline(always)]
324    pub fn rxfifosize(&self) -> RXFIFOSIZE_R {
325        RXFIFOSIZE_R::new((self.bits & 0x07) as u8)
326    }
327    #[doc = "Bit 3 - Receive FIFO Enable"]
328    #[inline(always)]
329    pub fn rxfe(&self) -> RXFE_R {
330        RXFE_R::new(((self.bits >> 3) & 0x01) != 0)
331    }
332    #[doc = "Bits 4:6 - Transmit FIFO. Buffer Depth"]
333    #[inline(always)]
334    pub fn txfifosize(&self) -> TXFIFOSIZE_R {
335        TXFIFOSIZE_R::new(((self.bits >> 4) & 0x07) as u8)
336    }
337    #[doc = "Bit 7 - Transmit FIFO Enable"]
338    #[inline(always)]
339    pub fn txfe(&self) -> TXFE_R {
340        TXFE_R::new(((self.bits >> 7) & 0x01) != 0)
341    }
342}
343impl W {
344    #[doc = "Bit 3 - Receive FIFO Enable"]
345    #[inline(always)]
346    pub fn rxfe(&mut self) -> RXFE_W {
347        RXFE_W { w: self }
348    }
349    #[doc = "Bit 7 - Transmit FIFO Enable"]
350    #[inline(always)]
351    pub fn txfe(&mut self) -> TXFE_W {
352        TXFE_W { w: self }
353    }
354}