py32f0/py32f003/i2c/
sr1.rs

1///Register `SR1` reader
2pub struct R(crate::R<SR1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SR1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SR1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SR1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `SR1` writer
17pub struct W(crate::W<SR1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SR1_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<SR1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SR1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `SB` reader - Start bit (Master mode)
38pub type SB_R = crate::BitReader<SB_A>;
39/**Start bit (Master mode)
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum SB_A {
44    ///0: No Start condition
45    NoStart = 0,
46    ///1: Start condition generated
47    Start = 1,
48}
49impl From<SB_A> for bool {
50    #[inline(always)]
51    fn from(variant: SB_A) -> Self {
52        variant as u8 != 0
53    }
54}
55impl SB_R {
56    ///Get enumerated values variant
57    #[inline(always)]
58    pub fn variant(&self) -> SB_A {
59        match self.bits {
60            false => SB_A::NoStart,
61            true => SB_A::Start,
62        }
63    }
64    ///Checks if the value of the field is `NoStart`
65    #[inline(always)]
66    pub fn is_no_start(&self) -> bool {
67        *self == SB_A::NoStart
68    }
69    ///Checks if the value of the field is `Start`
70    #[inline(always)]
71    pub fn is_start(&self) -> bool {
72        *self == SB_A::Start
73    }
74}
75///Field `ADDR` reader - Address sent (master mode)/matched (slave mode)
76pub type ADDR_R = crate::BitReader<ADDR_A>;
77/**Address sent (master mode)/matched (slave mode)
78
79Value on reset: 0*/
80#[derive(Clone, Copy, Debug, PartialEq, Eq)]
81pub enum ADDR_A {
82    ///0: Adress mismatched or not received
83    NotMatch = 0,
84    ///1: Received slave address matched with one of the enabled slave addresses
85    Match = 1,
86}
87impl From<ADDR_A> for bool {
88    #[inline(always)]
89    fn from(variant: ADDR_A) -> Self {
90        variant as u8 != 0
91    }
92}
93impl ADDR_R {
94    ///Get enumerated values variant
95    #[inline(always)]
96    pub fn variant(&self) -> ADDR_A {
97        match self.bits {
98            false => ADDR_A::NotMatch,
99            true => ADDR_A::Match,
100        }
101    }
102    ///Checks if the value of the field is `NotMatch`
103    #[inline(always)]
104    pub fn is_not_match(&self) -> bool {
105        *self == ADDR_A::NotMatch
106    }
107    ///Checks if the value of the field is `Match`
108    #[inline(always)]
109    pub fn is_match(&self) -> bool {
110        *self == ADDR_A::Match
111    }
112}
113///Field `BTF` reader - Byte transfer finished
114pub type BTF_R = crate::BitReader<BTF_A>;
115/**Byte transfer finished
116
117Value on reset: 0*/
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum BTF_A {
120    ///0: Data byte transfer not done
121    NotFinished = 0,
122    ///1: Data byte transfer successful
123    Finished = 1,
124}
125impl From<BTF_A> for bool {
126    #[inline(always)]
127    fn from(variant: BTF_A) -> Self {
128        variant as u8 != 0
129    }
130}
131impl BTF_R {
132    ///Get enumerated values variant
133    #[inline(always)]
134    pub fn variant(&self) -> BTF_A {
135        match self.bits {
136            false => BTF_A::NotFinished,
137            true => BTF_A::Finished,
138        }
139    }
140    ///Checks if the value of the field is `NotFinished`
141    #[inline(always)]
142    pub fn is_not_finished(&self) -> bool {
143        *self == BTF_A::NotFinished
144    }
145    ///Checks if the value of the field is `Finished`
146    #[inline(always)]
147    pub fn is_finished(&self) -> bool {
148        *self == BTF_A::Finished
149    }
150}
151///Field `STOPF` reader - Stop detection (slave mode)
152pub type STOPF_R = crate::BitReader<STOPF_A>;
153/**Stop detection (slave mode)
154
155Value on reset: 0*/
156#[derive(Clone, Copy, Debug, PartialEq, Eq)]
157pub enum STOPF_A {
158    ///0: No Stop condition detected
159    NoStop = 0,
160    ///1: Stop condition detected
161    Stop = 1,
162}
163impl From<STOPF_A> for bool {
164    #[inline(always)]
165    fn from(variant: STOPF_A) -> Self {
166        variant as u8 != 0
167    }
168}
169impl STOPF_R {
170    ///Get enumerated values variant
171    #[inline(always)]
172    pub fn variant(&self) -> STOPF_A {
173        match self.bits {
174            false => STOPF_A::NoStop,
175            true => STOPF_A::Stop,
176        }
177    }
178    ///Checks if the value of the field is `NoStop`
179    #[inline(always)]
180    pub fn is_no_stop(&self) -> bool {
181        *self == STOPF_A::NoStop
182    }
183    ///Checks if the value of the field is `Stop`
184    #[inline(always)]
185    pub fn is_stop(&self) -> bool {
186        *self == STOPF_A::Stop
187    }
188}
189///Field `RXNE` reader - Data register not empty (receivers)
190pub type RXNE_R = crate::BitReader<RXNE_A>;
191/**Data register not empty (receivers)
192
193Value on reset: 0*/
194#[derive(Clone, Copy, Debug, PartialEq, Eq)]
195pub enum RXNE_A {
196    ///0: Data register empty
197    Empty = 0,
198    ///1: Data register not empty
199    NotEmpty = 1,
200}
201impl From<RXNE_A> for bool {
202    #[inline(always)]
203    fn from(variant: RXNE_A) -> Self {
204        variant as u8 != 0
205    }
206}
207impl RXNE_R {
208    ///Get enumerated values variant
209    #[inline(always)]
210    pub fn variant(&self) -> RXNE_A {
211        match self.bits {
212            false => RXNE_A::Empty,
213            true => RXNE_A::NotEmpty,
214        }
215    }
216    ///Checks if the value of the field is `Empty`
217    #[inline(always)]
218    pub fn is_empty(&self) -> bool {
219        *self == RXNE_A::Empty
220    }
221    ///Checks if the value of the field is `NotEmpty`
222    #[inline(always)]
223    pub fn is_not_empty(&self) -> bool {
224        *self == RXNE_A::NotEmpty
225    }
226}
227///Field `TXE` reader - Data register empty (transmitters)
228pub type TXE_R = crate::BitReader<TXE_A>;
229/**Data register empty (transmitters)
230
231Value on reset: 0*/
232#[derive(Clone, Copy, Debug, PartialEq, Eq)]
233pub enum TXE_A {
234    ///0: Data register not empty
235    NotEmpty = 0,
236    ///1: Data register empty
237    Empty = 1,
238}
239impl From<TXE_A> for bool {
240    #[inline(always)]
241    fn from(variant: TXE_A) -> Self {
242        variant as u8 != 0
243    }
244}
245impl TXE_R {
246    ///Get enumerated values variant
247    #[inline(always)]
248    pub fn variant(&self) -> TXE_A {
249        match self.bits {
250            false => TXE_A::NotEmpty,
251            true => TXE_A::Empty,
252        }
253    }
254    ///Checks if the value of the field is `NotEmpty`
255    #[inline(always)]
256    pub fn is_not_empty(&self) -> bool {
257        *self == TXE_A::NotEmpty
258    }
259    ///Checks if the value of the field is `Empty`
260    #[inline(always)]
261    pub fn is_empty(&self) -> bool {
262        *self == TXE_A::Empty
263    }
264}
265///Field `BERR` reader - Bus error
266pub type BERR_R = crate::BitReader<BERRR_A>;
267/**Bus error
268
269Value on reset: 0*/
270#[derive(Clone, Copy, Debug, PartialEq, Eq)]
271pub enum BERRR_A {
272    ///0: No misplaced Start or Stop condition
273    NoError = 0,
274    ///1: Misplaced Start or Stop condition
275    Error = 1,
276}
277impl From<BERRR_A> for bool {
278    #[inline(always)]
279    fn from(variant: BERRR_A) -> Self {
280        variant as u8 != 0
281    }
282}
283impl BERR_R {
284    ///Get enumerated values variant
285    #[inline(always)]
286    pub fn variant(&self) -> BERRR_A {
287        match self.bits {
288            false => BERRR_A::NoError,
289            true => BERRR_A::Error,
290        }
291    }
292    ///Checks if the value of the field is `NoError`
293    #[inline(always)]
294    pub fn is_no_error(&self) -> bool {
295        *self == BERRR_A::NoError
296    }
297    ///Checks if the value of the field is `Error`
298    #[inline(always)]
299    pub fn is_error(&self) -> bool {
300        *self == BERRR_A::Error
301    }
302}
303/**Bus error
304
305Value on reset: 0*/
306#[derive(Clone, Copy, Debug, PartialEq, Eq)]
307pub enum BERRW_AW {
308    ///0: Clear flag
309    Clear = 0,
310}
311impl From<BERRW_AW> for bool {
312    #[inline(always)]
313    fn from(variant: BERRW_AW) -> Self {
314        variant as u8 != 0
315    }
316}
317///Field `BERR` writer - Bus error
318pub type BERR_W<'a, const O: u8> = crate::BitWriter0C<'a, u32, SR1_SPEC, BERRW_AW, O>;
319impl<'a, const O: u8> BERR_W<'a, O> {
320    ///Clear flag
321    #[inline(always)]
322    pub fn clear(self) -> &'a mut W {
323        self.variant(BERRW_AW::Clear)
324    }
325}
326///Field `ARLO` reader - Arbitration lost (master mode)
327pub type ARLO_R = crate::BitReader<ARLOR_A>;
328/**Arbitration lost (master mode)
329
330Value on reset: 0*/
331#[derive(Clone, Copy, Debug, PartialEq, Eq)]
332pub enum ARLOR_A {
333    ///0: No Arbitration Lost detected
334    NoLost = 0,
335    ///1: Arbitration Lost detected
336    Lost = 1,
337}
338impl From<ARLOR_A> for bool {
339    #[inline(always)]
340    fn from(variant: ARLOR_A) -> Self {
341        variant as u8 != 0
342    }
343}
344impl ARLO_R {
345    ///Get enumerated values variant
346    #[inline(always)]
347    pub fn variant(&self) -> ARLOR_A {
348        match self.bits {
349            false => ARLOR_A::NoLost,
350            true => ARLOR_A::Lost,
351        }
352    }
353    ///Checks if the value of the field is `NoLost`
354    #[inline(always)]
355    pub fn is_no_lost(&self) -> bool {
356        *self == ARLOR_A::NoLost
357    }
358    ///Checks if the value of the field is `Lost`
359    #[inline(always)]
360    pub fn is_lost(&self) -> bool {
361        *self == ARLOR_A::Lost
362    }
363}
364/**Arbitration lost (master mode)
365
366Value on reset: 0*/
367#[derive(Clone, Copy, Debug, PartialEq, Eq)]
368pub enum ARLOW_AW {
369    ///0: Clear flag
370    Clear = 0,
371}
372impl From<ARLOW_AW> for bool {
373    #[inline(always)]
374    fn from(variant: ARLOW_AW) -> Self {
375        variant as u8 != 0
376    }
377}
378///Field `ARLO` writer - Arbitration lost (master mode)
379pub type ARLO_W<'a, const O: u8> = crate::BitWriter0C<'a, u32, SR1_SPEC, ARLOW_AW, O>;
380impl<'a, const O: u8> ARLO_W<'a, O> {
381    ///Clear flag
382    #[inline(always)]
383    pub fn clear(self) -> &'a mut W {
384        self.variant(ARLOW_AW::Clear)
385    }
386}
387///Field `AF` reader - Acknowledge failure
388pub type AF_R = crate::BitReader<AFR_A>;
389/**Acknowledge failure
390
391Value on reset: 0*/
392#[derive(Clone, Copy, Debug, PartialEq, Eq)]
393pub enum AFR_A {
394    ///0: No acknowledge failure
395    NoFailure = 0,
396    ///1: Acknowledge failure
397    Failure = 1,
398}
399impl From<AFR_A> for bool {
400    #[inline(always)]
401    fn from(variant: AFR_A) -> Self {
402        variant as u8 != 0
403    }
404}
405impl AF_R {
406    ///Get enumerated values variant
407    #[inline(always)]
408    pub fn variant(&self) -> AFR_A {
409        match self.bits {
410            false => AFR_A::NoFailure,
411            true => AFR_A::Failure,
412        }
413    }
414    ///Checks if the value of the field is `NoFailure`
415    #[inline(always)]
416    pub fn is_no_failure(&self) -> bool {
417        *self == AFR_A::NoFailure
418    }
419    ///Checks if the value of the field is `Failure`
420    #[inline(always)]
421    pub fn is_failure(&self) -> bool {
422        *self == AFR_A::Failure
423    }
424}
425/**Acknowledge failure
426
427Value on reset: 0*/
428#[derive(Clone, Copy, Debug, PartialEq, Eq)]
429pub enum AFW_AW {
430    ///0: Clear flag
431    Clear = 0,
432}
433impl From<AFW_AW> for bool {
434    #[inline(always)]
435    fn from(variant: AFW_AW) -> Self {
436        variant as u8 != 0
437    }
438}
439///Field `AF` writer - Acknowledge failure
440pub type AF_W<'a, const O: u8> = crate::BitWriter0C<'a, u32, SR1_SPEC, AFW_AW, O>;
441impl<'a, const O: u8> AF_W<'a, O> {
442    ///Clear flag
443    #[inline(always)]
444    pub fn clear(self) -> &'a mut W {
445        self.variant(AFW_AW::Clear)
446    }
447}
448///Field `OVR` reader - Overrun/Underrun
449pub type OVR_R = crate::BitReader<OVRR_A>;
450/**Overrun/Underrun
451
452Value on reset: 0*/
453#[derive(Clone, Copy, Debug, PartialEq, Eq)]
454pub enum OVRR_A {
455    ///0: No overrun/underrun occured
456    NoOverrun = 0,
457    ///1: Overrun/underrun occured
458    Overrun = 1,
459}
460impl From<OVRR_A> for bool {
461    #[inline(always)]
462    fn from(variant: OVRR_A) -> Self {
463        variant as u8 != 0
464    }
465}
466impl OVR_R {
467    ///Get enumerated values variant
468    #[inline(always)]
469    pub fn variant(&self) -> OVRR_A {
470        match self.bits {
471            false => OVRR_A::NoOverrun,
472            true => OVRR_A::Overrun,
473        }
474    }
475    ///Checks if the value of the field is `NoOverrun`
476    #[inline(always)]
477    pub fn is_no_overrun(&self) -> bool {
478        *self == OVRR_A::NoOverrun
479    }
480    ///Checks if the value of the field is `Overrun`
481    #[inline(always)]
482    pub fn is_overrun(&self) -> bool {
483        *self == OVRR_A::Overrun
484    }
485}
486/**Overrun/Underrun
487
488Value on reset: 0*/
489#[derive(Clone, Copy, Debug, PartialEq, Eq)]
490pub enum OVRW_AW {
491    ///0: Clear flag
492    Clear = 0,
493}
494impl From<OVRW_AW> for bool {
495    #[inline(always)]
496    fn from(variant: OVRW_AW) -> Self {
497        variant as u8 != 0
498    }
499}
500///Field `OVR` writer - Overrun/Underrun
501pub type OVR_W<'a, const O: u8> = crate::BitWriter0C<'a, u32, SR1_SPEC, OVRW_AW, O>;
502impl<'a, const O: u8> OVR_W<'a, O> {
503    ///Clear flag
504    #[inline(always)]
505    pub fn clear(self) -> &'a mut W {
506        self.variant(OVRW_AW::Clear)
507    }
508}
509///Field `PECERR` reader - PEC Error in reception
510pub type PECERR_R = crate::BitReader<PECERRR_A>;
511/**PEC Error in reception
512
513Value on reset: 0*/
514#[derive(Clone, Copy, Debug, PartialEq, Eq)]
515pub enum PECERRR_A {
516    ///0: no PEC error: receiver returns ACK after PEC reception (if ACK=1)
517    NoError = 0,
518    ///1: PEC error: receiver returns NACK after PEC reception (whatever ACK)
519    Error = 1,
520}
521impl From<PECERRR_A> for bool {
522    #[inline(always)]
523    fn from(variant: PECERRR_A) -> Self {
524        variant as u8 != 0
525    }
526}
527impl PECERR_R {
528    ///Get enumerated values variant
529    #[inline(always)]
530    pub fn variant(&self) -> PECERRR_A {
531        match self.bits {
532            false => PECERRR_A::NoError,
533            true => PECERRR_A::Error,
534        }
535    }
536    ///Checks if the value of the field is `NoError`
537    #[inline(always)]
538    pub fn is_no_error(&self) -> bool {
539        *self == PECERRR_A::NoError
540    }
541    ///Checks if the value of the field is `Error`
542    #[inline(always)]
543    pub fn is_error(&self) -> bool {
544        *self == PECERRR_A::Error
545    }
546}
547/**PEC Error in reception
548
549Value on reset: 0*/
550#[derive(Clone, Copy, Debug, PartialEq, Eq)]
551pub enum PECERRW_AW {
552    ///0: Clear flag
553    Clear = 0,
554}
555impl From<PECERRW_AW> for bool {
556    #[inline(always)]
557    fn from(variant: PECERRW_AW) -> Self {
558        variant as u8 != 0
559    }
560}
561///Field `PECERR` writer - PEC Error in reception
562pub type PECERR_W<'a, const O: u8> = crate::BitWriter0C<'a, u32, SR1_SPEC, PECERRW_AW, O>;
563impl<'a, const O: u8> PECERR_W<'a, O> {
564    ///Clear flag
565    #[inline(always)]
566    pub fn clear(self) -> &'a mut W {
567        self.variant(PECERRW_AW::Clear)
568    }
569}
570impl R {
571    ///Bit 0 - Start bit (Master mode)
572    #[inline(always)]
573    pub fn sb(&self) -> SB_R {
574        SB_R::new((self.bits & 1) != 0)
575    }
576    ///Bit 1 - Address sent (master mode)/matched (slave mode)
577    #[inline(always)]
578    pub fn addr(&self) -> ADDR_R {
579        ADDR_R::new(((self.bits >> 1) & 1) != 0)
580    }
581    ///Bit 2 - Byte transfer finished
582    #[inline(always)]
583    pub fn btf(&self) -> BTF_R {
584        BTF_R::new(((self.bits >> 2) & 1) != 0)
585    }
586    ///Bit 4 - Stop detection (slave mode)
587    #[inline(always)]
588    pub fn stopf(&self) -> STOPF_R {
589        STOPF_R::new(((self.bits >> 4) & 1) != 0)
590    }
591    ///Bit 6 - Data register not empty (receivers)
592    #[inline(always)]
593    pub fn rxne(&self) -> RXNE_R {
594        RXNE_R::new(((self.bits >> 6) & 1) != 0)
595    }
596    ///Bit 7 - Data register empty (transmitters)
597    #[inline(always)]
598    pub fn txe(&self) -> TXE_R {
599        TXE_R::new(((self.bits >> 7) & 1) != 0)
600    }
601    ///Bit 8 - Bus error
602    #[inline(always)]
603    pub fn berr(&self) -> BERR_R {
604        BERR_R::new(((self.bits >> 8) & 1) != 0)
605    }
606    ///Bit 9 - Arbitration lost (master mode)
607    #[inline(always)]
608    pub fn arlo(&self) -> ARLO_R {
609        ARLO_R::new(((self.bits >> 9) & 1) != 0)
610    }
611    ///Bit 10 - Acknowledge failure
612    #[inline(always)]
613    pub fn af(&self) -> AF_R {
614        AF_R::new(((self.bits >> 10) & 1) != 0)
615    }
616    ///Bit 11 - Overrun/Underrun
617    #[inline(always)]
618    pub fn ovr(&self) -> OVR_R {
619        OVR_R::new(((self.bits >> 11) & 1) != 0)
620    }
621    ///Bit 12 - PEC Error in reception
622    #[inline(always)]
623    pub fn pecerr(&self) -> PECERR_R {
624        PECERR_R::new(((self.bits >> 12) & 1) != 0)
625    }
626}
627impl W {
628    ///Bit 8 - Bus error
629    #[inline(always)]
630    #[must_use]
631    pub fn berr(&mut self) -> BERR_W<8> {
632        BERR_W::new(self)
633    }
634    ///Bit 9 - Arbitration lost (master mode)
635    #[inline(always)]
636    #[must_use]
637    pub fn arlo(&mut self) -> ARLO_W<9> {
638        ARLO_W::new(self)
639    }
640    ///Bit 10 - Acknowledge failure
641    #[inline(always)]
642    #[must_use]
643    pub fn af(&mut self) -> AF_W<10> {
644        AF_W::new(self)
645    }
646    ///Bit 11 - Overrun/Underrun
647    #[inline(always)]
648    #[must_use]
649    pub fn ovr(&mut self) -> OVR_W<11> {
650        OVR_W::new(self)
651    }
652    ///Bit 12 - PEC Error in reception
653    #[inline(always)]
654    #[must_use]
655    pub fn pecerr(&mut self) -> PECERR_W<12> {
656        PECERR_W::new(self)
657    }
658    ///Writes raw bits to the register.
659    #[inline(always)]
660    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
661        self.0.bits(bits);
662        self
663    }
664}
665/**Status register 1
666
667This register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
668
669For information about available fields see [sr1](index.html) module*/
670pub struct SR1_SPEC;
671impl crate::RegisterSpec for SR1_SPEC {
672    type Ux = u32;
673}
674///`read()` method returns [sr1::R](R) reader structure
675impl crate::Readable for SR1_SPEC {
676    type Reader = R;
677}
678///`write(|w| ..)` method takes [sr1::W](W) writer structure
679impl crate::Writable for SR1_SPEC {
680    type Writer = W;
681    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0x1f00;
682    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
683}
684///`reset()` method sets SR1 to value 0
685impl crate::Resettable for SR1_SPEC {
686    const RESET_VALUE: Self::Ux = 0;
687}