stm32f429/can1/
tdt2r.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::TDT2R {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct TIMER {
47    bits: u16,
48}
49impl TIMER {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u16 {
53        self.bits
54    }
55}
56#[doc = r" Value of the field"]
57pub struct TGTR {
58    bits: bool,
59}
60impl TGTR {
61    #[doc = r" Value of the field as raw bits"]
62    #[inline]
63    pub fn bit(&self) -> bool {
64        self.bits
65    }
66    #[doc = r" Returns `true` if the bit is clear (0)"]
67    #[inline]
68    pub fn bit_is_clear(&self) -> bool {
69        !self.bit()
70    }
71    #[doc = r" Returns `true` if the bit is set (1)"]
72    #[inline]
73    pub fn bit_is_set(&self) -> bool {
74        self.bit()
75    }
76}
77#[doc = r" Value of the field"]
78pub struct DLCR {
79    bits: u8,
80}
81impl DLCR {
82    #[doc = r" Value of the field as raw bits"]
83    #[inline]
84    pub fn bits(&self) -> u8 {
85        self.bits
86    }
87}
88#[doc = r" Proxy"]
89pub struct _TIMEW<'a> {
90    w: &'a mut W,
91}
92impl<'a> _TIMEW<'a> {
93    #[doc = r" Writes raw bits to the field"]
94    #[inline]
95    pub unsafe fn bits(self, value: u16) -> &'a mut W {
96        const MASK: u16 = 65535;
97        const OFFSET: u8 = 16;
98        self.w.bits &= !((MASK as u32) << OFFSET);
99        self.w.bits |= ((value & MASK) as u32) << OFFSET;
100        self.w
101    }
102}
103#[doc = r" Proxy"]
104pub struct _TGTW<'a> {
105    w: &'a mut W,
106}
107impl<'a> _TGTW<'a> {
108    #[doc = r" Sets the field bit"]
109    pub fn set_bit(self) -> &'a mut W {
110        self.bit(true)
111    }
112    #[doc = r" Clears the field bit"]
113    pub fn clear_bit(self) -> &'a mut W {
114        self.bit(false)
115    }
116    #[doc = r" Writes raw bits to the field"]
117    #[inline]
118    pub fn bit(self, value: bool) -> &'a mut W {
119        const MASK: bool = true;
120        const OFFSET: u8 = 8;
121        self.w.bits &= !((MASK as u32) << OFFSET);
122        self.w.bits |= ((value & MASK) as u32) << OFFSET;
123        self.w
124    }
125}
126#[doc = r" Proxy"]
127pub struct _DLCW<'a> {
128    w: &'a mut W,
129}
130impl<'a> _DLCW<'a> {
131    #[doc = r" Writes raw bits to the field"]
132    #[inline]
133    pub unsafe fn bits(self, value: u8) -> &'a mut W {
134        const MASK: u8 = 15;
135        const OFFSET: u8 = 0;
136        self.w.bits &= !((MASK as u32) << OFFSET);
137        self.w.bits |= ((value & MASK) as u32) << OFFSET;
138        self.w
139    }
140}
141impl R {
142    #[doc = r" Value of the register as raw bits"]
143    #[inline]
144    pub fn bits(&self) -> u32 {
145        self.bits
146    }
147    #[doc = "Bits 16:31 - TIME"]
148    #[inline]
149    pub fn time(&self) -> TIMER {
150        let bits = {
151            const MASK: u16 = 65535;
152            const OFFSET: u8 = 16;
153            ((self.bits >> OFFSET) & MASK as u32) as u16
154        };
155        TIMER { bits }
156    }
157    #[doc = "Bit 8 - TGT"]
158    #[inline]
159    pub fn tgt(&self) -> TGTR {
160        let bits = {
161            const MASK: bool = true;
162            const OFFSET: u8 = 8;
163            ((self.bits >> OFFSET) & MASK as u32) != 0
164        };
165        TGTR { bits }
166    }
167    #[doc = "Bits 0:3 - DLC"]
168    #[inline]
169    pub fn dlc(&self) -> DLCR {
170        let bits = {
171            const MASK: u8 = 15;
172            const OFFSET: u8 = 0;
173            ((self.bits >> OFFSET) & MASK as u32) as u8
174        };
175        DLCR { bits }
176    }
177}
178impl W {
179    #[doc = r" Reset value of the register"]
180    #[inline]
181    pub fn reset_value() -> W {
182        W { bits: 0 }
183    }
184    #[doc = r" Writes raw bits to the register"]
185    #[inline]
186    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
187        self.bits = bits;
188        self
189    }
190    #[doc = "Bits 16:31 - TIME"]
191    #[inline]
192    pub fn time(&mut self) -> _TIMEW {
193        _TIMEW { w: self }
194    }
195    #[doc = "Bit 8 - TGT"]
196    #[inline]
197    pub fn tgt(&mut self) -> _TGTW {
198        _TGTW { w: self }
199    }
200    #[doc = "Bits 0:3 - DLC"]
201    #[inline]
202    pub fn dlc(&mut self) -> _DLCW {
203        _DLCW { w: self }
204    }
205}