stm32l4x2_pac/i2c1/
timeoutr.rs1#[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 = "Possible values of the field `TIDLE`"]
57#[derive(Clone, Copy, Debug, PartialEq)]
58pub enum TIDLER {
59 #[doc = "TIMEOUTA is used to detect SCL low timeout"]
60 DISABLED,
61 #[doc = "TIMEOUTA is used to detect both SCL and SDA high timeout (bus idle condition)"]
62 ENABLED,
63}
64impl TIDLER {
65 #[doc = r" Returns `true` if the bit is clear (0)"]
66 #[inline]
67 pub fn bit_is_clear(&self) -> bool {
68 !self.bit()
69 }
70 #[doc = r" Returns `true` if the bit is set (1)"]
71 #[inline]
72 pub fn bit_is_set(&self) -> bool {
73 self.bit()
74 }
75 #[doc = r" Value of the field as raw bits"]
76 #[inline]
77 pub fn bit(&self) -> bool {
78 match *self {
79 TIDLER::DISABLED => false,
80 TIDLER::ENABLED => true,
81 }
82 }
83 #[allow(missing_docs)]
84 #[doc(hidden)]
85 #[inline]
86 pub fn _from(value: bool) -> TIDLER {
87 match value {
88 false => TIDLER::DISABLED,
89 true => TIDLER::ENABLED,
90 }
91 }
92 #[doc = "Checks if the value of the field is `DISABLED`"]
93 #[inline]
94 pub fn is_disabled(&self) -> bool {
95 *self == TIDLER::DISABLED
96 }
97 #[doc = "Checks if the value of the field is `ENABLED`"]
98 #[inline]
99 pub fn is_enabled(&self) -> bool {
100 *self == TIDLER::ENABLED
101 }
102}
103#[doc = "Possible values of the field `TIMOUTEN`"]
104#[derive(Clone, Copy, Debug, PartialEq)]
105pub enum TIMOUTENR {
106 #[doc = "SCL timeout detection is disabled"]
107 DISABLED,
108 #[doc = "SCL timeout detection is enabled"]
109 ENABLED,
110}
111impl TIMOUTENR {
112 #[doc = r" Returns `true` if the bit is clear (0)"]
113 #[inline]
114 pub fn bit_is_clear(&self) -> bool {
115 !self.bit()
116 }
117 #[doc = r" Returns `true` if the bit is set (1)"]
118 #[inline]
119 pub fn bit_is_set(&self) -> bool {
120 self.bit()
121 }
122 #[doc = r" Value of the field as raw bits"]
123 #[inline]
124 pub fn bit(&self) -> bool {
125 match *self {
126 TIMOUTENR::DISABLED => false,
127 TIMOUTENR::ENABLED => true,
128 }
129 }
130 #[allow(missing_docs)]
131 #[doc(hidden)]
132 #[inline]
133 pub fn _from(value: bool) -> TIMOUTENR {
134 match value {
135 false => TIMOUTENR::DISABLED,
136 true => TIMOUTENR::ENABLED,
137 }
138 }
139 #[doc = "Checks if the value of the field is `DISABLED`"]
140 #[inline]
141 pub fn is_disabled(&self) -> bool {
142 *self == TIMOUTENR::DISABLED
143 }
144 #[doc = "Checks if the value of the field is `ENABLED`"]
145 #[inline]
146 pub fn is_enabled(&self) -> bool {
147 *self == TIMOUTENR::ENABLED
148 }
149}
150#[doc = r" Value of the field"]
151pub struct TIMEOUTBR {
152 bits: u16,
153}
154impl TIMEOUTBR {
155 #[doc = r" Value of the field as raw bits"]
156 #[inline]
157 pub fn bits(&self) -> u16 {
158 self.bits
159 }
160}
161#[doc = "Possible values of the field `TEXTEN`"]
162#[derive(Clone, Copy, Debug, PartialEq)]
163pub enum TEXTENR {
164 #[doc = "Extended clock timeout detection is disabled"]
165 DISABLED,
166 #[doc = "Extended clock timeout detection is enabled"]
167 ENABLED,
168}
169impl TEXTENR {
170 #[doc = r" Returns `true` if the bit is clear (0)"]
171 #[inline]
172 pub fn bit_is_clear(&self) -> bool {
173 !self.bit()
174 }
175 #[doc = r" Returns `true` if the bit is set (1)"]
176 #[inline]
177 pub fn bit_is_set(&self) -> bool {
178 self.bit()
179 }
180 #[doc = r" Value of the field as raw bits"]
181 #[inline]
182 pub fn bit(&self) -> bool {
183 match *self {
184 TEXTENR::DISABLED => false,
185 TEXTENR::ENABLED => true,
186 }
187 }
188 #[allow(missing_docs)]
189 #[doc(hidden)]
190 #[inline]
191 pub fn _from(value: bool) -> TEXTENR {
192 match value {
193 false => TEXTENR::DISABLED,
194 true => TEXTENR::ENABLED,
195 }
196 }
197 #[doc = "Checks if the value of the field is `DISABLED`"]
198 #[inline]
199 pub fn is_disabled(&self) -> bool {
200 *self == TEXTENR::DISABLED
201 }
202 #[doc = "Checks if the value of the field is `ENABLED`"]
203 #[inline]
204 pub fn is_enabled(&self) -> bool {
205 *self == TEXTENR::ENABLED
206 }
207}
208#[doc = r" Proxy"]
209pub struct _TIMEOUTAW<'a> {
210 w: &'a mut W,
211}
212impl<'a> _TIMEOUTAW<'a> {
213 #[doc = r" Writes raw bits to the field"]
214 #[inline]
215 pub fn bits(self, value: u16) -> &'a mut W {
216 const MASK: u16 = 4095;
217 const OFFSET: u8 = 0;
218 self.w.bits &= !((MASK as u32) << OFFSET);
219 self.w.bits |= ((value & MASK) as u32) << OFFSET;
220 self.w
221 }
222}
223#[doc = "Values that can be written to the field `TIDLE`"]
224pub enum TIDLEW {
225 #[doc = "TIMEOUTA is used to detect SCL low timeout"]
226 DISABLED,
227 #[doc = "TIMEOUTA is used to detect both SCL and SDA high timeout (bus idle condition)"]
228 ENABLED,
229}
230impl TIDLEW {
231 #[allow(missing_docs)]
232 #[doc(hidden)]
233 #[inline]
234 pub fn _bits(&self) -> bool {
235 match *self {
236 TIDLEW::DISABLED => false,
237 TIDLEW::ENABLED => true,
238 }
239 }
240}
241#[doc = r" Proxy"]
242pub struct _TIDLEW<'a> {
243 w: &'a mut W,
244}
245impl<'a> _TIDLEW<'a> {
246 #[doc = r" Writes `variant` to the field"]
247 #[inline]
248 pub fn variant(self, variant: TIDLEW) -> &'a mut W {
249 {
250 self.bit(variant._bits())
251 }
252 }
253 #[doc = "TIMEOUTA is used to detect SCL low timeout"]
254 #[inline]
255 pub fn disabled(self) -> &'a mut W {
256 self.variant(TIDLEW::DISABLED)
257 }
258 #[doc = "TIMEOUTA is used to detect both SCL and SDA high timeout (bus idle condition)"]
259 #[inline]
260 pub fn enabled(self) -> &'a mut W {
261 self.variant(TIDLEW::ENABLED)
262 }
263 #[doc = r" Sets the field bit"]
264 pub fn set_bit(self) -> &'a mut W {
265 self.bit(true)
266 }
267 #[doc = r" Clears the field bit"]
268 pub fn clear_bit(self) -> &'a mut W {
269 self.bit(false)
270 }
271 #[doc = r" Writes raw bits to the field"]
272 #[inline]
273 pub fn bit(self, value: bool) -> &'a mut W {
274 const MASK: bool = true;
275 const OFFSET: u8 = 12;
276 self.w.bits &= !((MASK as u32) << OFFSET);
277 self.w.bits |= ((value & MASK) as u32) << OFFSET;
278 self.w
279 }
280}
281#[doc = "Values that can be written to the field `TIMOUTEN`"]
282pub enum TIMOUTENW {
283 #[doc = "SCL timeout detection is disabled"]
284 DISABLED,
285 #[doc = "SCL timeout detection is enabled"]
286 ENABLED,
287}
288impl TIMOUTENW {
289 #[allow(missing_docs)]
290 #[doc(hidden)]
291 #[inline]
292 pub fn _bits(&self) -> bool {
293 match *self {
294 TIMOUTENW::DISABLED => false,
295 TIMOUTENW::ENABLED => true,
296 }
297 }
298}
299#[doc = r" Proxy"]
300pub struct _TIMOUTENW<'a> {
301 w: &'a mut W,
302}
303impl<'a> _TIMOUTENW<'a> {
304 #[doc = r" Writes `variant` to the field"]
305 #[inline]
306 pub fn variant(self, variant: TIMOUTENW) -> &'a mut W {
307 {
308 self.bit(variant._bits())
309 }
310 }
311 #[doc = "SCL timeout detection is disabled"]
312 #[inline]
313 pub fn disabled(self) -> &'a mut W {
314 self.variant(TIMOUTENW::DISABLED)
315 }
316 #[doc = "SCL timeout detection is enabled"]
317 #[inline]
318 pub fn enabled(self) -> &'a mut W {
319 self.variant(TIMOUTENW::ENABLED)
320 }
321 #[doc = r" Sets the field bit"]
322 pub fn set_bit(self) -> &'a mut W {
323 self.bit(true)
324 }
325 #[doc = r" Clears the field bit"]
326 pub fn clear_bit(self) -> &'a mut W {
327 self.bit(false)
328 }
329 #[doc = r" Writes raw bits to the field"]
330 #[inline]
331 pub fn bit(self, value: bool) -> &'a mut W {
332 const MASK: bool = true;
333 const OFFSET: u8 = 15;
334 self.w.bits &= !((MASK as u32) << OFFSET);
335 self.w.bits |= ((value & MASK) as u32) << OFFSET;
336 self.w
337 }
338}
339#[doc = r" Proxy"]
340pub struct _TIMEOUTBW<'a> {
341 w: &'a mut W,
342}
343impl<'a> _TIMEOUTBW<'a> {
344 #[doc = r" Writes raw bits to the field"]
345 #[inline]
346 pub fn bits(self, value: u16) -> &'a mut W {
347 const MASK: u16 = 4095;
348 const OFFSET: u8 = 16;
349 self.w.bits &= !((MASK as u32) << OFFSET);
350 self.w.bits |= ((value & MASK) as u32) << OFFSET;
351 self.w
352 }
353}
354#[doc = "Values that can be written to the field `TEXTEN`"]
355pub enum TEXTENW {
356 #[doc = "Extended clock timeout detection is disabled"]
357 DISABLED,
358 #[doc = "Extended clock timeout detection is enabled"]
359 ENABLED,
360}
361impl TEXTENW {
362 #[allow(missing_docs)]
363 #[doc(hidden)]
364 #[inline]
365 pub fn _bits(&self) -> bool {
366 match *self {
367 TEXTENW::DISABLED => false,
368 TEXTENW::ENABLED => true,
369 }
370 }
371}
372#[doc = r" Proxy"]
373pub struct _TEXTENW<'a> {
374 w: &'a mut W,
375}
376impl<'a> _TEXTENW<'a> {
377 #[doc = r" Writes `variant` to the field"]
378 #[inline]
379 pub fn variant(self, variant: TEXTENW) -> &'a mut W {
380 {
381 self.bit(variant._bits())
382 }
383 }
384 #[doc = "Extended clock timeout detection is disabled"]
385 #[inline]
386 pub fn disabled(self) -> &'a mut W {
387 self.variant(TEXTENW::DISABLED)
388 }
389 #[doc = "Extended clock timeout detection is enabled"]
390 #[inline]
391 pub fn enabled(self) -> &'a mut W {
392 self.variant(TEXTENW::ENABLED)
393 }
394 #[doc = r" Sets the field bit"]
395 pub fn set_bit(self) -> &'a mut W {
396 self.bit(true)
397 }
398 #[doc = r" Clears the field bit"]
399 pub fn clear_bit(self) -> &'a mut W {
400 self.bit(false)
401 }
402 #[doc = r" Writes raw bits to the field"]
403 #[inline]
404 pub fn bit(self, value: bool) -> &'a mut W {
405 const MASK: bool = true;
406 const OFFSET: u8 = 31;
407 self.w.bits &= !((MASK as u32) << OFFSET);
408 self.w.bits |= ((value & MASK) as u32) << OFFSET;
409 self.w
410 }
411}
412impl R {
413 #[doc = r" Value of the register as raw bits"]
414 #[inline]
415 pub fn bits(&self) -> u32 {
416 self.bits
417 }
418 #[doc = "Bits 0:11 - Bus timeout A"]
419 #[inline]
420 pub fn timeouta(&self) -> TIMEOUTAR {
421 let bits = {
422 const MASK: u16 = 4095;
423 const OFFSET: u8 = 0;
424 ((self.bits >> OFFSET) & MASK as u32) as u16
425 };
426 TIMEOUTAR { bits }
427 }
428 #[doc = "Bit 12 - Idle clock timeout detection"]
429 #[inline]
430 pub fn tidle(&self) -> TIDLER {
431 TIDLER::_from({
432 const MASK: bool = true;
433 const OFFSET: u8 = 12;
434 ((self.bits >> OFFSET) & MASK as u32) != 0
435 })
436 }
437 #[doc = "Bit 15 - Clock timeout enable"]
438 #[inline]
439 pub fn timouten(&self) -> TIMOUTENR {
440 TIMOUTENR::_from({
441 const MASK: bool = true;
442 const OFFSET: u8 = 15;
443 ((self.bits >> OFFSET) & MASK as u32) != 0
444 })
445 }
446 #[doc = "Bits 16:27 - Bus timeout B"]
447 #[inline]
448 pub fn timeoutb(&self) -> TIMEOUTBR {
449 let bits = {
450 const MASK: u16 = 4095;
451 const OFFSET: u8 = 16;
452 ((self.bits >> OFFSET) & MASK as u32) as u16
453 };
454 TIMEOUTBR { bits }
455 }
456 #[doc = "Bit 31 - Extended clock timeout enable"]
457 #[inline]
458 pub fn texten(&self) -> TEXTENR {
459 TEXTENR::_from({
460 const MASK: bool = true;
461 const OFFSET: u8 = 31;
462 ((self.bits >> OFFSET) & MASK as u32) != 0
463 })
464 }
465}
466impl W {
467 #[doc = r" Reset value of the register"]
468 #[inline]
469 pub fn reset_value() -> W {
470 W { bits: 0 }
471 }
472 #[doc = r" Writes raw bits to the register"]
473 #[inline]
474 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
475 self.bits = bits;
476 self
477 }
478 #[doc = "Bits 0:11 - Bus timeout A"]
479 #[inline]
480 pub fn timeouta(&mut self) -> _TIMEOUTAW {
481 _TIMEOUTAW { w: self }
482 }
483 #[doc = "Bit 12 - Idle clock timeout detection"]
484 #[inline]
485 pub fn tidle(&mut self) -> _TIDLEW {
486 _TIDLEW { w: self }
487 }
488 #[doc = "Bit 15 - Clock timeout enable"]
489 #[inline]
490 pub fn timouten(&mut self) -> _TIMOUTENW {
491 _TIMOUTENW { w: self }
492 }
493 #[doc = "Bits 16:27 - Bus timeout B"]
494 #[inline]
495 pub fn timeoutb(&mut self) -> _TIMEOUTBW {
496 _TIMEOUTBW { w: self }
497 }
498 #[doc = "Bit 31 - Extended clock timeout enable"]
499 #[inline]
500 pub fn texten(&mut self) -> _TEXTENW {
501 _TEXTENW { w: self }
502 }
503}