1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#[doc = "Register `ERR` reader"]
pub type R = crate::R<ErrSpec>;
#[doc = "Register `ERR` writer"]
pub type W = crate::W<ErrSpec>;
#[doc = "Warning error\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Werr {
    #[doc = "0: No warning error"]
    NoError = 0,
    #[doc = "1: Warning error"]
    Error = 1,
}
impl From<Werr> for bool {
    #[inline(always)]
    fn from(variant: Werr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `WERR` reader - Warning error"]
pub type WerrR = crate::BitReader<Werr>;
impl WerrR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Werr {
        match self.bits {
            false => Werr::NoError,
            true => Werr::Error,
        }
    }
    #[doc = "No warning error"]
    #[inline(always)]
    pub fn is_no_error(&self) -> bool {
        *self == Werr::NoError
    }
    #[doc = "Warning error"]
    #[inline(always)]
    pub fn is_error(&self) -> bool {
        *self == Werr::Error
    }
}
#[doc = "Passive error\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Perr {
    #[doc = "0: No passive error"]
    NoError = 0,
    #[doc = "1: Passive error"]
    Error = 1,
}
impl From<Perr> for bool {
    #[inline(always)]
    fn from(variant: Perr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `PERR` reader - Passive error"]
pub type PerrR = crate::BitReader<Perr>;
impl PerrR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Perr {
        match self.bits {
            false => Perr::NoError,
            true => Perr::Error,
        }
    }
    #[doc = "No passive error"]
    #[inline(always)]
    pub fn is_no_error(&self) -> bool {
        *self == Perr::NoError
    }
    #[doc = "Passive error"]
    #[inline(always)]
    pub fn is_error(&self) -> bool {
        *self == Perr::Error
    }
}
#[doc = "Bus-off error\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Boerr {
    #[doc = "0: No bus-off error"]
    NoError = 0,
    #[doc = "1: Bus-off error"]
    Error = 1,
}
impl From<Boerr> for bool {
    #[inline(always)]
    fn from(variant: Boerr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `BOERR` reader - Bus-off error"]
pub type BoerrR = crate::BitReader<Boerr>;
impl BoerrR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Boerr {
        match self.bits {
            false => Boerr::NoError,
            true => Boerr::Error,
        }
    }
    #[doc = "No bus-off error"]
    #[inline(always)]
    pub fn is_no_error(&self) -> bool {
        *self == Boerr::NoError
    }
    #[doc = "Bus-off error"]
    #[inline(always)]
    pub fn is_error(&self) -> bool {
        *self == Boerr::Error
    }
}
#[doc = "Error number\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Errn {
    #[doc = "0: No Error"]
    NoError = 0,
    #[doc = "1: Stuff Error"]
    Stuff = 1,
    #[doc = "2: Form Error"]
    Form = 2,
    #[doc = "3: Acknowledgment Error"]
    Ack = 3,
    #[doc = "4: Bit recessive Error"]
    BitRecessive = 4,
    #[doc = "5: Bit dominant Error"]
    BitDominant = 5,
    #[doc = "6: CRC Error"]
    Crc = 6,
    #[doc = "7: Set by software"]
    Custom = 7,
}
impl From<Errn> for u8 {
    #[inline(always)]
    fn from(variant: Errn) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Errn {
    type Ux = u8;
}
#[doc = "Field `ERRN` reader - Error number"]
pub type ErrnR = crate::FieldReader<Errn>;
impl ErrnR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Errn {
        match self.bits {
            0 => Errn::NoError,
            1 => Errn::Stuff,
            2 => Errn::Form,
            3 => Errn::Ack,
            4 => Errn::BitRecessive,
            5 => Errn::BitDominant,
            6 => Errn::Crc,
            7 => Errn::Custom,
            _ => unreachable!(),
        }
    }
    #[doc = "No Error"]
    #[inline(always)]
    pub fn is_no_error(&self) -> bool {
        *self == Errn::NoError
    }
    #[doc = "Stuff Error"]
    #[inline(always)]
    pub fn is_stuff(&self) -> bool {
        *self == Errn::Stuff
    }
    #[doc = "Form Error"]
    #[inline(always)]
    pub fn is_form(&self) -> bool {
        *self == Errn::Form
    }
    #[doc = "Acknowledgment Error"]
    #[inline(always)]
    pub fn is_ack(&self) -> bool {
        *self == Errn::Ack
    }
    #[doc = "Bit recessive Error"]
    #[inline(always)]
    pub fn is_bit_recessive(&self) -> bool {
        *self == Errn::BitRecessive
    }
    #[doc = "Bit dominant Error"]
    #[inline(always)]
    pub fn is_bit_dominant(&self) -> bool {
        *self == Errn::BitDominant
    }
    #[doc = "CRC Error"]
    #[inline(always)]
    pub fn is_crc(&self) -> bool {
        *self == Errn::Crc
    }
    #[doc = "Set by software"]
    #[inline(always)]
    pub fn is_custom(&self) -> bool {
        *self == Errn::Custom
    }
}
#[doc = "Field `ERRN` writer - Error number"]
pub type ErrnW<'a, REG> = crate::FieldWriterSafe<'a, REG, 3, Errn>;
impl<'a, REG> ErrnW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "No Error"]
    #[inline(always)]
    pub fn no_error(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::NoError)
    }
    #[doc = "Stuff Error"]
    #[inline(always)]
    pub fn stuff(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::Stuff)
    }
    #[doc = "Form Error"]
    #[inline(always)]
    pub fn form(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::Form)
    }
    #[doc = "Acknowledgment Error"]
    #[inline(always)]
    pub fn ack(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::Ack)
    }
    #[doc = "Bit recessive Error"]
    #[inline(always)]
    pub fn bit_recessive(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::BitRecessive)
    }
    #[doc = "Bit dominant Error"]
    #[inline(always)]
    pub fn bit_dominant(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::BitDominant)
    }
    #[doc = "CRC Error"]
    #[inline(always)]
    pub fn crc(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::Crc)
    }
    #[doc = "Set by software"]
    #[inline(always)]
    pub fn custom(self) -> &'a mut crate::W<REG> {
        self.variant(Errn::Custom)
    }
}
#[doc = "Field `TECNT` reader - Transmit Error Count"]
pub type TecntR = crate::FieldReader;
#[doc = "Field `RECNT` reader - Receive Error Count"]
pub type RecntR = crate::FieldReader;
impl R {
    #[doc = "Bit 0 - Warning error"]
    #[inline(always)]
    pub fn werr(&self) -> WerrR {
        WerrR::new((self.bits & 1) != 0)
    }
    #[doc = "Bit 1 - Passive error"]
    #[inline(always)]
    pub fn perr(&self) -> PerrR {
        PerrR::new(((self.bits >> 1) & 1) != 0)
    }
    #[doc = "Bit 2 - Bus-off error"]
    #[inline(always)]
    pub fn boerr(&self) -> BoerrR {
        BoerrR::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bits 4:6 - Error number"]
    #[inline(always)]
    pub fn errn(&self) -> ErrnR {
        ErrnR::new(((self.bits >> 4) & 7) as u8)
    }
    #[doc = "Bits 16:23 - Transmit Error Count"]
    #[inline(always)]
    pub fn tecnt(&self) -> TecntR {
        TecntR::new(((self.bits >> 16) & 0xff) as u8)
    }
    #[doc = "Bits 24:31 - Receive Error Count"]
    #[inline(always)]
    pub fn recnt(&self) -> RecntR {
        RecntR::new(((self.bits >> 24) & 0xff) as u8)
    }
}
impl W {
    #[doc = "Bits 4:6 - Error number"]
    #[inline(always)]
    #[must_use]
    pub fn errn(&mut self) -> ErrnW<ErrSpec> {
        ErrnW::new(self, 4)
    }
}
#[doc = "Error register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`err::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 [`err::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct ErrSpec;
impl crate::RegisterSpec for ErrSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`err::R`](R) reader structure"]
impl crate::Readable for ErrSpec {}
#[doc = "`write(|w| ..)` method takes [`err::W`](W) writer structure"]
impl crate::Writable for ErrSpec {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets ERR to value 0"]
impl crate::Resettable for ErrSpec {
    const RESET_VALUE: u32 = 0;
}