stm32f30x/i2c1/timeoutr/
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::TIMEOUTR {
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 TIMEOUTAR {
47    bits: u16,
48}
49impl TIMEOUTAR {
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 TIDLER {
58    bits: bool,
59}
60impl TIDLER {
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 TIMOUTENR {
79    bits: bool,
80}
81impl TIMOUTENR {
82    #[doc = r" Value of the field as raw bits"]
83    #[inline]
84    pub fn bit(&self) -> bool {
85        self.bits
86    }
87    #[doc = r" Returns `true` if the bit is clear (0)"]
88    #[inline]
89    pub fn bit_is_clear(&self) -> bool {
90        !self.bit()
91    }
92    #[doc = r" Returns `true` if the bit is set (1)"]
93    #[inline]
94    pub fn bit_is_set(&self) -> bool {
95        self.bit()
96    }
97}
98#[doc = r" Value of the field"]
99pub struct TIMEOUTBR {
100    bits: u16,
101}
102impl TIMEOUTBR {
103    #[doc = r" Value of the field as raw bits"]
104    #[inline]
105    pub fn bits(&self) -> u16 {
106        self.bits
107    }
108}
109#[doc = r" Value of the field"]
110pub struct TEXTENR {
111    bits: bool,
112}
113impl TEXTENR {
114    #[doc = r" Value of the field as raw bits"]
115    #[inline]
116    pub fn bit(&self) -> bool {
117        self.bits
118    }
119    #[doc = r" Returns `true` if the bit is clear (0)"]
120    #[inline]
121    pub fn bit_is_clear(&self) -> bool {
122        !self.bit()
123    }
124    #[doc = r" Returns `true` if the bit is set (1)"]
125    #[inline]
126    pub fn bit_is_set(&self) -> bool {
127        self.bit()
128    }
129}
130#[doc = r" Proxy"]
131pub struct _TIMEOUTAW<'a> {
132    w: &'a mut W,
133}
134impl<'a> _TIMEOUTAW<'a> {
135    #[doc = r" Writes raw bits to the field"]
136    #[inline]
137    pub unsafe fn bits(self, value: u16) -> &'a mut W {
138        const MASK: u16 = 4095;
139        const OFFSET: u8 = 0;
140        self.w.bits &= !((MASK as u32) << OFFSET);
141        self.w.bits |= ((value & MASK) as u32) << OFFSET;
142        self.w
143    }
144}
145#[doc = r" Proxy"]
146pub struct _TIDLEW<'a> {
147    w: &'a mut W,
148}
149impl<'a> _TIDLEW<'a> {
150    #[doc = r" Sets the field bit"]
151    pub fn set_bit(self) -> &'a mut W {
152        self.bit(true)
153    }
154    #[doc = r" Clears the field bit"]
155    pub fn clear_bit(self) -> &'a mut W {
156        self.bit(false)
157    }
158    #[doc = r" Writes raw bits to the field"]
159    #[inline]
160    pub fn bit(self, value: bool) -> &'a mut W {
161        const MASK: bool = true;
162        const OFFSET: u8 = 12;
163        self.w.bits &= !((MASK as u32) << OFFSET);
164        self.w.bits |= ((value & MASK) as u32) << OFFSET;
165        self.w
166    }
167}
168#[doc = r" Proxy"]
169pub struct _TIMOUTENW<'a> {
170    w: &'a mut W,
171}
172impl<'a> _TIMOUTENW<'a> {
173    #[doc = r" Sets the field bit"]
174    pub fn set_bit(self) -> &'a mut W {
175        self.bit(true)
176    }
177    #[doc = r" Clears the field bit"]
178    pub fn clear_bit(self) -> &'a mut W {
179        self.bit(false)
180    }
181    #[doc = r" Writes raw bits to the field"]
182    #[inline]
183    pub fn bit(self, value: bool) -> &'a mut W {
184        const MASK: bool = true;
185        const OFFSET: u8 = 15;
186        self.w.bits &= !((MASK as u32) << OFFSET);
187        self.w.bits |= ((value & MASK) as u32) << OFFSET;
188        self.w
189    }
190}
191#[doc = r" Proxy"]
192pub struct _TIMEOUTBW<'a> {
193    w: &'a mut W,
194}
195impl<'a> _TIMEOUTBW<'a> {
196    #[doc = r" Writes raw bits to the field"]
197    #[inline]
198    pub unsafe fn bits(self, value: u16) -> &'a mut W {
199        const MASK: u16 = 4095;
200        const OFFSET: u8 = 16;
201        self.w.bits &= !((MASK as u32) << OFFSET);
202        self.w.bits |= ((value & MASK) as u32) << OFFSET;
203        self.w
204    }
205}
206#[doc = r" Proxy"]
207pub struct _TEXTENW<'a> {
208    w: &'a mut W,
209}
210impl<'a> _TEXTENW<'a> {
211    #[doc = r" Sets the field bit"]
212    pub fn set_bit(self) -> &'a mut W {
213        self.bit(true)
214    }
215    #[doc = r" Clears the field bit"]
216    pub fn clear_bit(self) -> &'a mut W {
217        self.bit(false)
218    }
219    #[doc = r" Writes raw bits to the field"]
220    #[inline]
221    pub fn bit(self, value: bool) -> &'a mut W {
222        const MASK: bool = true;
223        const OFFSET: u8 = 31;
224        self.w.bits &= !((MASK as u32) << OFFSET);
225        self.w.bits |= ((value & MASK) as u32) << OFFSET;
226        self.w
227    }
228}
229impl R {
230    #[doc = r" Value of the register as raw bits"]
231    #[inline]
232    pub fn bits(&self) -> u32 {
233        self.bits
234    }
235    #[doc = "Bits 0:11 - Bus timeout A"]
236    #[inline]
237    pub fn timeouta(&self) -> TIMEOUTAR {
238        let bits = {
239            const MASK: u16 = 4095;
240            const OFFSET: u8 = 0;
241            ((self.bits >> OFFSET) & MASK as u32) as u16
242        };
243        TIMEOUTAR { bits }
244    }
245    #[doc = "Bit 12 - Idle clock timeout detection"]
246    #[inline]
247    pub fn tidle(&self) -> TIDLER {
248        let bits = {
249            const MASK: bool = true;
250            const OFFSET: u8 = 12;
251            ((self.bits >> OFFSET) & MASK as u32) != 0
252        };
253        TIDLER { bits }
254    }
255    #[doc = "Bit 15 - Clock timeout enable"]
256    #[inline]
257    pub fn timouten(&self) -> TIMOUTENR {
258        let bits = {
259            const MASK: bool = true;
260            const OFFSET: u8 = 15;
261            ((self.bits >> OFFSET) & MASK as u32) != 0
262        };
263        TIMOUTENR { bits }
264    }
265    #[doc = "Bits 16:27 - Bus timeout B"]
266    #[inline]
267    pub fn timeoutb(&self) -> TIMEOUTBR {
268        let bits = {
269            const MASK: u16 = 4095;
270            const OFFSET: u8 = 16;
271            ((self.bits >> OFFSET) & MASK as u32) as u16
272        };
273        TIMEOUTBR { bits }
274    }
275    #[doc = "Bit 31 - Extended clock timeout enable"]
276    #[inline]
277    pub fn texten(&self) -> TEXTENR {
278        let bits = {
279            const MASK: bool = true;
280            const OFFSET: u8 = 31;
281            ((self.bits >> OFFSET) & MASK as u32) != 0
282        };
283        TEXTENR { bits }
284    }
285}
286impl W {
287    #[doc = r" Reset value of the register"]
288    #[inline]
289    pub fn reset_value() -> W {
290        W { bits: 0 }
291    }
292    #[doc = r" Writes raw bits to the register"]
293    #[inline]
294    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
295        self.bits = bits;
296        self
297    }
298    #[doc = "Bits 0:11 - Bus timeout A"]
299    #[inline]
300    pub fn timeouta(&mut self) -> _TIMEOUTAW {
301        _TIMEOUTAW { w: self }
302    }
303    #[doc = "Bit 12 - Idle clock timeout detection"]
304    #[inline]
305    pub fn tidle(&mut self) -> _TIDLEW {
306        _TIDLEW { w: self }
307    }
308    #[doc = "Bit 15 - Clock timeout enable"]
309    #[inline]
310    pub fn timouten(&mut self) -> _TIMOUTENW {
311        _TIMOUTENW { w: self }
312    }
313    #[doc = "Bits 16:27 - Bus timeout B"]
314    #[inline]
315    pub fn timeoutb(&mut self) -> _TIMEOUTBW {
316        _TIMEOUTBW { w: self }
317    }
318    #[doc = "Bit 31 - Extended clock timeout enable"]
319    #[inline]
320    pub fn texten(&mut self) -> _TEXTENW {
321        _TEXTENW { w: self }
322    }
323}