tm4c129x/can0/
sts.rs

1#[doc = "Reader of register STS"]
2pub type R = crate::R<u32, super::STS>;
3#[doc = "Writer for register STS"]
4pub type W = crate::W<u32, super::STS>;
5#[doc = "Register STS `reset()`'s with value 0"]
6impl crate::ResetValue for super::STS {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Last Error Code\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum LEC_A {
17    #[doc = "0: No Error"]
18    NONE = 0,
19    #[doc = "1: Stuff Error"]
20    STUFF = 1,
21    #[doc = "2: Format Error"]
22    FORM = 2,
23    #[doc = "3: ACK Error"]
24    ACK = 3,
25    #[doc = "4: Bit 1 Error"]
26    BIT1 = 4,
27    #[doc = "5: Bit 0 Error"]
28    BIT0 = 5,
29    #[doc = "6: CRC Error"]
30    CRC = 6,
31    #[doc = "7: No Event"]
32    NOEVENT = 7,
33}
34impl From<LEC_A> for u8 {
35    #[inline(always)]
36    fn from(variant: LEC_A) -> Self {
37        variant as _
38    }
39}
40#[doc = "Reader of field `LEC`"]
41pub type LEC_R = crate::R<u8, LEC_A>;
42impl LEC_R {
43    #[doc = r"Get enumerated values variant"]
44    #[inline(always)]
45    pub fn variant(&self) -> LEC_A {
46        match self.bits {
47            0 => LEC_A::NONE,
48            1 => LEC_A::STUFF,
49            2 => LEC_A::FORM,
50            3 => LEC_A::ACK,
51            4 => LEC_A::BIT1,
52            5 => LEC_A::BIT0,
53            6 => LEC_A::CRC,
54            7 => LEC_A::NOEVENT,
55            _ => unreachable!(),
56        }
57    }
58    #[doc = "Checks if the value of the field is `NONE`"]
59    #[inline(always)]
60    pub fn is_none(&self) -> bool {
61        *self == LEC_A::NONE
62    }
63    #[doc = "Checks if the value of the field is `STUFF`"]
64    #[inline(always)]
65    pub fn is_stuff(&self) -> bool {
66        *self == LEC_A::STUFF
67    }
68    #[doc = "Checks if the value of the field is `FORM`"]
69    #[inline(always)]
70    pub fn is_form(&self) -> bool {
71        *self == LEC_A::FORM
72    }
73    #[doc = "Checks if the value of the field is `ACK`"]
74    #[inline(always)]
75    pub fn is_ack(&self) -> bool {
76        *self == LEC_A::ACK
77    }
78    #[doc = "Checks if the value of the field is `BIT1`"]
79    #[inline(always)]
80    pub fn is_bit1(&self) -> bool {
81        *self == LEC_A::BIT1
82    }
83    #[doc = "Checks if the value of the field is `BIT0`"]
84    #[inline(always)]
85    pub fn is_bit0(&self) -> bool {
86        *self == LEC_A::BIT0
87    }
88    #[doc = "Checks if the value of the field is `CRC`"]
89    #[inline(always)]
90    pub fn is_crc(&self) -> bool {
91        *self == LEC_A::CRC
92    }
93    #[doc = "Checks if the value of the field is `NOEVENT`"]
94    #[inline(always)]
95    pub fn is_noevent(&self) -> bool {
96        *self == LEC_A::NOEVENT
97    }
98}
99#[doc = "Write proxy for field `LEC`"]
100pub struct LEC_W<'a> {
101    w: &'a mut W,
102}
103impl<'a> LEC_W<'a> {
104    #[doc = r"Writes `variant` to the field"]
105    #[inline(always)]
106    pub fn variant(self, variant: LEC_A) -> &'a mut W {
107        {
108            self.bits(variant.into())
109        }
110    }
111    #[doc = "No Error"]
112    #[inline(always)]
113    pub fn none(self) -> &'a mut W {
114        self.variant(LEC_A::NONE)
115    }
116    #[doc = "Stuff Error"]
117    #[inline(always)]
118    pub fn stuff(self) -> &'a mut W {
119        self.variant(LEC_A::STUFF)
120    }
121    #[doc = "Format Error"]
122    #[inline(always)]
123    pub fn form(self) -> &'a mut W {
124        self.variant(LEC_A::FORM)
125    }
126    #[doc = "ACK Error"]
127    #[inline(always)]
128    pub fn ack(self) -> &'a mut W {
129        self.variant(LEC_A::ACK)
130    }
131    #[doc = "Bit 1 Error"]
132    #[inline(always)]
133    pub fn bit1(self) -> &'a mut W {
134        self.variant(LEC_A::BIT1)
135    }
136    #[doc = "Bit 0 Error"]
137    #[inline(always)]
138    pub fn bit0(self) -> &'a mut W {
139        self.variant(LEC_A::BIT0)
140    }
141    #[doc = "CRC Error"]
142    #[inline(always)]
143    pub fn crc(self) -> &'a mut W {
144        self.variant(LEC_A::CRC)
145    }
146    #[doc = "No Event"]
147    #[inline(always)]
148    pub fn noevent(self) -> &'a mut W {
149        self.variant(LEC_A::NOEVENT)
150    }
151    #[doc = r"Writes raw bits to the field"]
152    #[inline(always)]
153    pub fn bits(self, value: u8) -> &'a mut W {
154        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
155        self.w
156    }
157}
158#[doc = "Reader of field `TXOK`"]
159pub type TXOK_R = crate::R<bool, bool>;
160#[doc = "Write proxy for field `TXOK`"]
161pub struct TXOK_W<'a> {
162    w: &'a mut W,
163}
164impl<'a> TXOK_W<'a> {
165    #[doc = r"Sets the field bit"]
166    #[inline(always)]
167    pub fn set_bit(self) -> &'a mut W {
168        self.bit(true)
169    }
170    #[doc = r"Clears the field bit"]
171    #[inline(always)]
172    pub fn clear_bit(self) -> &'a mut W {
173        self.bit(false)
174    }
175    #[doc = r"Writes raw bits to the field"]
176    #[inline(always)]
177    pub fn bit(self, value: bool) -> &'a mut W {
178        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
179        self.w
180    }
181}
182#[doc = "Reader of field `RXOK`"]
183pub type RXOK_R = crate::R<bool, bool>;
184#[doc = "Write proxy for field `RXOK`"]
185pub struct RXOK_W<'a> {
186    w: &'a mut W,
187}
188impl<'a> RXOK_W<'a> {
189    #[doc = r"Sets the field bit"]
190    #[inline(always)]
191    pub fn set_bit(self) -> &'a mut W {
192        self.bit(true)
193    }
194    #[doc = r"Clears the field bit"]
195    #[inline(always)]
196    pub fn clear_bit(self) -> &'a mut W {
197        self.bit(false)
198    }
199    #[doc = r"Writes raw bits to the field"]
200    #[inline(always)]
201    pub fn bit(self, value: bool) -> &'a mut W {
202        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
203        self.w
204    }
205}
206#[doc = "Reader of field `EPASS`"]
207pub type EPASS_R = crate::R<bool, bool>;
208#[doc = "Write proxy for field `EPASS`"]
209pub struct EPASS_W<'a> {
210    w: &'a mut W,
211}
212impl<'a> EPASS_W<'a> {
213    #[doc = r"Sets the field bit"]
214    #[inline(always)]
215    pub fn set_bit(self) -> &'a mut W {
216        self.bit(true)
217    }
218    #[doc = r"Clears the field bit"]
219    #[inline(always)]
220    pub fn clear_bit(self) -> &'a mut W {
221        self.bit(false)
222    }
223    #[doc = r"Writes raw bits to the field"]
224    #[inline(always)]
225    pub fn bit(self, value: bool) -> &'a mut W {
226        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
227        self.w
228    }
229}
230#[doc = "Reader of field `EWARN`"]
231pub type EWARN_R = crate::R<bool, bool>;
232#[doc = "Write proxy for field `EWARN`"]
233pub struct EWARN_W<'a> {
234    w: &'a mut W,
235}
236impl<'a> EWARN_W<'a> {
237    #[doc = r"Sets the field bit"]
238    #[inline(always)]
239    pub fn set_bit(self) -> &'a mut W {
240        self.bit(true)
241    }
242    #[doc = r"Clears the field bit"]
243    #[inline(always)]
244    pub fn clear_bit(self) -> &'a mut W {
245        self.bit(false)
246    }
247    #[doc = r"Writes raw bits to the field"]
248    #[inline(always)]
249    pub fn bit(self, value: bool) -> &'a mut W {
250        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
251        self.w
252    }
253}
254#[doc = "Reader of field `BOFF`"]
255pub type BOFF_R = crate::R<bool, bool>;
256#[doc = "Write proxy for field `BOFF`"]
257pub struct BOFF_W<'a> {
258    w: &'a mut W,
259}
260impl<'a> BOFF_W<'a> {
261    #[doc = r"Sets the field bit"]
262    #[inline(always)]
263    pub fn set_bit(self) -> &'a mut W {
264        self.bit(true)
265    }
266    #[doc = r"Clears the field bit"]
267    #[inline(always)]
268    pub fn clear_bit(self) -> &'a mut W {
269        self.bit(false)
270    }
271    #[doc = r"Writes raw bits to the field"]
272    #[inline(always)]
273    pub fn bit(self, value: bool) -> &'a mut W {
274        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
275        self.w
276    }
277}
278impl R {
279    #[doc = "Bits 0:2 - Last Error Code"]
280    #[inline(always)]
281    pub fn lec(&self) -> LEC_R {
282        LEC_R::new((self.bits & 0x07) as u8)
283    }
284    #[doc = "Bit 3 - Transmitted a Message Successfully"]
285    #[inline(always)]
286    pub fn txok(&self) -> TXOK_R {
287        TXOK_R::new(((self.bits >> 3) & 0x01) != 0)
288    }
289    #[doc = "Bit 4 - Received a Message Successfully"]
290    #[inline(always)]
291    pub fn rxok(&self) -> RXOK_R {
292        RXOK_R::new(((self.bits >> 4) & 0x01) != 0)
293    }
294    #[doc = "Bit 5 - Error Passive"]
295    #[inline(always)]
296    pub fn epass(&self) -> EPASS_R {
297        EPASS_R::new(((self.bits >> 5) & 0x01) != 0)
298    }
299    #[doc = "Bit 6 - Warning Status"]
300    #[inline(always)]
301    pub fn ewarn(&self) -> EWARN_R {
302        EWARN_R::new(((self.bits >> 6) & 0x01) != 0)
303    }
304    #[doc = "Bit 7 - Bus-Off Status"]
305    #[inline(always)]
306    pub fn boff(&self) -> BOFF_R {
307        BOFF_R::new(((self.bits >> 7) & 0x01) != 0)
308    }
309}
310impl W {
311    #[doc = "Bits 0:2 - Last Error Code"]
312    #[inline(always)]
313    pub fn lec(&mut self) -> LEC_W {
314        LEC_W { w: self }
315    }
316    #[doc = "Bit 3 - Transmitted a Message Successfully"]
317    #[inline(always)]
318    pub fn txok(&mut self) -> TXOK_W {
319        TXOK_W { w: self }
320    }
321    #[doc = "Bit 4 - Received a Message Successfully"]
322    #[inline(always)]
323    pub fn rxok(&mut self) -> RXOK_W {
324        RXOK_W { w: self }
325    }
326    #[doc = "Bit 5 - Error Passive"]
327    #[inline(always)]
328    pub fn epass(&mut self) -> EPASS_W {
329        EPASS_W { w: self }
330    }
331    #[doc = "Bit 6 - Warning Status"]
332    #[inline(always)]
333    pub fn ewarn(&mut self) -> EWARN_W {
334        EWARN_W { w: self }
335    }
336    #[doc = "Bit 7 - Bus-Off Status"]
337    #[inline(always)]
338    pub fn boff(&mut self) -> BOFF_W {
339        BOFF_W { w: self }
340    }
341}