efm32gg11b510_pac/can0/
test.rs1#[doc = "Register `TEST` reader"]
2pub struct R(crate::R<TEST_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TEST_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TEST_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TEST_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TEST` writer"]
17pub struct W(crate::W<TEST_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TEST_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<TEST_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TEST_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BASIC` reader - Basic Mode"]
38pub type BASIC_R = crate::BitReader<bool>;
39#[doc = "Field `BASIC` writer - Basic Mode"]
40pub type BASIC_W<'a> = crate::BitWriter<'a, u32, TEST_SPEC, bool, 2>;
41#[doc = "Field `SILENT` reader - Silent Mode"]
42pub type SILENT_R = crate::BitReader<bool>;
43#[doc = "Field `SILENT` writer - Silent Mode"]
44pub type SILENT_W<'a> = crate::BitWriter<'a, u32, TEST_SPEC, bool, 3>;
45#[doc = "Field `LBACK` reader - Loopback Mode"]
46pub type LBACK_R = crate::BitReader<bool>;
47#[doc = "Field `LBACK` writer - Loopback Mode"]
48pub type LBACK_W<'a> = crate::BitWriter<'a, u32, TEST_SPEC, bool, 4>;
49#[doc = "Control of CAN_TX Pin\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[repr(u8)]
52pub enum TX_A {
53    #[doc = "0: Reset value, CAN_TX is controlled by the CAN Core."]
54    CORE = 0,
55    #[doc = "1: Sample Point can be monitored at CAN_TX pin."]
56    SAMPT = 1,
57    #[doc = "2: CAN_TX pin drives a dominant bit (0) value."]
58    LOW = 2,
59    #[doc = "3: CAN_TX pin drives a recessive bit (1) value."]
60    HIGH = 3,
61}
62impl From<TX_A> for u8 {
63    #[inline(always)]
64    fn from(variant: TX_A) -> Self {
65        variant as _
66    }
67}
68#[doc = "Field `TX` reader - Control of CAN_TX Pin"]
69pub type TX_R = crate::FieldReader<u8, TX_A>;
70impl TX_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> TX_A {
74        match self.bits {
75            0 => TX_A::CORE,
76            1 => TX_A::SAMPT,
77            2 => TX_A::LOW,
78            3 => TX_A::HIGH,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `CORE`"]
83    #[inline(always)]
84    pub fn is_core(&self) -> bool {
85        *self == TX_A::CORE
86    }
87    #[doc = "Checks if the value of the field is `SAMPT`"]
88    #[inline(always)]
89    pub fn is_sampt(&self) -> bool {
90        *self == TX_A::SAMPT
91    }
92    #[doc = "Checks if the value of the field is `LOW`"]
93    #[inline(always)]
94    pub fn is_low(&self) -> bool {
95        *self == TX_A::LOW
96    }
97    #[doc = "Checks if the value of the field is `HIGH`"]
98    #[inline(always)]
99    pub fn is_high(&self) -> bool {
100        *self == TX_A::HIGH
101    }
102}
103#[doc = "Field `TX` writer - Control of CAN_TX Pin"]
104pub type TX_W<'a> = crate::FieldWriterSafe<'a, u32, TEST_SPEC, u8, TX_A, 2, 5>;
105impl<'a> TX_W<'a> {
106    #[doc = "Reset value, CAN_TX is controlled by the CAN Core."]
107    #[inline(always)]
108    pub fn core(self) -> &'a mut W {
109        self.variant(TX_A::CORE)
110    }
111    #[doc = "Sample Point can be monitored at CAN_TX pin."]
112    #[inline(always)]
113    pub fn sampt(self) -> &'a mut W {
114        self.variant(TX_A::SAMPT)
115    }
116    #[doc = "CAN_TX pin drives a dominant bit (0) value."]
117    #[inline(always)]
118    pub fn low(self) -> &'a mut W {
119        self.variant(TX_A::LOW)
120    }
121    #[doc = "CAN_TX pin drives a recessive bit (1) value."]
122    #[inline(always)]
123    pub fn high(self) -> &'a mut W {
124        self.variant(TX_A::HIGH)
125    }
126}
127#[doc = "Field `RX` reader - Monitors the Actual Value of CAN_RX Pin"]
128pub type RX_R = crate::BitReader<bool>;
129impl R {
130    #[doc = "Bit 2 - Basic Mode"]
131    #[inline(always)]
132    pub fn basic(&self) -> BASIC_R {
133        BASIC_R::new(((self.bits >> 2) & 1) != 0)
134    }
135    #[doc = "Bit 3 - Silent Mode"]
136    #[inline(always)]
137    pub fn silent(&self) -> SILENT_R {
138        SILENT_R::new(((self.bits >> 3) & 1) != 0)
139    }
140    #[doc = "Bit 4 - Loopback Mode"]
141    #[inline(always)]
142    pub fn lback(&self) -> LBACK_R {
143        LBACK_R::new(((self.bits >> 4) & 1) != 0)
144    }
145    #[doc = "Bits 5:6 - Control of CAN_TX Pin"]
146    #[inline(always)]
147    pub fn tx(&self) -> TX_R {
148        TX_R::new(((self.bits >> 5) & 3) as u8)
149    }
150    #[doc = "Bit 7 - Monitors the Actual Value of CAN_RX Pin"]
151    #[inline(always)]
152    pub fn rx(&self) -> RX_R {
153        RX_R::new(((self.bits >> 7) & 1) != 0)
154    }
155}
156impl W {
157    #[doc = "Bit 2 - Basic Mode"]
158    #[inline(always)]
159    pub fn basic(&mut self) -> BASIC_W {
160        BASIC_W::new(self)
161    }
162    #[doc = "Bit 3 - Silent Mode"]
163    #[inline(always)]
164    pub fn silent(&mut self) -> SILENT_W {
165        SILENT_W::new(self)
166    }
167    #[doc = "Bit 4 - Loopback Mode"]
168    #[inline(always)]
169    pub fn lback(&mut self) -> LBACK_W {
170        LBACK_W::new(self)
171    }
172    #[doc = "Bits 5:6 - Control of CAN_TX Pin"]
173    #[inline(always)]
174    pub fn tx(&mut self) -> TX_W {
175        TX_W::new(self)
176    }
177    #[doc = "Writes raw bits to the register."]
178    #[inline(always)]
179    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
180        self.0.bits(bits);
181        self
182    }
183}
184#[doc = "Test 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 [test](index.html) module"]
185pub struct TEST_SPEC;
186impl crate::RegisterSpec for TEST_SPEC {
187    type Ux = u32;
188}
189#[doc = "`read()` method returns [test::R](R) reader structure"]
190impl crate::Readable for TEST_SPEC {
191    type Reader = R;
192}
193#[doc = "`write(|w| ..)` method takes [test::W](W) writer structure"]
194impl crate::Writable for TEST_SPEC {
195    type Writer = W;
196}
197#[doc = "`reset()` method sets TEST to value 0"]
198impl crate::Resettable for TEST_SPEC {
199    #[inline(always)]
200    fn reset_value() -> Self::Ux {
201        0
202    }
203}