mk66f18/uart3/
bdh.rs

1#[doc = "Reader of register BDH"]
2pub type R = crate::R<u8, super::BDH>;
3#[doc = "Writer for register BDH"]
4pub type W = crate::W<u8, super::BDH>;
5#[doc = "Register BDH `reset()`'s with value 0"]
6impl crate::ResetValue for super::BDH {
7    type Type = u8;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `SBR`"]
14pub type SBR_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `SBR`"]
16pub struct SBR_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> SBR_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x1f) | ((value as u8) & 0x1f);
24        self.w
25    }
26}
27#[doc = "Stop Bit Number Select\n\nValue on reset: 0"]
28#[derive(Clone, Copy, Debug, PartialEq)]
29pub enum SBNS_A {
30    #[doc = "0: Data frame consists of a single stop bit."]
31    _0,
32    #[doc = "1: Data frame consists of two stop bits."]
33    _1,
34}
35impl From<SBNS_A> for bool {
36    #[inline(always)]
37    fn from(variant: SBNS_A) -> Self {
38        match variant {
39            SBNS_A::_0 => false,
40            SBNS_A::_1 => true,
41        }
42    }
43}
44#[doc = "Reader of field `SBNS`"]
45pub type SBNS_R = crate::R<bool, SBNS_A>;
46impl SBNS_R {
47    #[doc = r"Get enumerated values variant"]
48    #[inline(always)]
49    pub fn variant(&self) -> SBNS_A {
50        match self.bits {
51            false => SBNS_A::_0,
52            true => SBNS_A::_1,
53        }
54    }
55    #[doc = "Checks if the value of the field is `_0`"]
56    #[inline(always)]
57    pub fn is_0(&self) -> bool {
58        *self == SBNS_A::_0
59    }
60    #[doc = "Checks if the value of the field is `_1`"]
61    #[inline(always)]
62    pub fn is_1(&self) -> bool {
63        *self == SBNS_A::_1
64    }
65}
66#[doc = "Write proxy for field `SBNS`"]
67pub struct SBNS_W<'a> {
68    w: &'a mut W,
69}
70impl<'a> SBNS_W<'a> {
71    #[doc = r"Writes `variant` to the field"]
72    #[inline(always)]
73    pub fn variant(self, variant: SBNS_A) -> &'a mut W {
74        {
75            self.bit(variant.into())
76        }
77    }
78    #[doc = "Data frame consists of a single stop bit."]
79    #[inline(always)]
80    pub fn _0(self) -> &'a mut W {
81        self.variant(SBNS_A::_0)
82    }
83    #[doc = "Data frame consists of two stop bits."]
84    #[inline(always)]
85    pub fn _1(self) -> &'a mut W {
86        self.variant(SBNS_A::_1)
87    }
88    #[doc = r"Sets the field bit"]
89    #[inline(always)]
90    pub fn set_bit(self) -> &'a mut W {
91        self.bit(true)
92    }
93    #[doc = r"Clears the field bit"]
94    #[inline(always)]
95    pub fn clear_bit(self) -> &'a mut W {
96        self.bit(false)
97    }
98    #[doc = r"Writes raw bits to the field"]
99    #[inline(always)]
100    pub fn bit(self, value: bool) -> &'a mut W {
101        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u8) & 0x01) << 5);
102        self.w
103    }
104}
105#[doc = "RxD Input Active Edge Interrupt Enable\n\nValue on reset: 0"]
106#[derive(Clone, Copy, Debug, PartialEq)]
107pub enum RXEDGIE_A {
108    #[doc = "0: Hardware interrupts from RXEDGIF disabled using polling."]
109    _0,
110    #[doc = "1: RXEDGIF interrupt request enabled."]
111    _1,
112}
113impl From<RXEDGIE_A> for bool {
114    #[inline(always)]
115    fn from(variant: RXEDGIE_A) -> Self {
116        match variant {
117            RXEDGIE_A::_0 => false,
118            RXEDGIE_A::_1 => true,
119        }
120    }
121}
122#[doc = "Reader of field `RXEDGIE`"]
123pub type RXEDGIE_R = crate::R<bool, RXEDGIE_A>;
124impl RXEDGIE_R {
125    #[doc = r"Get enumerated values variant"]
126    #[inline(always)]
127    pub fn variant(&self) -> RXEDGIE_A {
128        match self.bits {
129            false => RXEDGIE_A::_0,
130            true => RXEDGIE_A::_1,
131        }
132    }
133    #[doc = "Checks if the value of the field is `_0`"]
134    #[inline(always)]
135    pub fn is_0(&self) -> bool {
136        *self == RXEDGIE_A::_0
137    }
138    #[doc = "Checks if the value of the field is `_1`"]
139    #[inline(always)]
140    pub fn is_1(&self) -> bool {
141        *self == RXEDGIE_A::_1
142    }
143}
144#[doc = "Write proxy for field `RXEDGIE`"]
145pub struct RXEDGIE_W<'a> {
146    w: &'a mut W,
147}
148impl<'a> RXEDGIE_W<'a> {
149    #[doc = r"Writes `variant` to the field"]
150    #[inline(always)]
151    pub fn variant(self, variant: RXEDGIE_A) -> &'a mut W {
152        {
153            self.bit(variant.into())
154        }
155    }
156    #[doc = "Hardware interrupts from RXEDGIF disabled using polling."]
157    #[inline(always)]
158    pub fn _0(self) -> &'a mut W {
159        self.variant(RXEDGIE_A::_0)
160    }
161    #[doc = "RXEDGIF interrupt request enabled."]
162    #[inline(always)]
163    pub fn _1(self) -> &'a mut W {
164        self.variant(RXEDGIE_A::_1)
165    }
166    #[doc = r"Sets the field bit"]
167    #[inline(always)]
168    pub fn set_bit(self) -> &'a mut W {
169        self.bit(true)
170    }
171    #[doc = r"Clears the field bit"]
172    #[inline(always)]
173    pub fn clear_bit(self) -> &'a mut W {
174        self.bit(false)
175    }
176    #[doc = r"Writes raw bits to the field"]
177    #[inline(always)]
178    pub fn bit(self, value: bool) -> &'a mut W {
179        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
180        self.w
181    }
182}
183#[doc = "LIN Break Detect Interrupt Enable\n\nValue on reset: 0"]
184#[derive(Clone, Copy, Debug, PartialEq)]
185pub enum LBKDIE_A {
186    #[doc = "0: LBKDIF interrupt requests disabled."]
187    _0,
188    #[doc = "1: LBKDIF interrupt requests enabled."]
189    _1,
190}
191impl From<LBKDIE_A> for bool {
192    #[inline(always)]
193    fn from(variant: LBKDIE_A) -> Self {
194        match variant {
195            LBKDIE_A::_0 => false,
196            LBKDIE_A::_1 => true,
197        }
198    }
199}
200#[doc = "Reader of field `LBKDIE`"]
201pub type LBKDIE_R = crate::R<bool, LBKDIE_A>;
202impl LBKDIE_R {
203    #[doc = r"Get enumerated values variant"]
204    #[inline(always)]
205    pub fn variant(&self) -> LBKDIE_A {
206        match self.bits {
207            false => LBKDIE_A::_0,
208            true => LBKDIE_A::_1,
209        }
210    }
211    #[doc = "Checks if the value of the field is `_0`"]
212    #[inline(always)]
213    pub fn is_0(&self) -> bool {
214        *self == LBKDIE_A::_0
215    }
216    #[doc = "Checks if the value of the field is `_1`"]
217    #[inline(always)]
218    pub fn is_1(&self) -> bool {
219        *self == LBKDIE_A::_1
220    }
221}
222#[doc = "Write proxy for field `LBKDIE`"]
223pub struct LBKDIE_W<'a> {
224    w: &'a mut W,
225}
226impl<'a> LBKDIE_W<'a> {
227    #[doc = r"Writes `variant` to the field"]
228    #[inline(always)]
229    pub fn variant(self, variant: LBKDIE_A) -> &'a mut W {
230        {
231            self.bit(variant.into())
232        }
233    }
234    #[doc = "LBKDIF interrupt requests disabled."]
235    #[inline(always)]
236    pub fn _0(self) -> &'a mut W {
237        self.variant(LBKDIE_A::_0)
238    }
239    #[doc = "LBKDIF interrupt requests enabled."]
240    #[inline(always)]
241    pub fn _1(self) -> &'a mut W {
242        self.variant(LBKDIE_A::_1)
243    }
244    #[doc = r"Sets the field bit"]
245    #[inline(always)]
246    pub fn set_bit(self) -> &'a mut W {
247        self.bit(true)
248    }
249    #[doc = r"Clears the field bit"]
250    #[inline(always)]
251    pub fn clear_bit(self) -> &'a mut W {
252        self.bit(false)
253    }
254    #[doc = r"Writes raw bits to the field"]
255    #[inline(always)]
256    pub fn bit(self, value: bool) -> &'a mut W {
257        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
258        self.w
259    }
260}
261impl R {
262    #[doc = "Bits 0:4 - UART Baud Rate Bits"]
263    #[inline(always)]
264    pub fn sbr(&self) -> SBR_R {
265        SBR_R::new((self.bits & 0x1f) as u8)
266    }
267    #[doc = "Bit 5 - Stop Bit Number Select"]
268    #[inline(always)]
269    pub fn sbns(&self) -> SBNS_R {
270        SBNS_R::new(((self.bits >> 5) & 0x01) != 0)
271    }
272    #[doc = "Bit 6 - RxD Input Active Edge Interrupt Enable"]
273    #[inline(always)]
274    pub fn rxedgie(&self) -> RXEDGIE_R {
275        RXEDGIE_R::new(((self.bits >> 6) & 0x01) != 0)
276    }
277    #[doc = "Bit 7 - LIN Break Detect Interrupt Enable"]
278    #[inline(always)]
279    pub fn lbkdie(&self) -> LBKDIE_R {
280        LBKDIE_R::new(((self.bits >> 7) & 0x01) != 0)
281    }
282}
283impl W {
284    #[doc = "Bits 0:4 - UART Baud Rate Bits"]
285    #[inline(always)]
286    pub fn sbr(&mut self) -> SBR_W {
287        SBR_W { w: self }
288    }
289    #[doc = "Bit 5 - Stop Bit Number Select"]
290    #[inline(always)]
291    pub fn sbns(&mut self) -> SBNS_W {
292        SBNS_W { w: self }
293    }
294    #[doc = "Bit 6 - RxD Input Active Edge Interrupt Enable"]
295    #[inline(always)]
296    pub fn rxedgie(&mut self) -> RXEDGIE_W {
297        RXEDGIE_W { w: self }
298    }
299    #[doc = "Bit 7 - LIN Break Detect Interrupt Enable"]
300    #[inline(always)]
301    pub fn lbkdie(&mut self) -> LBKDIE_W {
302        LBKDIE_W { w: self }
303    }
304}