stm32f1_staging/stm32f102/i2c1/
cr1.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
///Register `CR1` reader
pub type R = crate::R<CR1rs>;
///Register `CR1` writer
pub type W = crate::W<CR1rs>;
/**Peripheral enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PE {
    ///0: Peripheral disabled
    Disabled = 0,
    ///1: Peripheral enabled
    Enabled = 1,
}
impl From<PE> for bool {
    #[inline(always)]
    fn from(variant: PE) -> Self {
        variant as u8 != 0
    }
}
///Field `PE` reader - Peripheral enable
pub type PE_R = crate::BitReader<PE>;
impl PE_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PE {
        match self.bits {
            false => PE::Disabled,
            true => PE::Enabled,
        }
    }
    ///Peripheral disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == PE::Disabled
    }
    ///Peripheral enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == PE::Enabled
    }
}
///Field `PE` writer - Peripheral enable
pub type PE_W<'a, REG> = crate::BitWriter<'a, REG, PE>;
impl<'a, REG> PE_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Peripheral disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(PE::Disabled)
    }
    ///Peripheral enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(PE::Enabled)
    }
}
/**SMBus mode

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SMBUS {
    ///0: I2C Mode
    I2c = 0,
    ///1: SMBus
    Smbus = 1,
}
impl From<SMBUS> for bool {
    #[inline(always)]
    fn from(variant: SMBUS) -> Self {
        variant as u8 != 0
    }
}
///Field `SMBUS` reader - SMBus mode
pub type SMBUS_R = crate::BitReader<SMBUS>;
impl SMBUS_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SMBUS {
        match self.bits {
            false => SMBUS::I2c,
            true => SMBUS::Smbus,
        }
    }
    ///I2C Mode
    #[inline(always)]
    pub fn is_i2c(&self) -> bool {
        *self == SMBUS::I2c
    }
    ///SMBus
    #[inline(always)]
    pub fn is_smbus(&self) -> bool {
        *self == SMBUS::Smbus
    }
}
///Field `SMBUS` writer - SMBus mode
pub type SMBUS_W<'a, REG> = crate::BitWriter<'a, REG, SMBUS>;
impl<'a, REG> SMBUS_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///I2C Mode
    #[inline(always)]
    pub fn i2c(self) -> &'a mut crate::W<REG> {
        self.variant(SMBUS::I2c)
    }
    ///SMBus
    #[inline(always)]
    pub fn smbus(self) -> &'a mut crate::W<REG> {
        self.variant(SMBUS::Smbus)
    }
}
/**SMBus type

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SMBTYPE {
    ///0: SMBus Device
    Device = 0,
    ///1: SMBus Host
    Host = 1,
}
impl From<SMBTYPE> for bool {
    #[inline(always)]
    fn from(variant: SMBTYPE) -> Self {
        variant as u8 != 0
    }
}
///Field `SMBTYPE` reader - SMBus type
pub type SMBTYPE_R = crate::BitReader<SMBTYPE>;
impl SMBTYPE_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SMBTYPE {
        match self.bits {
            false => SMBTYPE::Device,
            true => SMBTYPE::Host,
        }
    }
    ///SMBus Device
    #[inline(always)]
    pub fn is_device(&self) -> bool {
        *self == SMBTYPE::Device
    }
    ///SMBus Host
    #[inline(always)]
    pub fn is_host(&self) -> bool {
        *self == SMBTYPE::Host
    }
}
///Field `SMBTYPE` writer - SMBus type
pub type SMBTYPE_W<'a, REG> = crate::BitWriter<'a, REG, SMBTYPE>;
impl<'a, REG> SMBTYPE_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///SMBus Device
    #[inline(always)]
    pub fn device(self) -> &'a mut crate::W<REG> {
        self.variant(SMBTYPE::Device)
    }
    ///SMBus Host
    #[inline(always)]
    pub fn host(self) -> &'a mut crate::W<REG> {
        self.variant(SMBTYPE::Host)
    }
}
/**ARP enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ENARP {
    ///0: ARP disabled
    Disabled = 0,
    ///1: ARP enabled
    Enabled = 1,
}
impl From<ENARP> for bool {
    #[inline(always)]
    fn from(variant: ENARP) -> Self {
        variant as u8 != 0
    }
}
///Field `ENARP` reader - ARP enable
pub type ENARP_R = crate::BitReader<ENARP>;
impl ENARP_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> ENARP {
        match self.bits {
            false => ENARP::Disabled,
            true => ENARP::Enabled,
        }
    }
    ///ARP disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == ENARP::Disabled
    }
    ///ARP enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == ENARP::Enabled
    }
}
///Field `ENARP` writer - ARP enable
pub type ENARP_W<'a, REG> = crate::BitWriter<'a, REG, ENARP>;
impl<'a, REG> ENARP_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///ARP disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENARP::Disabled)
    }
    ///ARP enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENARP::Enabled)
    }
}
/**PEC enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ENPEC {
    ///0: PEC calculation disabled
    Disabled = 0,
    ///1: PEC calculation enabled
    Enabled = 1,
}
impl From<ENPEC> for bool {
    #[inline(always)]
    fn from(variant: ENPEC) -> Self {
        variant as u8 != 0
    }
}
///Field `ENPEC` reader - PEC enable
pub type ENPEC_R = crate::BitReader<ENPEC>;
impl ENPEC_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> ENPEC {
        match self.bits {
            false => ENPEC::Disabled,
            true => ENPEC::Enabled,
        }
    }
    ///PEC calculation disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == ENPEC::Disabled
    }
    ///PEC calculation enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == ENPEC::Enabled
    }
}
///Field `ENPEC` writer - PEC enable
pub type ENPEC_W<'a, REG> = crate::BitWriter<'a, REG, ENPEC>;
impl<'a, REG> ENPEC_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///PEC calculation disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENPEC::Disabled)
    }
    ///PEC calculation enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENPEC::Enabled)
    }
}
/**General call enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ENGC {
    ///0: General call disabled
    Disabled = 0,
    ///1: General call enabled
    Enabled = 1,
}
impl From<ENGC> for bool {
    #[inline(always)]
    fn from(variant: ENGC) -> Self {
        variant as u8 != 0
    }
}
///Field `ENGC` reader - General call enable
pub type ENGC_R = crate::BitReader<ENGC>;
impl ENGC_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> ENGC {
        match self.bits {
            false => ENGC::Disabled,
            true => ENGC::Enabled,
        }
    }
    ///General call disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == ENGC::Disabled
    }
    ///General call enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == ENGC::Enabled
    }
}
///Field `ENGC` writer - General call enable
pub type ENGC_W<'a, REG> = crate::BitWriter<'a, REG, ENGC>;
impl<'a, REG> ENGC_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///General call disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENGC::Disabled)
    }
    ///General call enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(ENGC::Enabled)
    }
}
/**Clock stretching disable (Slave mode)

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NOSTRETCH {
    ///0: Clock stretching enabled
    Enabled = 0,
    ///1: Clock stretching disabled
    Disabled = 1,
}
impl From<NOSTRETCH> for bool {
    #[inline(always)]
    fn from(variant: NOSTRETCH) -> Self {
        variant as u8 != 0
    }
}
///Field `NOSTRETCH` reader - Clock stretching disable (Slave mode)
pub type NOSTRETCH_R = crate::BitReader<NOSTRETCH>;
impl NOSTRETCH_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> NOSTRETCH {
        match self.bits {
            false => NOSTRETCH::Enabled,
            true => NOSTRETCH::Disabled,
        }
    }
    ///Clock stretching enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == NOSTRETCH::Enabled
    }
    ///Clock stretching disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == NOSTRETCH::Disabled
    }
}
///Field `NOSTRETCH` writer - Clock stretching disable (Slave mode)
pub type NOSTRETCH_W<'a, REG> = crate::BitWriter<'a, REG, NOSTRETCH>;
impl<'a, REG> NOSTRETCH_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Clock stretching enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(NOSTRETCH::Enabled)
    }
    ///Clock stretching disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(NOSTRETCH::Disabled)
    }
}
/**Start generation

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum START {
    ///0: No Start generation
    NoStart = 0,
    ///1: In master mode: repeated start generation, in slave mode: start generation when bus is free
    Start = 1,
}
impl From<START> for bool {
    #[inline(always)]
    fn from(variant: START) -> Self {
        variant as u8 != 0
    }
}
///Field `START` reader - Start generation
pub type START_R = crate::BitReader<START>;
impl START_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> START {
        match self.bits {
            false => START::NoStart,
            true => START::Start,
        }
    }
    ///No Start generation
    #[inline(always)]
    pub fn is_no_start(&self) -> bool {
        *self == START::NoStart
    }
    ///In master mode: repeated start generation, in slave mode: start generation when bus is free
    #[inline(always)]
    pub fn is_start(&self) -> bool {
        *self == START::Start
    }
}
///Field `START` writer - Start generation
pub type START_W<'a, REG> = crate::BitWriter<'a, REG, START>;
impl<'a, REG> START_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///No Start generation
    #[inline(always)]
    pub fn no_start(self) -> &'a mut crate::W<REG> {
        self.variant(START::NoStart)
    }
    ///In master mode: repeated start generation, in slave mode: start generation when bus is free
    #[inline(always)]
    pub fn start(self) -> &'a mut crate::W<REG> {
        self.variant(START::Start)
    }
}
/**Stop generation

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum STOP {
    ///0: No Stop generation
    NoStop = 0,
    ///1: In master mode: stop generation after current byte/start, in slave mode: release SCL and SDA after current byte
    Stop = 1,
}
impl From<STOP> for bool {
    #[inline(always)]
    fn from(variant: STOP) -> Self {
        variant as u8 != 0
    }
}
///Field `STOP` reader - Stop generation
pub type STOP_R = crate::BitReader<STOP>;
impl STOP_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> STOP {
        match self.bits {
            false => STOP::NoStop,
            true => STOP::Stop,
        }
    }
    ///No Stop generation
    #[inline(always)]
    pub fn is_no_stop(&self) -> bool {
        *self == STOP::NoStop
    }
    ///In master mode: stop generation after current byte/start, in slave mode: release SCL and SDA after current byte
    #[inline(always)]
    pub fn is_stop(&self) -> bool {
        *self == STOP::Stop
    }
}
///Field `STOP` writer - Stop generation
pub type STOP_W<'a, REG> = crate::BitWriter<'a, REG, STOP>;
impl<'a, REG> STOP_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///No Stop generation
    #[inline(always)]
    pub fn no_stop(self) -> &'a mut crate::W<REG> {
        self.variant(STOP::NoStop)
    }
    ///In master mode: stop generation after current byte/start, in slave mode: release SCL and SDA after current byte
    #[inline(always)]
    pub fn stop(self) -> &'a mut crate::W<REG> {
        self.variant(STOP::Stop)
    }
}
/**Acknowledge enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ACK {
    ///0: No acknowledge returned
    Nak = 0,
    ///1: Acknowledge returned after a byte is received
    Ack = 1,
}
impl From<ACK> for bool {
    #[inline(always)]
    fn from(variant: ACK) -> Self {
        variant as u8 != 0
    }
}
///Field `ACK` reader - Acknowledge enable
pub type ACK_R = crate::BitReader<ACK>;
impl ACK_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> ACK {
        match self.bits {
            false => ACK::Nak,
            true => ACK::Ack,
        }
    }
    ///No acknowledge returned
    #[inline(always)]
    pub fn is_nak(&self) -> bool {
        *self == ACK::Nak
    }
    ///Acknowledge returned after a byte is received
    #[inline(always)]
    pub fn is_ack(&self) -> bool {
        *self == ACK::Ack
    }
}
///Field `ACK` writer - Acknowledge enable
pub type ACK_W<'a, REG> = crate::BitWriter<'a, REG, ACK>;
impl<'a, REG> ACK_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///No acknowledge returned
    #[inline(always)]
    pub fn nak(self) -> &'a mut crate::W<REG> {
        self.variant(ACK::Nak)
    }
    ///Acknowledge returned after a byte is received
    #[inline(always)]
    pub fn ack(self) -> &'a mut crate::W<REG> {
        self.variant(ACK::Ack)
    }
}
/**Acknowledge/PEC Position (for data reception)

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum POS {
    ///0: ACK bit controls the (N)ACK of the current byte being received
    Current = 0,
    ///1: ACK bit controls the (N)ACK of the next byte to be received
    Next = 1,
}
impl From<POS> for bool {
    #[inline(always)]
    fn from(variant: POS) -> Self {
        variant as u8 != 0
    }
}
///Field `POS` reader - Acknowledge/PEC Position (for data reception)
pub type POS_R = crate::BitReader<POS>;
impl POS_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> POS {
        match self.bits {
            false => POS::Current,
            true => POS::Next,
        }
    }
    ///ACK bit controls the (N)ACK of the current byte being received
    #[inline(always)]
    pub fn is_current(&self) -> bool {
        *self == POS::Current
    }
    ///ACK bit controls the (N)ACK of the next byte to be received
    #[inline(always)]
    pub fn is_next(&self) -> bool {
        *self == POS::Next
    }
}
///Field `POS` writer - Acknowledge/PEC Position (for data reception)
pub type POS_W<'a, REG> = crate::BitWriter<'a, REG, POS>;
impl<'a, REG> POS_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///ACK bit controls the (N)ACK of the current byte being received
    #[inline(always)]
    pub fn current(self) -> &'a mut crate::W<REG> {
        self.variant(POS::Current)
    }
    ///ACK bit controls the (N)ACK of the next byte to be received
    #[inline(always)]
    pub fn next(self) -> &'a mut crate::W<REG> {
        self.variant(POS::Next)
    }
}
/**Packet error checking

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PEC {
    ///0: No PEC transfer
    Disabled = 0,
    ///1: PEC transfer
    Enabled = 1,
}
impl From<PEC> for bool {
    #[inline(always)]
    fn from(variant: PEC) -> Self {
        variant as u8 != 0
    }
}
///Field `PEC` reader - Packet error checking
pub type PEC_R = crate::BitReader<PEC>;
impl PEC_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PEC {
        match self.bits {
            false => PEC::Disabled,
            true => PEC::Enabled,
        }
    }
    ///No PEC transfer
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == PEC::Disabled
    }
    ///PEC transfer
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == PEC::Enabled
    }
}
///Field `PEC` writer - Packet error checking
pub type PEC_W<'a, REG> = crate::BitWriter<'a, REG, PEC>;
impl<'a, REG> PEC_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///No PEC transfer
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(PEC::Disabled)
    }
    ///PEC transfer
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(PEC::Enabled)
    }
}
/**SMBus alert

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ALERT {
    ///0: SMBA pin released high
    Release = 0,
    ///1: SMBA pin driven low
    Drive = 1,
}
impl From<ALERT> for bool {
    #[inline(always)]
    fn from(variant: ALERT) -> Self {
        variant as u8 != 0
    }
}
///Field `ALERT` reader - SMBus alert
pub type ALERT_R = crate::BitReader<ALERT>;
impl ALERT_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> ALERT {
        match self.bits {
            false => ALERT::Release,
            true => ALERT::Drive,
        }
    }
    ///SMBA pin released high
    #[inline(always)]
    pub fn is_release(&self) -> bool {
        *self == ALERT::Release
    }
    ///SMBA pin driven low
    #[inline(always)]
    pub fn is_drive(&self) -> bool {
        *self == ALERT::Drive
    }
}
///Field `ALERT` writer - SMBus alert
pub type ALERT_W<'a, REG> = crate::BitWriter<'a, REG, ALERT>;
impl<'a, REG> ALERT_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///SMBA pin released high
    #[inline(always)]
    pub fn release(self) -> &'a mut crate::W<REG> {
        self.variant(ALERT::Release)
    }
    ///SMBA pin driven low
    #[inline(always)]
    pub fn drive(self) -> &'a mut crate::W<REG> {
        self.variant(ALERT::Drive)
    }
}
/**Software reset

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SWRST {
    ///0: I2C peripheral not under reset
    NotReset = 0,
    ///1: I2C peripheral under reset
    Reset = 1,
}
impl From<SWRST> for bool {
    #[inline(always)]
    fn from(variant: SWRST) -> Self {
        variant as u8 != 0
    }
}
///Field `SWRST` reader - Software reset
pub type SWRST_R = crate::BitReader<SWRST>;
impl SWRST_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SWRST {
        match self.bits {
            false => SWRST::NotReset,
            true => SWRST::Reset,
        }
    }
    ///I2C peripheral not under reset
    #[inline(always)]
    pub fn is_not_reset(&self) -> bool {
        *self == SWRST::NotReset
    }
    ///I2C peripheral under reset
    #[inline(always)]
    pub fn is_reset(&self) -> bool {
        *self == SWRST::Reset
    }
}
///Field `SWRST` writer - Software reset
pub type SWRST_W<'a, REG> = crate::BitWriter<'a, REG, SWRST>;
impl<'a, REG> SWRST_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///I2C peripheral not under reset
    #[inline(always)]
    pub fn not_reset(self) -> &'a mut crate::W<REG> {
        self.variant(SWRST::NotReset)
    }
    ///I2C peripheral under reset
    #[inline(always)]
    pub fn reset(self) -> &'a mut crate::W<REG> {
        self.variant(SWRST::Reset)
    }
}
impl R {
    ///Bit 0 - Peripheral enable
    #[inline(always)]
    pub fn pe(&self) -> PE_R {
        PE_R::new((self.bits & 1) != 0)
    }
    ///Bit 1 - SMBus mode
    #[inline(always)]
    pub fn smbus(&self) -> SMBUS_R {
        SMBUS_R::new(((self.bits >> 1) & 1) != 0)
    }
    ///Bit 3 - SMBus type
    #[inline(always)]
    pub fn smbtype(&self) -> SMBTYPE_R {
        SMBTYPE_R::new(((self.bits >> 3) & 1) != 0)
    }
    ///Bit 4 - ARP enable
    #[inline(always)]
    pub fn enarp(&self) -> ENARP_R {
        ENARP_R::new(((self.bits >> 4) & 1) != 0)
    }
    ///Bit 5 - PEC enable
    #[inline(always)]
    pub fn enpec(&self) -> ENPEC_R {
        ENPEC_R::new(((self.bits >> 5) & 1) != 0)
    }
    ///Bit 6 - General call enable
    #[inline(always)]
    pub fn engc(&self) -> ENGC_R {
        ENGC_R::new(((self.bits >> 6) & 1) != 0)
    }
    ///Bit 7 - Clock stretching disable (Slave mode)
    #[inline(always)]
    pub fn nostretch(&self) -> NOSTRETCH_R {
        NOSTRETCH_R::new(((self.bits >> 7) & 1) != 0)
    }
    ///Bit 8 - Start generation
    #[inline(always)]
    pub fn start(&self) -> START_R {
        START_R::new(((self.bits >> 8) & 1) != 0)
    }
    ///Bit 9 - Stop generation
    #[inline(always)]
    pub fn stop(&self) -> STOP_R {
        STOP_R::new(((self.bits >> 9) & 1) != 0)
    }
    ///Bit 10 - Acknowledge enable
    #[inline(always)]
    pub fn ack(&self) -> ACK_R {
        ACK_R::new(((self.bits >> 10) & 1) != 0)
    }
    ///Bit 11 - Acknowledge/PEC Position (for data reception)
    #[inline(always)]
    pub fn pos(&self) -> POS_R {
        POS_R::new(((self.bits >> 11) & 1) != 0)
    }
    ///Bit 12 - Packet error checking
    #[inline(always)]
    pub fn pec(&self) -> PEC_R {
        PEC_R::new(((self.bits >> 12) & 1) != 0)
    }
    ///Bit 13 - SMBus alert
    #[inline(always)]
    pub fn alert(&self) -> ALERT_R {
        ALERT_R::new(((self.bits >> 13) & 1) != 0)
    }
    ///Bit 15 - Software reset
    #[inline(always)]
    pub fn swrst(&self) -> SWRST_R {
        SWRST_R::new(((self.bits >> 15) & 1) != 0)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("CR1")
            .field("swrst", &self.swrst())
            .field("alert", &self.alert())
            .field("pec", &self.pec())
            .field("pos", &self.pos())
            .field("ack", &self.ack())
            .field("stop", &self.stop())
            .field("start", &self.start())
            .field("nostretch", &self.nostretch())
            .field("engc", &self.engc())
            .field("enpec", &self.enpec())
            .field("enarp", &self.enarp())
            .field("smbtype", &self.smbtype())
            .field("smbus", &self.smbus())
            .field("pe", &self.pe())
            .finish()
    }
}
impl W {
    ///Bit 0 - Peripheral enable
    #[inline(always)]
    #[must_use]
    pub fn pe(&mut self) -> PE_W<CR1rs> {
        PE_W::new(self, 0)
    }
    ///Bit 1 - SMBus mode
    #[inline(always)]
    #[must_use]
    pub fn smbus(&mut self) -> SMBUS_W<CR1rs> {
        SMBUS_W::new(self, 1)
    }
    ///Bit 3 - SMBus type
    #[inline(always)]
    #[must_use]
    pub fn smbtype(&mut self) -> SMBTYPE_W<CR1rs> {
        SMBTYPE_W::new(self, 3)
    }
    ///Bit 4 - ARP enable
    #[inline(always)]
    #[must_use]
    pub fn enarp(&mut self) -> ENARP_W<CR1rs> {
        ENARP_W::new(self, 4)
    }
    ///Bit 5 - PEC enable
    #[inline(always)]
    #[must_use]
    pub fn enpec(&mut self) -> ENPEC_W<CR1rs> {
        ENPEC_W::new(self, 5)
    }
    ///Bit 6 - General call enable
    #[inline(always)]
    #[must_use]
    pub fn engc(&mut self) -> ENGC_W<CR1rs> {
        ENGC_W::new(self, 6)
    }
    ///Bit 7 - Clock stretching disable (Slave mode)
    #[inline(always)]
    #[must_use]
    pub fn nostretch(&mut self) -> NOSTRETCH_W<CR1rs> {
        NOSTRETCH_W::new(self, 7)
    }
    ///Bit 8 - Start generation
    #[inline(always)]
    #[must_use]
    pub fn start(&mut self) -> START_W<CR1rs> {
        START_W::new(self, 8)
    }
    ///Bit 9 - Stop generation
    #[inline(always)]
    #[must_use]
    pub fn stop(&mut self) -> STOP_W<CR1rs> {
        STOP_W::new(self, 9)
    }
    ///Bit 10 - Acknowledge enable
    #[inline(always)]
    #[must_use]
    pub fn ack(&mut self) -> ACK_W<CR1rs> {
        ACK_W::new(self, 10)
    }
    ///Bit 11 - Acknowledge/PEC Position (for data reception)
    #[inline(always)]
    #[must_use]
    pub fn pos(&mut self) -> POS_W<CR1rs> {
        POS_W::new(self, 11)
    }
    ///Bit 12 - Packet error checking
    #[inline(always)]
    #[must_use]
    pub fn pec(&mut self) -> PEC_W<CR1rs> {
        PEC_W::new(self, 12)
    }
    ///Bit 13 - SMBus alert
    #[inline(always)]
    #[must_use]
    pub fn alert(&mut self) -> ALERT_W<CR1rs> {
        ALERT_W::new(self, 13)
    }
    ///Bit 15 - Software reset
    #[inline(always)]
    #[must_use]
    pub fn swrst(&mut self) -> SWRST_W<CR1rs> {
        SWRST_W::new(self, 15)
    }
}
/**Control register 1

You can [`read`](crate::Reg::read) this register and get [`cr1::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr1::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).

See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F102.html#I2C1:CR1)*/
pub struct CR1rs;
impl crate::RegisterSpec for CR1rs {
    type Ux = u32;
}
///`read()` method returns [`cr1::R`](R) reader structure
impl crate::Readable for CR1rs {}
///`write(|w| ..)` method takes [`cr1::W`](W) writer structure
impl crate::Writable for CR1rs {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
///`reset()` method sets CR1 to value 0
impl crate::Resettable for CR1rs {
    const RESET_VALUE: u32 = 0;
}