1#[doc = "Reader of register CANEC"]
2pub type R = crate::R<u32, super::CANEC>;
3#[doc = "Reader of field `TEC_7_0`"]
4pub type TEC_7_0_R = crate::R<u8, u8>;
5#[doc = "Reader of field `REC_6_0`"]
6pub type REC_6_0_R = crate::R<u8, u8>;
7#[doc = "Receive error passive.\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq)]
9pub enum RP_A {
10 #[doc = "0: The receive counter is below the error passive level"]
11 BELOWERRORPASSIVE,
12 #[doc = "1: The receive counter has reached the error passive level as defined in the CAN2.0 specification"]
13 ERRORPASSIVE,
14}
15impl From<RP_A> for bool {
16 #[inline(always)]
17 fn from(variant: RP_A) -> Self {
18 match variant {
19 RP_A::BELOWERRORPASSIVE => false,
20 RP_A::ERRORPASSIVE => true,
21 }
22 }
23}
24#[doc = "Reader of field `RP`"]
25pub type RP_R = crate::R<bool, RP_A>;
26impl RP_R {
27 #[doc = r"Get enumerated values variant"]
28 #[inline(always)]
29 pub fn variant(&self) -> RP_A {
30 match self.bits {
31 false => RP_A::BELOWERRORPASSIVE,
32 true => RP_A::ERRORPASSIVE,
33 }
34 }
35 #[doc = "Checks if the value of the field is `BELOWERRORPASSIVE`"]
36 #[inline(always)]
37 pub fn is_belowerrorpassive(&self) -> bool {
38 *self == RP_A::BELOWERRORPASSIVE
39 }
40 #[doc = "Checks if the value of the field is `ERRORPASSIVE`"]
41 #[inline(always)]
42 pub fn is_errorpassive(&self) -> bool {
43 *self == RP_A::ERRORPASSIVE
44 }
45}
46impl R {
47 #[doc = "Bits 0:7 - Transmit error counter Current value of the transmit error counter (maximum value 255)."]
48 #[inline(always)]
49 pub fn tec_7_0(&self) -> TEC_7_0_R {
50 TEC_7_0_R::new((self.bits & 0xff) as u8)
51 }
52 #[doc = "Bits 8:14 - Receive error counter Current value of the receive error counter (maximum value 127)."]
53 #[inline(always)]
54 pub fn rec_6_0(&self) -> REC_6_0_R {
55 REC_6_0_R::new(((self.bits >> 8) & 0x7f) as u8)
56 }
57 #[doc = "Bit 15 - Receive error passive."]
58 #[inline(always)]
59 pub fn rp(&self) -> RP_R {
60 RP_R::new(((self.bits >> 15) & 0x01) != 0)
61 }
62}