mk20d7/can0/id2/
mod.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::ID2 {
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 EXTR {
47    bits: u32,
48}
49impl EXTR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u32 {
53        self.bits
54    }
55}
56#[doc = r" Value of the field"]
57pub struct STDR {
58    bits: u16,
59}
60impl STDR {
61    #[doc = r" Value of the field as raw bits"]
62    #[inline]
63    pub fn bits(&self) -> u16 {
64        self.bits
65    }
66}
67#[doc = r" Value of the field"]
68pub struct PRIOR {
69    bits: u8,
70}
71impl PRIOR {
72    #[doc = r" Value of the field as raw bits"]
73    #[inline]
74    pub fn bits(&self) -> u8 {
75        self.bits
76    }
77}
78#[doc = r" Proxy"]
79pub struct _EXTW<'a> {
80    w: &'a mut W,
81}
82impl<'a> _EXTW<'a> {
83    #[doc = r" Writes raw bits to the field"]
84    #[inline]
85    pub unsafe fn bits(self, value: u32) -> &'a mut W {
86        const MASK: u32 = 262143;
87        const OFFSET: u8 = 0;
88        self.w.bits &= !((MASK as u32) << OFFSET);
89        self.w.bits |= ((value & MASK) as u32) << OFFSET;
90        self.w
91    }
92}
93#[doc = r" Proxy"]
94pub struct _STDW<'a> {
95    w: &'a mut W,
96}
97impl<'a> _STDW<'a> {
98    #[doc = r" Writes raw bits to the field"]
99    #[inline]
100    pub unsafe fn bits(self, value: u16) -> &'a mut W {
101        const MASK: u16 = 2047;
102        const OFFSET: u8 = 18;
103        self.w.bits &= !((MASK as u32) << OFFSET);
104        self.w.bits |= ((value & MASK) as u32) << OFFSET;
105        self.w
106    }
107}
108#[doc = r" Proxy"]
109pub struct _PRIOW<'a> {
110    w: &'a mut W,
111}
112impl<'a> _PRIOW<'a> {
113    #[doc = r" Writes raw bits to the field"]
114    #[inline]
115    pub unsafe fn bits(self, value: u8) -> &'a mut W {
116        const MASK: u8 = 7;
117        const OFFSET: u8 = 29;
118        self.w.bits &= !((MASK as u32) << OFFSET);
119        self.w.bits |= ((value & MASK) as u32) << OFFSET;
120        self.w
121    }
122}
123impl R {
124    #[doc = r" Value of the register as raw bits"]
125    #[inline]
126    pub fn bits(&self) -> u32 {
127        self.bits
128    }
129    #[doc = "Bits 0:17 - Contains extended (LOW word) identifier of message buffer."]
130    #[inline]
131    pub fn ext(&self) -> EXTR {
132        let bits = {
133            const MASK: u32 = 262143;
134            const OFFSET: u8 = 0;
135            ((self.bits >> OFFSET) & MASK as u32) as u32
136        };
137        EXTR { bits }
138    }
139    #[doc = "Bits 18:28 - Contains standard/extended (HIGH word) identifier of message buffer."]
140    #[inline]
141    pub fn std(&self) -> STDR {
142        let bits = {
143            const MASK: u16 = 2047;
144            const OFFSET: u8 = 18;
145            ((self.bits >> OFFSET) & MASK as u32) as u16
146        };
147        STDR { bits }
148    }
149    #[doc = "Bits 29:31 - Local priority. This 3-bit fieldis only used when LPRIO_EN bit is set in MCR and it only makes sense for Tx buffers. These bits are not transmitted. They are appended to the regular ID to define the transmission priority."]
150    #[inline]
151    pub fn prio(&self) -> PRIOR {
152        let bits = {
153            const MASK: u8 = 7;
154            const OFFSET: u8 = 29;
155            ((self.bits >> OFFSET) & MASK as u32) as u8
156        };
157        PRIOR { bits }
158    }
159}
160impl W {
161    #[doc = r" Reset value of the register"]
162    #[inline]
163    pub fn reset_value() -> W {
164        W { bits: 0 }
165    }
166    #[doc = r" Writes raw bits to the register"]
167    #[inline]
168    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
169        self.bits = bits;
170        self
171    }
172    #[doc = "Bits 0:17 - Contains extended (LOW word) identifier of message buffer."]
173    #[inline]
174    pub fn ext(&mut self) -> _EXTW {
175        _EXTW { w: self }
176    }
177    #[doc = "Bits 18:28 - Contains standard/extended (HIGH word) identifier of message buffer."]
178    #[inline]
179    pub fn std(&mut self) -> _STDW {
180        _STDW { w: self }
181    }
182    #[doc = "Bits 29:31 - Local priority. This 3-bit fieldis only used when LPRIO_EN bit is set in MCR and it only makes sense for Tx buffers. These bits are not transmitted. They are appended to the regular ID to define the transmission priority."]
183    #[inline]
184    pub fn prio(&mut self) -> _PRIOW {
185        _PRIOW { w: self }
186    }
187}