esp32s3/twai0/
mode.rs

1#[doc = "Register `MODE` reader"]
2pub type R = crate::R<MODE_SPEC>;
3#[doc = "Register `MODE` writer"]
4pub type W = crate::W<MODE_SPEC>;
5#[doc = "Field `RESET_MODE` reader - This bit is used to configure the operating mode of the TWAI Controller. 1: Reset mode; 0: Operating mode."]
6pub type RESET_MODE_R = crate::BitReader;
7#[doc = "Field `RESET_MODE` writer - This bit is used to configure the operating mode of the TWAI Controller. 1: Reset mode; 0: Operating mode."]
8pub type RESET_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `LISTEN_ONLY_MODE` reader - 1: Listen only mode. In this mode the nodes will only receive messages from the bus, without generating the acknowledge signal nor updating the RX error counter."]
10pub type LISTEN_ONLY_MODE_R = crate::BitReader;
11#[doc = "Field `LISTEN_ONLY_MODE` writer - 1: Listen only mode. In this mode the nodes will only receive messages from the bus, without generating the acknowledge signal nor updating the RX error counter."]
12pub type LISTEN_ONLY_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `SELF_TEST_MODE` reader - 1: Self test mode. In this mode the TX nodes can perform a successful transmission without receiving the acknowledge signal. This mode is often used to test a single node with the self reception request command."]
14pub type SELF_TEST_MODE_R = crate::BitReader;
15#[doc = "Field `SELF_TEST_MODE` writer - 1: Self test mode. In this mode the TX nodes can perform a successful transmission without receiving the acknowledge signal. This mode is often used to test a single node with the self reception request command."]
16pub type SELF_TEST_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `RX_FILTER_MODE` reader - This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single filter mode."]
18pub type RX_FILTER_MODE_R = crate::BitReader;
19#[doc = "Field `RX_FILTER_MODE` writer - This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single filter mode."]
20pub type RX_FILTER_MODE_W<'a, REG> = crate::BitWriter<'a, REG>;
21impl R {
22    #[doc = "Bit 0 - This bit is used to configure the operating mode of the TWAI Controller. 1: Reset mode; 0: Operating mode."]
23    #[inline(always)]
24    pub fn reset_mode(&self) -> RESET_MODE_R {
25        RESET_MODE_R::new((self.bits & 1) != 0)
26    }
27    #[doc = "Bit 1 - 1: Listen only mode. In this mode the nodes will only receive messages from the bus, without generating the acknowledge signal nor updating the RX error counter."]
28    #[inline(always)]
29    pub fn listen_only_mode(&self) -> LISTEN_ONLY_MODE_R {
30        LISTEN_ONLY_MODE_R::new(((self.bits >> 1) & 1) != 0)
31    }
32    #[doc = "Bit 2 - 1: Self test mode. In this mode the TX nodes can perform a successful transmission without receiving the acknowledge signal. This mode is often used to test a single node with the self reception request command."]
33    #[inline(always)]
34    pub fn self_test_mode(&self) -> SELF_TEST_MODE_R {
35        SELF_TEST_MODE_R::new(((self.bits >> 2) & 1) != 0)
36    }
37    #[doc = "Bit 3 - This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single filter mode."]
38    #[inline(always)]
39    pub fn rx_filter_mode(&self) -> RX_FILTER_MODE_R {
40        RX_FILTER_MODE_R::new(((self.bits >> 3) & 1) != 0)
41    }
42}
43#[cfg(feature = "impl-register-debug")]
44impl core::fmt::Debug for R {
45    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
46        f.debug_struct("MODE")
47            .field("reset_mode", &self.reset_mode())
48            .field("listen_only_mode", &self.listen_only_mode())
49            .field("self_test_mode", &self.self_test_mode())
50            .field("rx_filter_mode", &self.rx_filter_mode())
51            .finish()
52    }
53}
54impl W {
55    #[doc = "Bit 0 - This bit is used to configure the operating mode of the TWAI Controller. 1: Reset mode; 0: Operating mode."]
56    #[inline(always)]
57    pub fn reset_mode(&mut self) -> RESET_MODE_W<MODE_SPEC> {
58        RESET_MODE_W::new(self, 0)
59    }
60    #[doc = "Bit 1 - 1: Listen only mode. In this mode the nodes will only receive messages from the bus, without generating the acknowledge signal nor updating the RX error counter."]
61    #[inline(always)]
62    pub fn listen_only_mode(&mut self) -> LISTEN_ONLY_MODE_W<MODE_SPEC> {
63        LISTEN_ONLY_MODE_W::new(self, 1)
64    }
65    #[doc = "Bit 2 - 1: Self test mode. In this mode the TX nodes can perform a successful transmission without receiving the acknowledge signal. This mode is often used to test a single node with the self reception request command."]
66    #[inline(always)]
67    pub fn self_test_mode(&mut self) -> SELF_TEST_MODE_W<MODE_SPEC> {
68        SELF_TEST_MODE_W::new(self, 2)
69    }
70    #[doc = "Bit 3 - This bit is used to configure the filter mode. 0: Dual filter mode; 1: Single filter mode."]
71    #[inline(always)]
72    pub fn rx_filter_mode(&mut self) -> RX_FILTER_MODE_W<MODE_SPEC> {
73        RX_FILTER_MODE_W::new(self, 3)
74    }
75}
76#[doc = "Mode Register\n\nYou can [`read`](crate::Reg::read) this register and get [`mode::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mode::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
77pub struct MODE_SPEC;
78impl crate::RegisterSpec for MODE_SPEC {
79    type Ux = u32;
80}
81#[doc = "`read()` method returns [`mode::R`](R) reader structure"]
82impl crate::Readable for MODE_SPEC {}
83#[doc = "`write(|w| ..)` method takes [`mode::W`](W) writer structure"]
84impl crate::Writable for MODE_SPEC {
85    type Safety = crate::Unsafe;
86    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
87    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
88}
89#[doc = "`reset()` method sets MODE to value 0x01"]
90impl crate::Resettable for MODE_SPEC {
91    const RESET_VALUE: u32 = 0x01;
92}