esp32p4/twai0/
err_code_cap.rs

1#[doc = "Register `ERR_CODE_CAP` reader"]
2pub type R = crate::R<ERR_CODE_CAP_SPEC>;
3#[doc = "Field `ERR_CAPTURE_CODE_SEGMENT` reader - This register contains information about the location of errors on the bus."]
4pub type ERR_CAPTURE_CODE_SEGMENT_R = crate::FieldReader;
5#[doc = "Field `ERR_CAPTURE_CODE_DIRECTION` reader - 1: RX, error occurred during reception. 0: TX, error occurred during transmission."]
6pub type ERR_CAPTURE_CODE_DIRECTION_R = crate::BitReader;
7#[doc = "Field `ERR_CAPTURE_CODE_TYPE` reader - 00: bit error. 01: form error. 10:stuff error. 11:other type of error."]
8pub type ERR_CAPTURE_CODE_TYPE_R = crate::FieldReader;
9impl R {
10    #[doc = "Bits 0:4 - This register contains information about the location of errors on the bus."]
11    #[inline(always)]
12    pub fn err_capture_code_segment(&self) -> ERR_CAPTURE_CODE_SEGMENT_R {
13        ERR_CAPTURE_CODE_SEGMENT_R::new((self.bits & 0x1f) as u8)
14    }
15    #[doc = "Bit 5 - 1: RX, error occurred during reception. 0: TX, error occurred during transmission."]
16    #[inline(always)]
17    pub fn err_capture_code_direction(&self) -> ERR_CAPTURE_CODE_DIRECTION_R {
18        ERR_CAPTURE_CODE_DIRECTION_R::new(((self.bits >> 5) & 1) != 0)
19    }
20    #[doc = "Bits 6:7 - 00: bit error. 01: form error. 10:stuff error. 11:other type of error."]
21    #[inline(always)]
22    pub fn err_capture_code_type(&self) -> ERR_CAPTURE_CODE_TYPE_R {
23        ERR_CAPTURE_CODE_TYPE_R::new(((self.bits >> 6) & 3) as u8)
24    }
25}
26#[cfg(feature = "impl-register-debug")]
27impl core::fmt::Debug for R {
28    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
29        f.debug_struct("ERR_CODE_CAP")
30            .field(
31                "err_capture_code_segment",
32                &format_args!("{}", self.err_capture_code_segment().bits()),
33            )
34            .field(
35                "err_capture_code_direction",
36                &format_args!("{}", self.err_capture_code_direction().bit()),
37            )
38            .field(
39                "err_capture_code_type",
40                &format_args!("{}", self.err_capture_code_type().bits()),
41            )
42            .finish()
43    }
44}
45#[cfg(feature = "impl-register-debug")]
46impl core::fmt::Debug for crate::generic::Reg<ERR_CODE_CAP_SPEC> {
47    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
48        core::fmt::Debug::fmt(&self.read(), f)
49    }
50}
51#[doc = "TWAI error info capture register.\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`err_code_cap::R`](R).  See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
52pub struct ERR_CODE_CAP_SPEC;
53impl crate::RegisterSpec for ERR_CODE_CAP_SPEC {
54    type Ux = u32;
55}
56#[doc = "`read()` method returns [`err_code_cap::R`](R) reader structure"]
57impl crate::Readable for ERR_CODE_CAP_SPEC {}
58#[doc = "`reset()` method sets ERR_CODE_CAP to value 0"]
59impl crate::Resettable for ERR_CODE_CAP_SPEC {
60    const RESET_VALUE: u32 = 0;
61}