stm32-metapac 18.0.0

Peripheral Access Crate (PAC) for all STM32 chips, including metadata.
Documentation
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
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::identity_op)]
#![allow(clippy::unnecessary_cast)]
#![allow(clippy::erasing_op)]

#[doc = "Sigma-delta analog-to-digital converter."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sdadc {
    ptr: *mut u8,
}
unsafe impl Send for Sdadc {}
unsafe impl Sync for Sdadc {}
impl Sdadc {
    #[inline(always)]
    pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
        Self { ptr: ptr as _ }
    }
    #[inline(always)]
    pub const fn as_ptr(&self) -> *mut () {
        self.ptr as _
    }
    #[doc = "control register 1."]
    #[inline(always)]
    pub const fn cr1(self) -> crate::common::Reg<regs::Cr1, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
    }
    #[doc = "control register 2."]
    #[inline(always)]
    pub const fn cr2(self) -> crate::common::Reg<regs::Cr2, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) }
    }
    #[doc = "interrupt and status register."]
    #[inline(always)]
    pub const fn isr(self) -> crate::common::Reg<regs::Isr, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) }
    }
    #[doc = "interrupt and status clear register."]
    #[inline(always)]
    pub const fn clrisr(self) -> crate::common::Reg<regs::Clrisr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
    }
    #[doc = "injected channel group selection register."]
    #[inline(always)]
    pub const fn jchgr(self) -> crate::common::Reg<regs::Jchgr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize) as _) }
    }
    #[doc = "configuration 0 register."]
    #[inline(always)]
    pub const fn confr(self, n: usize) -> crate::common::Reg<regs::Confr, crate::common::RW> {
        assert!(n < 3usize);
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize + n * 4usize) as _) }
    }
    #[doc = "channel configuration register 1."]
    #[inline(always)]
    pub const fn confchr1(self) -> crate::common::Reg<regs::Confchr1, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x40usize) as _) }
    }
    #[doc = "channel configuration register 2."]
    #[inline(always)]
    pub const fn confchr2(self) -> crate::common::Reg<regs::Confchr2, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x44usize) as _) }
    }
    #[doc = "data register for injected group."]
    #[inline(always)]
    pub const fn jdatar(self) -> crate::common::Reg<regs::Jdatar, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x60usize) as _) }
    }
    #[doc = "data register for the regular channel."]
    #[inline(always)]
    pub const fn rdatar(self) -> crate::common::Reg<regs::Rdatar, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x64usize) as _) }
    }
    #[doc = "SDADC1 and SDADC2 injected data register."]
    #[inline(always)]
    pub const fn jdata12r(self) -> crate::common::Reg<u32, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x70usize) as _) }
    }
    #[doc = "SDADC1 and SDADC2 regular data register."]
    #[inline(always)]
    pub const fn rdata12r(self) -> crate::common::Reg<u32, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x74usize) as _) }
    }
    #[doc = "SDADC1 and SDADC3 injected data register."]
    #[inline(always)]
    pub const fn jdata13r(self) -> crate::common::Reg<u32, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x78usize) as _) }
    }
    #[doc = "SDADC1 and SDADC3 regular data register."]
    #[inline(always)]
    pub const fn rdata13r(self) -> crate::common::Reg<u32, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x7cusize) as _) }
    }
}
pub mod regs {
    #[doc = "interrupt and status clear register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Clrisr(pub u32);
    impl Clrisr {
        #[doc = "Clear the end of calibration flag."]
        #[inline(always)]
        pub const fn clreocalf(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the end of calibration flag."]
        #[inline(always)]
        pub fn set_clreocalf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Clear the injected conversion overrun flag."]
        #[inline(always)]
        pub const fn clrjovrf(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the injected conversion overrun flag."]
        #[inline(always)]
        pub fn set_clrjovrf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Clear the regular conversion overrun flag."]
        #[inline(always)]
        pub const fn clrrovrf(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the regular conversion overrun flag."]
        #[inline(always)]
        pub fn set_clrrovrf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
    }
    impl Default for Clrisr {
        #[inline(always)]
        fn default() -> Clrisr {
            Clrisr(0)
        }
    }
    impl core::fmt::Debug for Clrisr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Clrisr")
                .field("clreocalf", &self.clreocalf())
                .field("clrjovrf", &self.clrjovrf())
                .field("clrrovrf", &self.clrrovrf())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Clrisr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Clrisr {{ clreocalf: {=bool:?}, clrjovrf: {=bool:?}, clrrovrf: {=bool:?} }}",
                self.clreocalf(),
                self.clrjovrf(),
                self.clrrovrf()
            )
        }
    }
    #[doc = "channel configuration register 1."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Confchr1(pub u32);
    impl Confchr1 {
        #[doc = "CONFCH0."]
        #[inline(always)]
        pub const fn confch(&self, n: usize) -> u8 {
            assert!(n < 8usize);
            let offs = 0usize + n * 4usize;
            let val = (self.0 >> offs) & 0x03;
            val as u8
        }
        #[doc = "CONFCH0."]
        #[inline(always)]
        pub fn set_confch(&mut self, n: usize, val: u8) {
            assert!(n < 8usize);
            let offs = 0usize + n * 4usize;
            self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs);
        }
    }
    impl Default for Confchr1 {
        #[inline(always)]
        fn default() -> Confchr1 {
            Confchr1(0)
        }
    }
    impl core::fmt::Debug for Confchr1 {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Confchr1")
                .field("confch[0]", &self.confch(0usize))
                .field("confch[1]", &self.confch(1usize))
                .field("confch[2]", &self.confch(2usize))
                .field("confch[3]", &self.confch(3usize))
                .field("confch[4]", &self.confch(4usize))
                .field("confch[5]", &self.confch(5usize))
                .field("confch[6]", &self.confch(6usize))
                .field("confch[7]", &self.confch(7usize))
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Confchr1 {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Confchr1 {{ confch[0]: {=u8:?}, confch[1]: {=u8:?}, confch[2]: {=u8:?}, confch[3]: {=u8:?}, confch[4]: {=u8:?}, confch[5]: {=u8:?}, confch[6]: {=u8:?}, confch[7]: {=u8:?} }}" , self . confch (0usize) , self . confch (1usize) , self . confch (2usize) , self . confch (3usize) , self . confch (4usize) , self . confch (5usize) , self . confch (6usize) , self . confch (7usize))
        }
    }
    #[doc = "channel configuration register 2."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Confchr2(pub u32);
    impl Confchr2 {
        #[doc = "Channel 8 configuration."]
        #[inline(always)]
        pub const fn confch(&self, n: usize) -> u8 {
            assert!(n < 1usize);
            let offs = 0usize + n * 0usize;
            let val = (self.0 >> offs) & 0x03;
            val as u8
        }
        #[doc = "Channel 8 configuration."]
        #[inline(always)]
        pub fn set_confch(&mut self, n: usize, val: u8) {
            assert!(n < 1usize);
            let offs = 0usize + n * 0usize;
            self.0 = (self.0 & !(0x03 << offs)) | (((val as u32) & 0x03) << offs);
        }
    }
    impl Default for Confchr2 {
        #[inline(always)]
        fn default() -> Confchr2 {
            Confchr2(0)
        }
    }
    impl core::fmt::Debug for Confchr2 {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Confchr2")
                .field("confch[0]", &self.confch(0usize))
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Confchr2 {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Confchr2 {{ confch[0]: {=u8:?} }}", self.confch(0usize))
        }
    }
    #[doc = "configuration 0 register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Confr(pub u32);
    impl Confr {
        #[doc = "Twelve-bit calibration offset for configuration 0."]
        #[inline(always)]
        pub const fn offset(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x0fff;
            val as u16
        }
        #[doc = "Twelve-bit calibration offset for configuration 0."]
        #[inline(always)]
        pub fn set_offset(&mut self, val: u16) {
            self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
        }
        #[doc = "Gain setting for configuration 0."]
        #[inline(always)]
        pub const fn gain(&self) -> u8 {
            let val = (self.0 >> 20usize) & 0x07;
            val as u8
        }
        #[doc = "Gain setting for configuration 0."]
        #[inline(always)]
        pub fn set_gain(&mut self, val: u8) {
            self.0 = (self.0 & !(0x07 << 20usize)) | (((val as u32) & 0x07) << 20usize);
        }
        #[doc = "Single-ended mode for configuration 0."]
        #[inline(always)]
        pub const fn se(&self) -> u8 {
            let val = (self.0 >> 26usize) & 0x03;
            val as u8
        }
        #[doc = "Single-ended mode for configuration 0."]
        #[inline(always)]
        pub fn set_se(&mut self, val: u8) {
            self.0 = (self.0 & !(0x03 << 26usize)) | (((val as u32) & 0x03) << 26usize);
        }
        #[doc = "Common mode for configuration 0."]
        #[inline(always)]
        pub const fn common(&self) -> u8 {
            let val = (self.0 >> 30usize) & 0x03;
            val as u8
        }
        #[doc = "Common mode for configuration 0."]
        #[inline(always)]
        pub fn set_common(&mut self, val: u8) {
            self.0 = (self.0 & !(0x03 << 30usize)) | (((val as u32) & 0x03) << 30usize);
        }
    }
    impl Default for Confr {
        #[inline(always)]
        fn default() -> Confr {
            Confr(0)
        }
    }
    impl core::fmt::Debug for Confr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Confr")
                .field("offset", &self.offset())
                .field("gain", &self.gain())
                .field("se", &self.se())
                .field("common", &self.common())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Confr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Confr {{ offset: {=u16:?}, gain: {=u8:?}, se: {=u8:?}, common: {=u8:?} }}",
                self.offset(),
                self.gain(),
                self.se(),
                self.common()
            )
        }
    }
    #[doc = "control register 1."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Cr1(pub u32);
    impl Cr1 {
        #[doc = "End of calibration interrupt enable."]
        #[inline(always)]
        pub const fn eocalie(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "End of calibration interrupt enable."]
        #[inline(always)]
        pub fn set_eocalie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Injected end of conversion interrupt enable."]
        #[inline(always)]
        pub const fn jeocie(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Injected end of conversion interrupt enable."]
        #[inline(always)]
        pub fn set_jeocie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Injected data overrun interrupt enable."]
        #[inline(always)]
        pub const fn jovrie(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Injected data overrun interrupt enable."]
        #[inline(always)]
        pub fn set_jovrie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Regular end of conversion interrupt enable."]
        #[inline(always)]
        pub const fn reocie(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Regular end of conversion interrupt enable."]
        #[inline(always)]
        pub fn set_reocie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
        #[doc = "Regular data overrun interrupt enable."]
        #[inline(always)]
        pub const fn rovrie(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Regular data overrun interrupt enable."]
        #[inline(always)]
        pub fn set_rovrie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
        #[doc = "Reference voltage selection."]
        #[inline(always)]
        pub const fn refv(&self) -> u8 {
            let val = (self.0 >> 8usize) & 0x03;
            val as u8
        }
        #[doc = "Reference voltage selection."]
        #[inline(always)]
        pub fn set_refv(&mut self, val: u8) {
            self.0 = (self.0 & !(0x03 << 8usize)) | (((val as u32) & 0x03) << 8usize);
        }
        #[doc = "Slow clock mode enable."]
        #[inline(always)]
        pub const fn slowck(&self) -> bool {
            let val = (self.0 >> 10usize) & 0x01;
            val != 0
        }
        #[doc = "Slow clock mode enable."]
        #[inline(always)]
        pub fn set_slowck(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
        }
        #[doc = "Enter Standby mode when idle."]
        #[inline(always)]
        pub const fn sbi(&self) -> bool {
            let val = (self.0 >> 11usize) & 0x01;
            val != 0
        }
        #[doc = "Enter Standby mode when idle."]
        #[inline(always)]
        pub fn set_sbi(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
        }
        #[doc = "Enter power down mode when idle."]
        #[inline(always)]
        pub const fn pdi(&self) -> bool {
            let val = (self.0 >> 12usize) & 0x01;
            val != 0
        }
        #[doc = "Enter power down mode when idle."]
        #[inline(always)]
        pub fn set_pdi(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
        }
        #[doc = "Launch a injected conversion synchronously with SDADC1."]
        #[inline(always)]
        pub const fn jsync(&self) -> bool {
            let val = (self.0 >> 14usize) & 0x01;
            val != 0
        }
        #[doc = "Launch a injected conversion synchronously with SDADC1."]
        #[inline(always)]
        pub fn set_jsync(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
        }
        #[doc = "Launch regular conversion synchronously with SDADC1."]
        #[inline(always)]
        pub const fn rsync(&self) -> bool {
            let val = (self.0 >> 15usize) & 0x01;
            val != 0
        }
        #[doc = "Launch regular conversion synchronously with SDADC1."]
        #[inline(always)]
        pub fn set_rsync(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
        }
        #[doc = "DMA channel enabled to read data for the injected channel group."]
        #[inline(always)]
        pub const fn jdmaen(&self) -> bool {
            let val = (self.0 >> 16usize) & 0x01;
            val != 0
        }
        #[doc = "DMA channel enabled to read data for the injected channel group."]
        #[inline(always)]
        pub fn set_jdmaen(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
        }
        #[doc = "DMA channel enabled to read data for the regular channel."]
        #[inline(always)]
        pub const fn rdmaen(&self) -> bool {
            let val = (self.0 >> 17usize) & 0x01;
            val != 0
        }
        #[doc = "DMA channel enabled to read data for the regular channel."]
        #[inline(always)]
        pub fn set_rdmaen(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
        }
        #[doc = "Initialization mode request."]
        #[inline(always)]
        pub const fn init(&self) -> bool {
            let val = (self.0 >> 31usize) & 0x01;
            val != 0
        }
        #[doc = "Initialization mode request."]
        #[inline(always)]
        pub fn set_init(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
        }
    }
    impl Default for Cr1 {
        #[inline(always)]
        fn default() -> Cr1 {
            Cr1(0)
        }
    }
    impl core::fmt::Debug for Cr1 {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Cr1")
                .field("eocalie", &self.eocalie())
                .field("jeocie", &self.jeocie())
                .field("jovrie", &self.jovrie())
                .field("reocie", &self.reocie())
                .field("rovrie", &self.rovrie())
                .field("refv", &self.refv())
                .field("slowck", &self.slowck())
                .field("sbi", &self.sbi())
                .field("pdi", &self.pdi())
                .field("jsync", &self.jsync())
                .field("rsync", &self.rsync())
                .field("jdmaen", &self.jdmaen())
                .field("rdmaen", &self.rdmaen())
                .field("init", &self.init())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Cr1 {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Cr1 {{ eocalie: {=bool:?}, jeocie: {=bool:?}, jovrie: {=bool:?}, reocie: {=bool:?}, rovrie: {=bool:?}, refv: {=u8:?}, slowck: {=bool:?}, sbi: {=bool:?}, pdi: {=bool:?}, jsync: {=bool:?}, rsync: {=bool:?}, jdmaen: {=bool:?}, rdmaen: {=bool:?}, init: {=bool:?} }}" , self . eocalie () , self . jeocie () , self . jovrie () , self . reocie () , self . rovrie () , self . refv () , self . slowck () , self . sbi () , self . pdi () , self . jsync () , self . rsync () , self . jdmaen () , self . rdmaen () , self . init ())
        }
    }
    #[doc = "control register 2."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Cr2(pub u32);
    impl Cr2 {
        #[doc = "SDADC enable."]
        #[inline(always)]
        pub const fn adon(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "SDADC enable."]
        #[inline(always)]
        pub fn set_adon(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Number of calibration sequences to be performed (number of valid configurations)."]
        #[inline(always)]
        pub const fn calibcnt(&self) -> u8 {
            let val = (self.0 >> 1usize) & 0x03;
            val as u8
        }
        #[doc = "Number of calibration sequences to be performed (number of valid configurations)."]
        #[inline(always)]
        pub fn set_calibcnt(&mut self, val: u8) {
            self.0 = (self.0 & !(0x03 << 1usize)) | (((val as u32) & 0x03) << 1usize);
        }
        #[doc = "Start calibration."]
        #[inline(always)]
        pub const fn startcalib(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Start calibration."]
        #[inline(always)]
        pub fn set_startcalib(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
        #[doc = "Continuous mode selection for injected conversions."]
        #[inline(always)]
        pub const fn jcont(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Continuous mode selection for injected conversions."]
        #[inline(always)]
        pub fn set_jcont(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
        }
        #[doc = "Delay start of injected conversions."]
        #[inline(always)]
        pub const fn jds(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Delay start of injected conversions."]
        #[inline(always)]
        pub fn set_jds(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
        }
        #[doc = "Trigger signal selection for launching injected conversions."]
        #[inline(always)]
        pub const fn jextsel(&self) -> u8 {
            let val = (self.0 >> 8usize) & 0x0f;
            val as u8
        }
        #[doc = "Trigger signal selection for launching injected conversions."]
        #[inline(always)]
        pub fn set_jextsel(&mut self, val: u8) {
            self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
        }
        #[doc = "Trigger enable and trigger edge selection for injected conversions."]
        #[inline(always)]
        pub const fn jexten(&self) -> u8 {
            let val = (self.0 >> 13usize) & 0x03;
            val as u8
        }
        #[doc = "Trigger enable and trigger edge selection for injected conversions."]
        #[inline(always)]
        pub fn set_jexten(&mut self, val: u8) {
            self.0 = (self.0 & !(0x03 << 13usize)) | (((val as u32) & 0x03) << 13usize);
        }
        #[doc = "Start a conversion of the injected group of channels."]
        #[inline(always)]
        pub const fn jswstart(&self) -> bool {
            let val = (self.0 >> 15usize) & 0x01;
            val != 0
        }
        #[doc = "Start a conversion of the injected group of channels."]
        #[inline(always)]
        pub fn set_jswstart(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
        }
        #[doc = "Regular channel selection."]
        #[inline(always)]
        pub const fn rch(&self) -> u8 {
            let val = (self.0 >> 16usize) & 0x0f;
            val as u8
        }
        #[doc = "Regular channel selection."]
        #[inline(always)]
        pub fn set_rch(&mut self, val: u8) {
            self.0 = (self.0 & !(0x0f << 16usize)) | (((val as u32) & 0x0f) << 16usize);
        }
        #[doc = "Continuous mode selection for regular conversions."]
        #[inline(always)]
        pub const fn rcont(&self) -> bool {
            let val = (self.0 >> 22usize) & 0x01;
            val != 0
        }
        #[doc = "Continuous mode selection for regular conversions."]
        #[inline(always)]
        pub fn set_rcont(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
        }
        #[doc = "Software start of a conversion on the regular channel."]
        #[inline(always)]
        pub const fn rswstart(&self) -> bool {
            let val = (self.0 >> 23usize) & 0x01;
            val != 0
        }
        #[doc = "Software start of a conversion on the regular channel."]
        #[inline(always)]
        pub fn set_rswstart(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
        }
        #[doc = "Fast conversion mode selection."]
        #[inline(always)]
        pub const fn fast(&self) -> bool {
            let val = (self.0 >> 24usize) & 0x01;
            val != 0
        }
        #[doc = "Fast conversion mode selection."]
        #[inline(always)]
        pub fn set_fast(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
        }
    }
    impl Default for Cr2 {
        #[inline(always)]
        fn default() -> Cr2 {
            Cr2(0)
        }
    }
    impl core::fmt::Debug for Cr2 {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Cr2")
                .field("adon", &self.adon())
                .field("calibcnt", &self.calibcnt())
                .field("startcalib", &self.startcalib())
                .field("jcont", &self.jcont())
                .field("jds", &self.jds())
                .field("jextsel", &self.jextsel())
                .field("jexten", &self.jexten())
                .field("jswstart", &self.jswstart())
                .field("rch", &self.rch())
                .field("rcont", &self.rcont())
                .field("rswstart", &self.rswstart())
                .field("fast", &self.fast())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Cr2 {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Cr2 {{ adon: {=bool:?}, calibcnt: {=u8:?}, startcalib: {=bool:?}, jcont: {=bool:?}, jds: {=bool:?}, jextsel: {=u8:?}, jexten: {=u8:?}, jswstart: {=bool:?}, rch: {=u8:?}, rcont: {=bool:?}, rswstart: {=bool:?}, fast: {=bool:?} }}" , self . adon () , self . calibcnt () , self . startcalib () , self . jcont () , self . jds () , self . jextsel () , self . jexten () , self . jswstart () , self . rch () , self . rcont () , self . rswstart () , self . fast ())
        }
    }
    #[doc = "interrupt and status register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Isr(pub u32);
    impl Isr {
        #[doc = "End of calibration flag."]
        #[inline(always)]
        pub const fn eocalf(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "End of calibration flag."]
        #[inline(always)]
        pub fn set_eocalf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "End of injected conversion flag."]
        #[inline(always)]
        pub const fn jeocf(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "End of injected conversion flag."]
        #[inline(always)]
        pub fn set_jeocf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Injected conversion overrun flag."]
        #[inline(always)]
        pub const fn jovrf(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Injected conversion overrun flag."]
        #[inline(always)]
        pub fn set_jovrf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "End of regular conversion flag."]
        #[inline(always)]
        pub const fn reocf(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "End of regular conversion flag."]
        #[inline(always)]
        pub fn set_reocf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
        #[doc = "Regular conversion overrun flag."]
        #[inline(always)]
        pub const fn rovrf(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Regular conversion overrun flag."]
        #[inline(always)]
        pub fn set_rovrf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
        #[doc = "Calibration in progress status."]
        #[inline(always)]
        pub const fn calibip(&self) -> bool {
            let val = (self.0 >> 12usize) & 0x01;
            val != 0
        }
        #[doc = "Calibration in progress status."]
        #[inline(always)]
        pub fn set_calibip(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
        }
        #[doc = "Injected conversion in progress status."]
        #[inline(always)]
        pub const fn jcip(&self) -> bool {
            let val = (self.0 >> 13usize) & 0x01;
            val != 0
        }
        #[doc = "Injected conversion in progress status."]
        #[inline(always)]
        pub fn set_jcip(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
        }
        #[doc = "Regular conversion in progress status."]
        #[inline(always)]
        pub const fn rcip(&self) -> bool {
            let val = (self.0 >> 14usize) & 0x01;
            val != 0
        }
        #[doc = "Regular conversion in progress status."]
        #[inline(always)]
        pub fn set_rcip(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
        }
        #[doc = "Stabilization in progress status."]
        #[inline(always)]
        pub const fn stabip(&self) -> bool {
            let val = (self.0 >> 15usize) & 0x01;
            val != 0
        }
        #[doc = "Stabilization in progress status."]
        #[inline(always)]
        pub fn set_stabip(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
        }
        #[doc = "Initialization mode is ready."]
        #[inline(always)]
        pub const fn initrdy(&self) -> bool {
            let val = (self.0 >> 31usize) & 0x01;
            val != 0
        }
        #[doc = "Initialization mode is ready."]
        #[inline(always)]
        pub fn set_initrdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
        }
    }
    impl Default for Isr {
        #[inline(always)]
        fn default() -> Isr {
            Isr(0)
        }
    }
    impl core::fmt::Debug for Isr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Isr")
                .field("eocalf", &self.eocalf())
                .field("jeocf", &self.jeocf())
                .field("jovrf", &self.jovrf())
                .field("reocf", &self.reocf())
                .field("rovrf", &self.rovrf())
                .field("calibip", &self.calibip())
                .field("jcip", &self.jcip())
                .field("rcip", &self.rcip())
                .field("stabip", &self.stabip())
                .field("initrdy", &self.initrdy())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Isr {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Isr {{ eocalf: {=bool:?}, jeocf: {=bool:?}, jovrf: {=bool:?}, reocf: {=bool:?}, rovrf: {=bool:?}, calibip: {=bool:?}, jcip: {=bool:?}, rcip: {=bool:?}, stabip: {=bool:?}, initrdy: {=bool:?} }}" , self . eocalf () , self . jeocf () , self . jovrf () , self . reocf () , self . rovrf () , self . calibip () , self . jcip () , self . rcip () , self . stabip () , self . initrdy ())
        }
    }
    #[doc = "injected channel group selection register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Jchgr(pub u32);
    impl Jchgr {
        #[doc = "Injected channel group selection."]
        #[inline(always)]
        pub const fn jchg(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x01ff;
            val as u16
        }
        #[doc = "Injected channel group selection."]
        #[inline(always)]
        pub fn set_jchg(&mut self, val: u16) {
            self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize);
        }
    }
    impl Default for Jchgr {
        #[inline(always)]
        fn default() -> Jchgr {
            Jchgr(0)
        }
    }
    impl core::fmt::Debug for Jchgr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Jchgr").field("jchg", &self.jchg()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Jchgr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Jchgr {{ jchg: {=u16:?} }}", self.jchg())
        }
    }
    #[doc = "data register for injected group."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Jdatar(pub u32);
    impl Jdatar {
        #[doc = "Injected group conversion data."]
        #[inline(always)]
        pub const fn jdata(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0xffff;
            val as u16
        }
        #[doc = "Injected group conversion data."]
        #[inline(always)]
        pub fn set_jdata(&mut self, val: u16) {
            self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
        }
        #[doc = "Injected channel most recently converted."]
        #[inline(always)]
        pub const fn jdatach(&self) -> u8 {
            let val = (self.0 >> 24usize) & 0x0f;
            val as u8
        }
        #[doc = "Injected channel most recently converted."]
        #[inline(always)]
        pub fn set_jdatach(&mut self, val: u8) {
            self.0 = (self.0 & !(0x0f << 24usize)) | (((val as u32) & 0x0f) << 24usize);
        }
    }
    impl Default for Jdatar {
        #[inline(always)]
        fn default() -> Jdatar {
            Jdatar(0)
        }
    }
    impl core::fmt::Debug for Jdatar {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Jdatar")
                .field("jdata", &self.jdata())
                .field("jdatach", &self.jdatach())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Jdatar {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Jdatar {{ jdata: {=u16:?}, jdatach: {=u8:?} }}",
                self.jdata(),
                self.jdatach()
            )
        }
    }
    #[doc = "data register for the regular channel."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rdatar(pub u32);
    impl Rdatar {
        #[doc = "Regular channel conversion data."]
        #[inline(always)]
        pub const fn rdata(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0xffff;
            val as u16
        }
        #[doc = "Regular channel conversion data."]
        #[inline(always)]
        pub fn set_rdata(&mut self, val: u16) {
            self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
        }
    }
    impl Default for Rdatar {
        #[inline(always)]
        fn default() -> Rdatar {
            Rdatar(0)
        }
    }
    impl core::fmt::Debug for Rdatar {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Rdatar").field("rdata", &self.rdata()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Rdatar {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Rdatar {{ rdata: {=u16:?} }}", self.rdata())
        }
    }
}