ra6t2/canfd_b/
cfdc0sts.rs

1#[doc = "Register `CFDC0STS` reader"]
2pub struct R(crate::R<CFDC0STS_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CFDC0STS_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CFDC0STS_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CFDC0STS_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CFDC0STS` writer"]
17pub struct W(crate::W<CFDC0STS_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CFDC0STS_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<CFDC0STS_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CFDC0STS_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CRSTSTS` reader - Channel Reset Status"]
38pub type CRSTSTS_R = crate::BitReader<CRSTSTS_A>;
39#[doc = "Channel Reset Status\n\nValue on reset: 1"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum CRSTSTS_A {
42    #[doc = "0: Channel not in Reset mode"]
43    _0 = 0,
44    #[doc = "1: Channel in Reset mode"]
45    _1 = 1,
46}
47impl From<CRSTSTS_A> for bool {
48    #[inline(always)]
49    fn from(variant: CRSTSTS_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl CRSTSTS_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> CRSTSTS_A {
57        match self.bits {
58            false => CRSTSTS_A::_0,
59            true => CRSTSTS_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == CRSTSTS_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == CRSTSTS_A::_1
71    }
72}
73#[doc = "Field `CHLTSTS` reader - Channel Halt Status"]
74pub type CHLTSTS_R = crate::BitReader<CHLTSTS_A>;
75#[doc = "Channel Halt Status\n\nValue on reset: 0"]
76#[derive(Clone, Copy, Debug, PartialEq, Eq)]
77pub enum CHLTSTS_A {
78    #[doc = "0: Channel not in Halt mode"]
79    _0 = 0,
80    #[doc = "1: Channel in Halt mode"]
81    _1 = 1,
82}
83impl From<CHLTSTS_A> for bool {
84    #[inline(always)]
85    fn from(variant: CHLTSTS_A) -> Self {
86        variant as u8 != 0
87    }
88}
89impl CHLTSTS_R {
90    #[doc = "Get enumerated values variant"]
91    #[inline(always)]
92    pub fn variant(&self) -> CHLTSTS_A {
93        match self.bits {
94            false => CHLTSTS_A::_0,
95            true => CHLTSTS_A::_1,
96        }
97    }
98    #[doc = "Checks if the value of the field is `_0`"]
99    #[inline(always)]
100    pub fn is_0(&self) -> bool {
101        *self == CHLTSTS_A::_0
102    }
103    #[doc = "Checks if the value of the field is `_1`"]
104    #[inline(always)]
105    pub fn is_1(&self) -> bool {
106        *self == CHLTSTS_A::_1
107    }
108}
109#[doc = "Field `CSLPSTS` reader - Channel Sleep Status"]
110pub type CSLPSTS_R = crate::BitReader<CSLPSTS_A>;
111#[doc = "Channel Sleep Status\n\nValue on reset: 1"]
112#[derive(Clone, Copy, Debug, PartialEq, Eq)]
113pub enum CSLPSTS_A {
114    #[doc = "0: Channel not in Sleep mode"]
115    _0 = 0,
116    #[doc = "1: Channel in Sleep mode"]
117    _1 = 1,
118}
119impl From<CSLPSTS_A> for bool {
120    #[inline(always)]
121    fn from(variant: CSLPSTS_A) -> Self {
122        variant as u8 != 0
123    }
124}
125impl CSLPSTS_R {
126    #[doc = "Get enumerated values variant"]
127    #[inline(always)]
128    pub fn variant(&self) -> CSLPSTS_A {
129        match self.bits {
130            false => CSLPSTS_A::_0,
131            true => CSLPSTS_A::_1,
132        }
133    }
134    #[doc = "Checks if the value of the field is `_0`"]
135    #[inline(always)]
136    pub fn is_0(&self) -> bool {
137        *self == CSLPSTS_A::_0
138    }
139    #[doc = "Checks if the value of the field is `_1`"]
140    #[inline(always)]
141    pub fn is_1(&self) -> bool {
142        *self == CSLPSTS_A::_1
143    }
144}
145#[doc = "Field `EPSTS` reader - Channel Error Passive Status"]
146pub type EPSTS_R = crate::BitReader<EPSTS_A>;
147#[doc = "Channel Error Passive Status\n\nValue on reset: 0"]
148#[derive(Clone, Copy, Debug, PartialEq, Eq)]
149pub enum EPSTS_A {
150    #[doc = "0: Channel not in error passive state"]
151    _0 = 0,
152    #[doc = "1: Channel in error passive state"]
153    _1 = 1,
154}
155impl From<EPSTS_A> for bool {
156    #[inline(always)]
157    fn from(variant: EPSTS_A) -> Self {
158        variant as u8 != 0
159    }
160}
161impl EPSTS_R {
162    #[doc = "Get enumerated values variant"]
163    #[inline(always)]
164    pub fn variant(&self) -> EPSTS_A {
165        match self.bits {
166            false => EPSTS_A::_0,
167            true => EPSTS_A::_1,
168        }
169    }
170    #[doc = "Checks if the value of the field is `_0`"]
171    #[inline(always)]
172    pub fn is_0(&self) -> bool {
173        *self == EPSTS_A::_0
174    }
175    #[doc = "Checks if the value of the field is `_1`"]
176    #[inline(always)]
177    pub fn is_1(&self) -> bool {
178        *self == EPSTS_A::_1
179    }
180}
181#[doc = "Field `BOSTS` reader - Channel Bus-Off Status"]
182pub type BOSTS_R = crate::BitReader<BOSTS_A>;
183#[doc = "Channel Bus-Off Status\n\nValue on reset: 0"]
184#[derive(Clone, Copy, Debug, PartialEq, Eq)]
185pub enum BOSTS_A {
186    #[doc = "0: Channel not in bus-off state"]
187    _0 = 0,
188    #[doc = "1: Channel in bus-off state"]
189    _1 = 1,
190}
191impl From<BOSTS_A> for bool {
192    #[inline(always)]
193    fn from(variant: BOSTS_A) -> Self {
194        variant as u8 != 0
195    }
196}
197impl BOSTS_R {
198    #[doc = "Get enumerated values variant"]
199    #[inline(always)]
200    pub fn variant(&self) -> BOSTS_A {
201        match self.bits {
202            false => BOSTS_A::_0,
203            true => BOSTS_A::_1,
204        }
205    }
206    #[doc = "Checks if the value of the field is `_0`"]
207    #[inline(always)]
208    pub fn is_0(&self) -> bool {
209        *self == BOSTS_A::_0
210    }
211    #[doc = "Checks if the value of the field is `_1`"]
212    #[inline(always)]
213    pub fn is_1(&self) -> bool {
214        *self == BOSTS_A::_1
215    }
216}
217#[doc = "Field `TRMSTS` reader - Channel Transmit Status"]
218pub type TRMSTS_R = crate::BitReader<TRMSTS_A>;
219#[doc = "Channel Transmit Status\n\nValue on reset: 0"]
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221pub enum TRMSTS_A {
222    #[doc = "0: Channel is not transmitting"]
223    _0 = 0,
224    #[doc = "1: Channel is transmitting"]
225    _1 = 1,
226}
227impl From<TRMSTS_A> for bool {
228    #[inline(always)]
229    fn from(variant: TRMSTS_A) -> Self {
230        variant as u8 != 0
231    }
232}
233impl TRMSTS_R {
234    #[doc = "Get enumerated values variant"]
235    #[inline(always)]
236    pub fn variant(&self) -> TRMSTS_A {
237        match self.bits {
238            false => TRMSTS_A::_0,
239            true => TRMSTS_A::_1,
240        }
241    }
242    #[doc = "Checks if the value of the field is `_0`"]
243    #[inline(always)]
244    pub fn is_0(&self) -> bool {
245        *self == TRMSTS_A::_0
246    }
247    #[doc = "Checks if the value of the field is `_1`"]
248    #[inline(always)]
249    pub fn is_1(&self) -> bool {
250        *self == TRMSTS_A::_1
251    }
252}
253#[doc = "Field `RECSTS` reader - Channel Receive Status"]
254pub type RECSTS_R = crate::BitReader<RECSTS_A>;
255#[doc = "Channel Receive Status\n\nValue on reset: 0"]
256#[derive(Clone, Copy, Debug, PartialEq, Eq)]
257pub enum RECSTS_A {
258    #[doc = "0: Channel is not receiving"]
259    _0 = 0,
260    #[doc = "1: Channel is receiving"]
261    _1 = 1,
262}
263impl From<RECSTS_A> for bool {
264    #[inline(always)]
265    fn from(variant: RECSTS_A) -> Self {
266        variant as u8 != 0
267    }
268}
269impl RECSTS_R {
270    #[doc = "Get enumerated values variant"]
271    #[inline(always)]
272    pub fn variant(&self) -> RECSTS_A {
273        match self.bits {
274            false => RECSTS_A::_0,
275            true => RECSTS_A::_1,
276        }
277    }
278    #[doc = "Checks if the value of the field is `_0`"]
279    #[inline(always)]
280    pub fn is_0(&self) -> bool {
281        *self == RECSTS_A::_0
282    }
283    #[doc = "Checks if the value of the field is `_1`"]
284    #[inline(always)]
285    pub fn is_1(&self) -> bool {
286        *self == RECSTS_A::_1
287    }
288}
289#[doc = "Field `COMSTS` reader - Channel Communication Status"]
290pub type COMSTS_R = crate::BitReader<COMSTS_A>;
291#[doc = "Channel Communication Status\n\nValue on reset: 0"]
292#[derive(Clone, Copy, Debug, PartialEq, Eq)]
293pub enum COMSTS_A {
294    #[doc = "0: Channel is not ready for communication"]
295    _0 = 0,
296    #[doc = "1: Channel is ready for communication"]
297    _1 = 1,
298}
299impl From<COMSTS_A> for bool {
300    #[inline(always)]
301    fn from(variant: COMSTS_A) -> Self {
302        variant as u8 != 0
303    }
304}
305impl COMSTS_R {
306    #[doc = "Get enumerated values variant"]
307    #[inline(always)]
308    pub fn variant(&self) -> COMSTS_A {
309        match self.bits {
310            false => COMSTS_A::_0,
311            true => COMSTS_A::_1,
312        }
313    }
314    #[doc = "Checks if the value of the field is `_0`"]
315    #[inline(always)]
316    pub fn is_0(&self) -> bool {
317        *self == COMSTS_A::_0
318    }
319    #[doc = "Checks if the value of the field is `_1`"]
320    #[inline(always)]
321    pub fn is_1(&self) -> bool {
322        *self == COMSTS_A::_1
323    }
324}
325#[doc = "Field `ESIF` reader - Error State Indication Flag"]
326pub type ESIF_R = crate::BitReader<ESIF_A>;
327#[doc = "Error State Indication Flag\n\nValue on reset: 0"]
328#[derive(Clone, Copy, Debug, PartialEq, Eq)]
329pub enum ESIF_A {
330    #[doc = "0: No CANFD message has been received when the ESI flag was set"]
331    _0 = 0,
332    #[doc = "1: At least one CANFD message was received when the ESI flag was set"]
333    _1 = 1,
334}
335impl From<ESIF_A> for bool {
336    #[inline(always)]
337    fn from(variant: ESIF_A) -> Self {
338        variant as u8 != 0
339    }
340}
341impl ESIF_R {
342    #[doc = "Get enumerated values variant"]
343    #[inline(always)]
344    pub fn variant(&self) -> ESIF_A {
345        match self.bits {
346            false => ESIF_A::_0,
347            true => ESIF_A::_1,
348        }
349    }
350    #[doc = "Checks if the value of the field is `_0`"]
351    #[inline(always)]
352    pub fn is_0(&self) -> bool {
353        *self == ESIF_A::_0
354    }
355    #[doc = "Checks if the value of the field is `_1`"]
356    #[inline(always)]
357    pub fn is_1(&self) -> bool {
358        *self == ESIF_A::_1
359    }
360}
361#[doc = "Field `ESIF` writer - Error State Indication Flag"]
362pub type ESIF_W<'a, const O: u8> = crate::BitWriter<'a, u32, CFDC0STS_SPEC, ESIF_A, O>;
363impl<'a, const O: u8> ESIF_W<'a, O> {
364    #[doc = "No CANFD message has been received when the ESI flag was set"]
365    #[inline(always)]
366    pub fn _0(self) -> &'a mut W {
367        self.variant(ESIF_A::_0)
368    }
369    #[doc = "At least one CANFD message was received when the ESI flag was set"]
370    #[inline(always)]
371    pub fn _1(self) -> &'a mut W {
372        self.variant(ESIF_A::_1)
373    }
374}
375#[doc = "Field `REC` reader - Reception Error Count"]
376pub type REC_R = crate::FieldReader<u8, u8>;
377#[doc = "Field `TEC` reader - Transmission Error Count"]
378pub type TEC_R = crate::FieldReader<u8, u8>;
379impl R {
380    #[doc = "Bit 0 - Channel Reset Status"]
381    #[inline(always)]
382    pub fn crststs(&self) -> CRSTSTS_R {
383        CRSTSTS_R::new((self.bits & 1) != 0)
384    }
385    #[doc = "Bit 1 - Channel Halt Status"]
386    #[inline(always)]
387    pub fn chltsts(&self) -> CHLTSTS_R {
388        CHLTSTS_R::new(((self.bits >> 1) & 1) != 0)
389    }
390    #[doc = "Bit 2 - Channel Sleep Status"]
391    #[inline(always)]
392    pub fn cslpsts(&self) -> CSLPSTS_R {
393        CSLPSTS_R::new(((self.bits >> 2) & 1) != 0)
394    }
395    #[doc = "Bit 3 - Channel Error Passive Status"]
396    #[inline(always)]
397    pub fn epsts(&self) -> EPSTS_R {
398        EPSTS_R::new(((self.bits >> 3) & 1) != 0)
399    }
400    #[doc = "Bit 4 - Channel Bus-Off Status"]
401    #[inline(always)]
402    pub fn bosts(&self) -> BOSTS_R {
403        BOSTS_R::new(((self.bits >> 4) & 1) != 0)
404    }
405    #[doc = "Bit 5 - Channel Transmit Status"]
406    #[inline(always)]
407    pub fn trmsts(&self) -> TRMSTS_R {
408        TRMSTS_R::new(((self.bits >> 5) & 1) != 0)
409    }
410    #[doc = "Bit 6 - Channel Receive Status"]
411    #[inline(always)]
412    pub fn recsts(&self) -> RECSTS_R {
413        RECSTS_R::new(((self.bits >> 6) & 1) != 0)
414    }
415    #[doc = "Bit 7 - Channel Communication Status"]
416    #[inline(always)]
417    pub fn comsts(&self) -> COMSTS_R {
418        COMSTS_R::new(((self.bits >> 7) & 1) != 0)
419    }
420    #[doc = "Bit 8 - Error State Indication Flag"]
421    #[inline(always)]
422    pub fn esif(&self) -> ESIF_R {
423        ESIF_R::new(((self.bits >> 8) & 1) != 0)
424    }
425    #[doc = "Bits 16:23 - Reception Error Count"]
426    #[inline(always)]
427    pub fn rec(&self) -> REC_R {
428        REC_R::new(((self.bits >> 16) & 0xff) as u8)
429    }
430    #[doc = "Bits 24:31 - Transmission Error Count"]
431    #[inline(always)]
432    pub fn tec(&self) -> TEC_R {
433        TEC_R::new(((self.bits >> 24) & 0xff) as u8)
434    }
435}
436impl W {
437    #[doc = "Bit 8 - Error State Indication Flag"]
438    #[inline(always)]
439    #[must_use]
440    pub fn esif(&mut self) -> ESIF_W<8> {
441        ESIF_W::new(self)
442    }
443    #[doc = "Writes raw bits to the register."]
444    #[inline(always)]
445    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
446        self.0.bits(bits);
447        self
448    }
449}
450#[doc = "Channel 0 Status 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 [cfdc0sts](index.html) module"]
451pub struct CFDC0STS_SPEC;
452impl crate::RegisterSpec for CFDC0STS_SPEC {
453    type Ux = u32;
454}
455#[doc = "`read()` method returns [cfdc0sts::R](R) reader structure"]
456impl crate::Readable for CFDC0STS_SPEC {
457    type Reader = R;
458}
459#[doc = "`write(|w| ..)` method takes [cfdc0sts::W](W) writer structure"]
460impl crate::Writable for CFDC0STS_SPEC {
461    type Writer = W;
462    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
463    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
464}
465#[doc = "`reset()` method sets CFDC0STS to value 0x05"]
466impl crate::Resettable for CFDC0STS_SPEC {
467    const RESET_VALUE: Self::Ux = 0x05;
468}