stm32f4/stm32f407/can1/
esr.rs

1#[doc = "Register `ESR` reader"]
2pub struct R(crate::R<ESR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ESR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ESR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ESR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ESR` writer"]
17pub struct W(crate::W<ESR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ESR_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<ESR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ESR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `REC` reader - REC"]
38pub type REC_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `TEC` reader - TEC"]
40pub type TEC_R = crate::FieldReader<u8, u8>;
41#[doc = "LEC\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum LEC_A {
45    #[doc = "0: No Error"]
46    NoError = 0,
47    #[doc = "1: Stuff Error"]
48    Stuff = 1,
49    #[doc = "2: Form Error"]
50    Form = 2,
51    #[doc = "3: Acknowledgment Error"]
52    Ack = 3,
53    #[doc = "4: Bit recessive Error"]
54    BitRecessive = 4,
55    #[doc = "5: Bit dominant Error"]
56    BitDominant = 5,
57    #[doc = "6: CRC Error"]
58    Crc = 6,
59    #[doc = "7: Set by software"]
60    Custom = 7,
61}
62impl From<LEC_A> for u8 {
63    #[inline(always)]
64    fn from(variant: LEC_A) -> Self {
65        variant as _
66    }
67}
68#[doc = "Field `LEC` reader - LEC"]
69pub type LEC_R = crate::FieldReader<u8, LEC_A>;
70impl LEC_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> LEC_A {
74        match self.bits {
75            0 => LEC_A::NoError,
76            1 => LEC_A::Stuff,
77            2 => LEC_A::Form,
78            3 => LEC_A::Ack,
79            4 => LEC_A::BitRecessive,
80            5 => LEC_A::BitDominant,
81            6 => LEC_A::Crc,
82            7 => LEC_A::Custom,
83            _ => unreachable!(),
84        }
85    }
86    #[doc = "Checks if the value of the field is `NoError`"]
87    #[inline(always)]
88    pub fn is_no_error(&self) -> bool {
89        *self == LEC_A::NoError
90    }
91    #[doc = "Checks if the value of the field is `Stuff`"]
92    #[inline(always)]
93    pub fn is_stuff(&self) -> bool {
94        *self == LEC_A::Stuff
95    }
96    #[doc = "Checks if the value of the field is `Form`"]
97    #[inline(always)]
98    pub fn is_form(&self) -> bool {
99        *self == LEC_A::Form
100    }
101    #[doc = "Checks if the value of the field is `Ack`"]
102    #[inline(always)]
103    pub fn is_ack(&self) -> bool {
104        *self == LEC_A::Ack
105    }
106    #[doc = "Checks if the value of the field is `BitRecessive`"]
107    #[inline(always)]
108    pub fn is_bit_recessive(&self) -> bool {
109        *self == LEC_A::BitRecessive
110    }
111    #[doc = "Checks if the value of the field is `BitDominant`"]
112    #[inline(always)]
113    pub fn is_bit_dominant(&self) -> bool {
114        *self == LEC_A::BitDominant
115    }
116    #[doc = "Checks if the value of the field is `Crc`"]
117    #[inline(always)]
118    pub fn is_crc(&self) -> bool {
119        *self == LEC_A::Crc
120    }
121    #[doc = "Checks if the value of the field is `Custom`"]
122    #[inline(always)]
123    pub fn is_custom(&self) -> bool {
124        *self == LEC_A::Custom
125    }
126}
127#[doc = "Field `LEC` writer - LEC"]
128pub type LEC_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, ESR_SPEC, u8, LEC_A, 3, O>;
129impl<'a, const O: u8> LEC_W<'a, O> {
130    #[doc = "No Error"]
131    #[inline(always)]
132    pub fn no_error(self) -> &'a mut W {
133        self.variant(LEC_A::NoError)
134    }
135    #[doc = "Stuff Error"]
136    #[inline(always)]
137    pub fn stuff(self) -> &'a mut W {
138        self.variant(LEC_A::Stuff)
139    }
140    #[doc = "Form Error"]
141    #[inline(always)]
142    pub fn form(self) -> &'a mut W {
143        self.variant(LEC_A::Form)
144    }
145    #[doc = "Acknowledgment Error"]
146    #[inline(always)]
147    pub fn ack(self) -> &'a mut W {
148        self.variant(LEC_A::Ack)
149    }
150    #[doc = "Bit recessive Error"]
151    #[inline(always)]
152    pub fn bit_recessive(self) -> &'a mut W {
153        self.variant(LEC_A::BitRecessive)
154    }
155    #[doc = "Bit dominant Error"]
156    #[inline(always)]
157    pub fn bit_dominant(self) -> &'a mut W {
158        self.variant(LEC_A::BitDominant)
159    }
160    #[doc = "CRC Error"]
161    #[inline(always)]
162    pub fn crc(self) -> &'a mut W {
163        self.variant(LEC_A::Crc)
164    }
165    #[doc = "Set by software"]
166    #[inline(always)]
167    pub fn custom(self) -> &'a mut W {
168        self.variant(LEC_A::Custom)
169    }
170}
171#[doc = "Field `BOFF` reader - BOFF"]
172pub type BOFF_R = crate::BitReader<bool>;
173#[doc = "Field `EPVF` reader - EPVF"]
174pub type EPVF_R = crate::BitReader<bool>;
175#[doc = "Field `EWGF` reader - EWGF"]
176pub type EWGF_R = crate::BitReader<bool>;
177impl R {
178    #[doc = "Bits 24:31 - REC"]
179    #[inline(always)]
180    pub fn rec(&self) -> REC_R {
181        REC_R::new(((self.bits >> 24) & 0xff) as u8)
182    }
183    #[doc = "Bits 16:23 - TEC"]
184    #[inline(always)]
185    pub fn tec(&self) -> TEC_R {
186        TEC_R::new(((self.bits >> 16) & 0xff) as u8)
187    }
188    #[doc = "Bits 4:6 - LEC"]
189    #[inline(always)]
190    pub fn lec(&self) -> LEC_R {
191        LEC_R::new(((self.bits >> 4) & 7) as u8)
192    }
193    #[doc = "Bit 2 - BOFF"]
194    #[inline(always)]
195    pub fn boff(&self) -> BOFF_R {
196        BOFF_R::new(((self.bits >> 2) & 1) != 0)
197    }
198    #[doc = "Bit 1 - EPVF"]
199    #[inline(always)]
200    pub fn epvf(&self) -> EPVF_R {
201        EPVF_R::new(((self.bits >> 1) & 1) != 0)
202    }
203    #[doc = "Bit 0 - EWGF"]
204    #[inline(always)]
205    pub fn ewgf(&self) -> EWGF_R {
206        EWGF_R::new((self.bits & 1) != 0)
207    }
208}
209impl W {
210    #[doc = "Bits 4:6 - LEC"]
211    #[inline(always)]
212    pub fn lec(&mut self) -> LEC_W<4> {
213        LEC_W::new(self)
214    }
215    #[doc = "Writes raw bits to the register."]
216    #[inline(always)]
217    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
218        self.0.bits(bits);
219        self
220    }
221}
222#[doc = "interrupt enable 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 [esr](index.html) module"]
223pub struct ESR_SPEC;
224impl crate::RegisterSpec for ESR_SPEC {
225    type Ux = u32;
226}
227#[doc = "`read()` method returns [esr::R](R) reader structure"]
228impl crate::Readable for ESR_SPEC {
229    type Reader = R;
230}
231#[doc = "`write(|w| ..)` method takes [esr::W](W) writer structure"]
232impl crate::Writable for ESR_SPEC {
233    type Writer = W;
234}
235#[doc = "`reset()` method sets ESR to value 0"]
236impl crate::Resettable for ESR_SPEC {
237    #[inline(always)]
238    fn reset_value() -> Self::Ux {
239        0
240    }
241}