stm32l0x1/i2c1/isr/
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::ISR {
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 ADDCODER {
47    bits: u8,
48}
49impl ADDCODER {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u8 {
53        self.bits
54    }
55}
56#[doc = r" Value of the field"]
57pub struct DIRR {
58    bits: bool,
59}
60impl DIRR {
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 BUSYR {
79    bits: bool,
80}
81impl BUSYR {
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 ALERTR {
100    bits: bool,
101}
102impl ALERTR {
103    #[doc = r" Value of the field as raw bits"]
104    #[inline]
105    pub fn bit(&self) -> bool {
106        self.bits
107    }
108    #[doc = r" Returns `true` if the bit is clear (0)"]
109    #[inline]
110    pub fn bit_is_clear(&self) -> bool {
111        !self.bit()
112    }
113    #[doc = r" Returns `true` if the bit is set (1)"]
114    #[inline]
115    pub fn bit_is_set(&self) -> bool {
116        self.bit()
117    }
118}
119#[doc = r" Value of the field"]
120pub struct TIMEOUTR {
121    bits: bool,
122}
123impl TIMEOUTR {
124    #[doc = r" Value of the field as raw bits"]
125    #[inline]
126    pub fn bit(&self) -> bool {
127        self.bits
128    }
129    #[doc = r" Returns `true` if the bit is clear (0)"]
130    #[inline]
131    pub fn bit_is_clear(&self) -> bool {
132        !self.bit()
133    }
134    #[doc = r" Returns `true` if the bit is set (1)"]
135    #[inline]
136    pub fn bit_is_set(&self) -> bool {
137        self.bit()
138    }
139}
140#[doc = r" Value of the field"]
141pub struct PECERRR {
142    bits: bool,
143}
144impl PECERRR {
145    #[doc = r" Value of the field as raw bits"]
146    #[inline]
147    pub fn bit(&self) -> bool {
148        self.bits
149    }
150    #[doc = r" Returns `true` if the bit is clear (0)"]
151    #[inline]
152    pub fn bit_is_clear(&self) -> bool {
153        !self.bit()
154    }
155    #[doc = r" Returns `true` if the bit is set (1)"]
156    #[inline]
157    pub fn bit_is_set(&self) -> bool {
158        self.bit()
159    }
160}
161#[doc = r" Value of the field"]
162pub struct OVRR {
163    bits: bool,
164}
165impl OVRR {
166    #[doc = r" Value of the field as raw bits"]
167    #[inline]
168    pub fn bit(&self) -> bool {
169        self.bits
170    }
171    #[doc = r" Returns `true` if the bit is clear (0)"]
172    #[inline]
173    pub fn bit_is_clear(&self) -> bool {
174        !self.bit()
175    }
176    #[doc = r" Returns `true` if the bit is set (1)"]
177    #[inline]
178    pub fn bit_is_set(&self) -> bool {
179        self.bit()
180    }
181}
182#[doc = r" Value of the field"]
183pub struct ARLOR {
184    bits: bool,
185}
186impl ARLOR {
187    #[doc = r" Value of the field as raw bits"]
188    #[inline]
189    pub fn bit(&self) -> bool {
190        self.bits
191    }
192    #[doc = r" Returns `true` if the bit is clear (0)"]
193    #[inline]
194    pub fn bit_is_clear(&self) -> bool {
195        !self.bit()
196    }
197    #[doc = r" Returns `true` if the bit is set (1)"]
198    #[inline]
199    pub fn bit_is_set(&self) -> bool {
200        self.bit()
201    }
202}
203#[doc = r" Value of the field"]
204pub struct BERRR {
205    bits: bool,
206}
207impl BERRR {
208    #[doc = r" Value of the field as raw bits"]
209    #[inline]
210    pub fn bit(&self) -> bool {
211        self.bits
212    }
213    #[doc = r" Returns `true` if the bit is clear (0)"]
214    #[inline]
215    pub fn bit_is_clear(&self) -> bool {
216        !self.bit()
217    }
218    #[doc = r" Returns `true` if the bit is set (1)"]
219    #[inline]
220    pub fn bit_is_set(&self) -> bool {
221        self.bit()
222    }
223}
224#[doc = r" Value of the field"]
225pub struct TCRR {
226    bits: bool,
227}
228impl TCRR {
229    #[doc = r" Value of the field as raw bits"]
230    #[inline]
231    pub fn bit(&self) -> bool {
232        self.bits
233    }
234    #[doc = r" Returns `true` if the bit is clear (0)"]
235    #[inline]
236    pub fn bit_is_clear(&self) -> bool {
237        !self.bit()
238    }
239    #[doc = r" Returns `true` if the bit is set (1)"]
240    #[inline]
241    pub fn bit_is_set(&self) -> bool {
242        self.bit()
243    }
244}
245#[doc = r" Value of the field"]
246pub struct TCR {
247    bits: bool,
248}
249impl TCR {
250    #[doc = r" Value of the field as raw bits"]
251    #[inline]
252    pub fn bit(&self) -> bool {
253        self.bits
254    }
255    #[doc = r" Returns `true` if the bit is clear (0)"]
256    #[inline]
257    pub fn bit_is_clear(&self) -> bool {
258        !self.bit()
259    }
260    #[doc = r" Returns `true` if the bit is set (1)"]
261    #[inline]
262    pub fn bit_is_set(&self) -> bool {
263        self.bit()
264    }
265}
266#[doc = r" Value of the field"]
267pub struct STOPFR {
268    bits: bool,
269}
270impl STOPFR {
271    #[doc = r" Value of the field as raw bits"]
272    #[inline]
273    pub fn bit(&self) -> bool {
274        self.bits
275    }
276    #[doc = r" Returns `true` if the bit is clear (0)"]
277    #[inline]
278    pub fn bit_is_clear(&self) -> bool {
279        !self.bit()
280    }
281    #[doc = r" Returns `true` if the bit is set (1)"]
282    #[inline]
283    pub fn bit_is_set(&self) -> bool {
284        self.bit()
285    }
286}
287#[doc = r" Value of the field"]
288pub struct NACKFR {
289    bits: bool,
290}
291impl NACKFR {
292    #[doc = r" Value of the field as raw bits"]
293    #[inline]
294    pub fn bit(&self) -> bool {
295        self.bits
296    }
297    #[doc = r" Returns `true` if the bit is clear (0)"]
298    #[inline]
299    pub fn bit_is_clear(&self) -> bool {
300        !self.bit()
301    }
302    #[doc = r" Returns `true` if the bit is set (1)"]
303    #[inline]
304    pub fn bit_is_set(&self) -> bool {
305        self.bit()
306    }
307}
308#[doc = r" Value of the field"]
309pub struct ADDRR {
310    bits: bool,
311}
312impl ADDRR {
313    #[doc = r" Value of the field as raw bits"]
314    #[inline]
315    pub fn bit(&self) -> bool {
316        self.bits
317    }
318    #[doc = r" Returns `true` if the bit is clear (0)"]
319    #[inline]
320    pub fn bit_is_clear(&self) -> bool {
321        !self.bit()
322    }
323    #[doc = r" Returns `true` if the bit is set (1)"]
324    #[inline]
325    pub fn bit_is_set(&self) -> bool {
326        self.bit()
327    }
328}
329#[doc = r" Value of the field"]
330pub struct RXNER {
331    bits: bool,
332}
333impl RXNER {
334    #[doc = r" Value of the field as raw bits"]
335    #[inline]
336    pub fn bit(&self) -> bool {
337        self.bits
338    }
339    #[doc = r" Returns `true` if the bit is clear (0)"]
340    #[inline]
341    pub fn bit_is_clear(&self) -> bool {
342        !self.bit()
343    }
344    #[doc = r" Returns `true` if the bit is set (1)"]
345    #[inline]
346    pub fn bit_is_set(&self) -> bool {
347        self.bit()
348    }
349}
350#[doc = r" Value of the field"]
351pub struct TXISR {
352    bits: bool,
353}
354impl TXISR {
355    #[doc = r" Value of the field as raw bits"]
356    #[inline]
357    pub fn bit(&self) -> bool {
358        self.bits
359    }
360    #[doc = r" Returns `true` if the bit is clear (0)"]
361    #[inline]
362    pub fn bit_is_clear(&self) -> bool {
363        !self.bit()
364    }
365    #[doc = r" Returns `true` if the bit is set (1)"]
366    #[inline]
367    pub fn bit_is_set(&self) -> bool {
368        self.bit()
369    }
370}
371#[doc = r" Value of the field"]
372pub struct TXER {
373    bits: bool,
374}
375impl TXER {
376    #[doc = r" Value of the field as raw bits"]
377    #[inline]
378    pub fn bit(&self) -> bool {
379        self.bits
380    }
381    #[doc = r" Returns `true` if the bit is clear (0)"]
382    #[inline]
383    pub fn bit_is_clear(&self) -> bool {
384        !self.bit()
385    }
386    #[doc = r" Returns `true` if the bit is set (1)"]
387    #[inline]
388    pub fn bit_is_set(&self) -> bool {
389        self.bit()
390    }
391}
392#[doc = r" Proxy"]
393pub struct _TXISW<'a> {
394    w: &'a mut W,
395}
396impl<'a> _TXISW<'a> {
397    #[doc = r" Sets the field bit"]
398    pub fn set_bit(self) -> &'a mut W {
399        self.bit(true)
400    }
401    #[doc = r" Clears the field bit"]
402    pub fn clear_bit(self) -> &'a mut W {
403        self.bit(false)
404    }
405    #[doc = r" Writes raw bits to the field"]
406    #[inline]
407    pub fn bit(self, value: bool) -> &'a mut W {
408        const MASK: bool = true;
409        const OFFSET: u8 = 1;
410        self.w.bits &= !((MASK as u32) << OFFSET);
411        self.w.bits |= ((value & MASK) as u32) << OFFSET;
412        self.w
413    }
414}
415#[doc = r" Proxy"]
416pub struct _TXEW<'a> {
417    w: &'a mut W,
418}
419impl<'a> _TXEW<'a> {
420    #[doc = r" Sets the field bit"]
421    pub fn set_bit(self) -> &'a mut W {
422        self.bit(true)
423    }
424    #[doc = r" Clears the field bit"]
425    pub fn clear_bit(self) -> &'a mut W {
426        self.bit(false)
427    }
428    #[doc = r" Writes raw bits to the field"]
429    #[inline]
430    pub fn bit(self, value: bool) -> &'a mut W {
431        const MASK: bool = true;
432        const OFFSET: u8 = 0;
433        self.w.bits &= !((MASK as u32) << OFFSET);
434        self.w.bits |= ((value & MASK) as u32) << OFFSET;
435        self.w
436    }
437}
438impl R {
439    #[doc = r" Value of the register as raw bits"]
440    #[inline]
441    pub fn bits(&self) -> u32 {
442        self.bits
443    }
444    #[doc = "Bits 17:23 - Address match code (Slave mode)"]
445    #[inline]
446    pub fn addcode(&self) -> ADDCODER {
447        let bits = {
448            const MASK: u8 = 127;
449            const OFFSET: u8 = 17;
450            ((self.bits >> OFFSET) & MASK as u32) as u8
451        };
452        ADDCODER { bits }
453    }
454    #[doc = "Bit 16 - Transfer direction (Slave mode)"]
455    #[inline]
456    pub fn dir(&self) -> DIRR {
457        let bits = {
458            const MASK: bool = true;
459            const OFFSET: u8 = 16;
460            ((self.bits >> OFFSET) & MASK as u32) != 0
461        };
462        DIRR { bits }
463    }
464    #[doc = "Bit 15 - Bus busy"]
465    #[inline]
466    pub fn busy(&self) -> BUSYR {
467        let bits = {
468            const MASK: bool = true;
469            const OFFSET: u8 = 15;
470            ((self.bits >> OFFSET) & MASK as u32) != 0
471        };
472        BUSYR { bits }
473    }
474    #[doc = "Bit 13 - SMBus alert"]
475    #[inline]
476    pub fn alert(&self) -> ALERTR {
477        let bits = {
478            const MASK: bool = true;
479            const OFFSET: u8 = 13;
480            ((self.bits >> OFFSET) & MASK as u32) != 0
481        };
482        ALERTR { bits }
483    }
484    #[doc = "Bit 12 - Timeout or t_low detection flag"]
485    #[inline]
486    pub fn timeout(&self) -> TIMEOUTR {
487        let bits = {
488            const MASK: bool = true;
489            const OFFSET: u8 = 12;
490            ((self.bits >> OFFSET) & MASK as u32) != 0
491        };
492        TIMEOUTR { bits }
493    }
494    #[doc = "Bit 11 - PEC Error in reception"]
495    #[inline]
496    pub fn pecerr(&self) -> PECERRR {
497        let bits = {
498            const MASK: bool = true;
499            const OFFSET: u8 = 11;
500            ((self.bits >> OFFSET) & MASK as u32) != 0
501        };
502        PECERRR { bits }
503    }
504    #[doc = "Bit 10 - Overrun/Underrun (slave mode)"]
505    #[inline]
506    pub fn ovr(&self) -> OVRR {
507        let bits = {
508            const MASK: bool = true;
509            const OFFSET: u8 = 10;
510            ((self.bits >> OFFSET) & MASK as u32) != 0
511        };
512        OVRR { bits }
513    }
514    #[doc = "Bit 9 - Arbitration lost"]
515    #[inline]
516    pub fn arlo(&self) -> ARLOR {
517        let bits = {
518            const MASK: bool = true;
519            const OFFSET: u8 = 9;
520            ((self.bits >> OFFSET) & MASK as u32) != 0
521        };
522        ARLOR { bits }
523    }
524    #[doc = "Bit 8 - Bus error"]
525    #[inline]
526    pub fn berr(&self) -> BERRR {
527        let bits = {
528            const MASK: bool = true;
529            const OFFSET: u8 = 8;
530            ((self.bits >> OFFSET) & MASK as u32) != 0
531        };
532        BERRR { bits }
533    }
534    #[doc = "Bit 7 - Transfer Complete Reload"]
535    #[inline]
536    pub fn tcr(&self) -> TCRR {
537        let bits = {
538            const MASK: bool = true;
539            const OFFSET: u8 = 7;
540            ((self.bits >> OFFSET) & MASK as u32) != 0
541        };
542        TCRR { bits }
543    }
544    #[doc = "Bit 6 - Transfer Complete (master mode)"]
545    #[inline]
546    pub fn tc(&self) -> TCR {
547        let bits = {
548            const MASK: bool = true;
549            const OFFSET: u8 = 6;
550            ((self.bits >> OFFSET) & MASK as u32) != 0
551        };
552        TCR { bits }
553    }
554    #[doc = "Bit 5 - Stop detection flag"]
555    #[inline]
556    pub fn stopf(&self) -> STOPFR {
557        let bits = {
558            const MASK: bool = true;
559            const OFFSET: u8 = 5;
560            ((self.bits >> OFFSET) & MASK as u32) != 0
561        };
562        STOPFR { bits }
563    }
564    #[doc = "Bit 4 - Not acknowledge received flag"]
565    #[inline]
566    pub fn nackf(&self) -> NACKFR {
567        let bits = {
568            const MASK: bool = true;
569            const OFFSET: u8 = 4;
570            ((self.bits >> OFFSET) & MASK as u32) != 0
571        };
572        NACKFR { bits }
573    }
574    #[doc = "Bit 3 - Address matched (slave mode)"]
575    #[inline]
576    pub fn addr(&self) -> ADDRR {
577        let bits = {
578            const MASK: bool = true;
579            const OFFSET: u8 = 3;
580            ((self.bits >> OFFSET) & MASK as u32) != 0
581        };
582        ADDRR { bits }
583    }
584    #[doc = "Bit 2 - Receive data register not empty (receivers)"]
585    #[inline]
586    pub fn rxne(&self) -> RXNER {
587        let bits = {
588            const MASK: bool = true;
589            const OFFSET: u8 = 2;
590            ((self.bits >> OFFSET) & MASK as u32) != 0
591        };
592        RXNER { bits }
593    }
594    #[doc = "Bit 1 - Transmit interrupt status (transmitters)"]
595    #[inline]
596    pub fn txis(&self) -> TXISR {
597        let bits = {
598            const MASK: bool = true;
599            const OFFSET: u8 = 1;
600            ((self.bits >> OFFSET) & MASK as u32) != 0
601        };
602        TXISR { bits }
603    }
604    #[doc = "Bit 0 - Transmit data register empty (transmitters)"]
605    #[inline]
606    pub fn txe(&self) -> TXER {
607        let bits = {
608            const MASK: bool = true;
609            const OFFSET: u8 = 0;
610            ((self.bits >> OFFSET) & MASK as u32) != 0
611        };
612        TXER { bits }
613    }
614}
615impl W {
616    #[doc = r" Reset value of the register"]
617    #[inline]
618    pub fn reset_value() -> W {
619        W { bits: 1 }
620    }
621    #[doc = r" Writes raw bits to the register"]
622    #[inline]
623    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
624        self.bits = bits;
625        self
626    }
627    #[doc = "Bit 1 - Transmit interrupt status (transmitters)"]
628    #[inline]
629    pub fn txis(&mut self) -> _TXISW {
630        _TXISW { w: self }
631    }
632    #[doc = "Bit 0 - Transmit data register empty (transmitters)"]
633    #[inline]
634    pub fn txe(&mut self) -> _TXEW {
635        _TXEW { w: self }
636    }
637}