py32f0/py32f003/
mod.rs

1/*!Peripheral access API for PY32F003XX microcontrollers (generated using svd2rust v0.28.0 (27eebb4 2022-12-25))
2
3You can find an overview of the generated API [here].
4
5API features to be included in the [next]
6svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.
7
8[here]: https://docs.rs/svd2rust/0.28.0/svd2rust/#peripheral-api
9[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased
10[repository]: https://github.com/rust-embedded/svd2rust*/
11use core::marker::PhantomData;
12use core::ops::Deref;
13///Number available in the NVIC for configuring priority
14pub const NVIC_PRIO_BITS: u8 = 4;
15#[cfg(feature = "rt")]
16pub use self::Interrupt as interrupt;
17pub use cortex_m::peripheral::Peripherals as CorePeripherals;
18pub use cortex_m::peripheral::{CBP, CPUID, DCB, DWT, FPB, ITM, MPU, NVIC, SCB, SYST, TPIU};
19#[cfg(feature = "rt")]
20pub use cortex_m_rt::interrupt;
21#[cfg(feature = "rt")]
22extern "C" {
23    fn WWDG();
24    fn PVD();
25    fn RTC();
26    fn FLASH();
27    fn RCC();
28    fn EXTI0_1();
29    fn EXTI2_3();
30    fn EXTI4_15();
31    fn DMA_CHANNEL1();
32    fn DMA_CHANNEL2_3();
33    fn ADC_COMP();
34    fn TIM1_BRK_UP_TRG_COM();
35    fn TIM1_CC();
36    fn TIM3();
37    fn TIM14();
38    fn TIM16();
39    fn TIM17();
40    fn I2C1();
41    fn SPI1();
42    fn USART1();
43    fn USART2();
44}
45#[doc(hidden)]
46pub union Vector {
47    _handler: unsafe extern "C" fn(),
48    _reserved: u32,
49}
50#[cfg(feature = "rt")]
51#[doc(hidden)]
52#[link_section = ".vector_table.interrupts"]
53#[no_mangle]
54pub static __INTERRUPTS: [Vector; 29] = [
55    Vector { _handler: WWDG },
56    Vector { _handler: PVD },
57    Vector { _handler: RTC },
58    Vector { _handler: FLASH },
59    Vector { _handler: RCC },
60    Vector { _handler: EXTI0_1 },
61    Vector { _handler: EXTI2_3 },
62    Vector { _handler: EXTI4_15 },
63    Vector { _reserved: 0 },
64    Vector {
65        _handler: DMA_CHANNEL1,
66    },
67    Vector {
68        _handler: DMA_CHANNEL2_3,
69    },
70    Vector { _reserved: 0 },
71    Vector { _handler: ADC_COMP },
72    Vector {
73        _handler: TIM1_BRK_UP_TRG_COM,
74    },
75    Vector { _handler: TIM1_CC },
76    Vector { _reserved: 0 },
77    Vector { _handler: TIM3 },
78    Vector { _reserved: 0 },
79    Vector { _reserved: 0 },
80    Vector { _handler: TIM14 },
81    Vector { _reserved: 0 },
82    Vector { _handler: TIM16 },
83    Vector { _handler: TIM17 },
84    Vector { _handler: I2C1 },
85    Vector { _reserved: 0 },
86    Vector { _handler: SPI1 },
87    Vector { _reserved: 0 },
88    Vector { _handler: USART1 },
89    Vector { _handler: USART2 },
90];
91///Enumeration of all the interrupts.
92#[derive(Copy, Clone, Debug, PartialEq, Eq)]
93#[repr(u16)]
94pub enum Interrupt {
95    ///0 - Window WatchDog Interrupt
96    WWDG = 0,
97    ///1 - PVD Interrupt through EXTI Lines 16
98    PVD = 1,
99    ///2 - RTC Interrupt through EXTI Lines 19
100    RTC = 2,
101    ///3 - FLASH global Interrupt
102    FLASH = 3,
103    ///4 - RCC global Interrupt
104    RCC = 4,
105    ///5 - EXTI Line 0 and 1 Interrupt
106    EXTI0_1 = 5,
107    ///6 - EXTI Line 2 and 3 Interrupt
108    EXTI2_3 = 6,
109    ///7 - EXTI Line 4 to 15 Interrupt
110    EXTI4_15 = 7,
111    ///9 - DMA Channel 1 Interrupt
112    DMA_CHANNEL1 = 9,
113    ///10 - DMA Channel 2 and Channel 3 Interrupt
114    DMA_CHANNEL2_3 = 10,
115    ///12 - ADC and COMP Interrupt through EXTI Lines 17 and 18
116    ADC_COMP = 12,
117    ///13 - TIM1 Break, Update, Trigger and Commutation Interrupt
118    TIM1_BRK_UP_TRG_COM = 13,
119    ///14 - TIM1 Capture Compare Interrupt
120    TIM1_CC = 14,
121    ///16 - TIM3 global Interrupt
122    TIM3 = 16,
123    ///19 - TIM14 global Interrupt
124    TIM14 = 19,
125    ///21 - TIM16 global Interrupt
126    TIM16 = 21,
127    ///22 - TIM17 global Interrupt
128    TIM17 = 22,
129    ///23 - I2C1 global Interrupt
130    I2C1 = 23,
131    ///25 - SPI1 global Interrupt
132    SPI1 = 25,
133    ///27 - USART1 global Interrupt
134    USART1 = 27,
135    ///28 - USART2 global Interrupt
136    USART2 = 28,
137}
138unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
139    #[inline(always)]
140    fn number(self) -> u16 {
141        self as u16
142    }
143}
144///Analog to Digital Converter
145pub struct ADC {
146    _marker: PhantomData<*const ()>,
147}
148unsafe impl Send for ADC {}
149impl ADC {
150    ///Pointer to the register block
151    pub const PTR: *const adc::RegisterBlock = 0x4001_2400 as *const _;
152    ///Return the pointer to the register block
153    #[inline(always)]
154    pub const fn ptr() -> *const adc::RegisterBlock {
155        Self::PTR
156    }
157}
158impl Deref for ADC {
159    type Target = adc::RegisterBlock;
160    #[inline(always)]
161    fn deref(&self) -> &Self::Target {
162        unsafe { &*Self::PTR }
163    }
164}
165impl core::fmt::Debug for ADC {
166    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
167        f.debug_struct("ADC").finish()
168    }
169}
170///Analog to Digital Converter
171pub mod adc;
172///Comparator
173pub struct COMP1 {
174    _marker: PhantomData<*const ()>,
175}
176unsafe impl Send for COMP1 {}
177impl COMP1 {
178    ///Pointer to the register block
179    pub const PTR: *const comp1::RegisterBlock = 0x4001_0200 as *const _;
180    ///Return the pointer to the register block
181    #[inline(always)]
182    pub const fn ptr() -> *const comp1::RegisterBlock {
183        Self::PTR
184    }
185}
186impl Deref for COMP1 {
187    type Target = comp1::RegisterBlock;
188    #[inline(always)]
189    fn deref(&self) -> &Self::Target {
190        unsafe { &*Self::PTR }
191    }
192}
193impl core::fmt::Debug for COMP1 {
194    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
195        f.debug_struct("COMP1").finish()
196    }
197}
198///Comparator
199pub mod comp1;
200///Comparator
201pub struct COMP2 {
202    _marker: PhantomData<*const ()>,
203}
204unsafe impl Send for COMP2 {}
205impl COMP2 {
206    ///Pointer to the register block
207    pub const PTR: *const comp2::RegisterBlock = 0x4001_0210 as *const _;
208    ///Return the pointer to the register block
209    #[inline(always)]
210    pub const fn ptr() -> *const comp2::RegisterBlock {
211        Self::PTR
212    }
213}
214impl Deref for COMP2 {
215    type Target = comp2::RegisterBlock;
216    #[inline(always)]
217    fn deref(&self) -> &Self::Target {
218        unsafe { &*Self::PTR }
219    }
220}
221impl core::fmt::Debug for COMP2 {
222    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
223        f.debug_struct("COMP2").finish()
224    }
225}
226///Comparator
227pub mod comp2;
228///Reset and clock control
229pub struct RCC {
230    _marker: PhantomData<*const ()>,
231}
232unsafe impl Send for RCC {}
233impl RCC {
234    ///Pointer to the register block
235    pub const PTR: *const rcc::RegisterBlock = 0x4002_1000 as *const _;
236    ///Return the pointer to the register block
237    #[inline(always)]
238    pub const fn ptr() -> *const rcc::RegisterBlock {
239        Self::PTR
240    }
241}
242impl Deref for RCC {
243    type Target = rcc::RegisterBlock;
244    #[inline(always)]
245    fn deref(&self) -> &Self::Target {
246        unsafe { &*Self::PTR }
247    }
248}
249impl core::fmt::Debug for RCC {
250    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
251        f.debug_struct("RCC").finish()
252    }
253}
254///Reset and clock control
255pub mod rcc;
256///Power control
257pub struct PWR {
258    _marker: PhantomData<*const ()>,
259}
260unsafe impl Send for PWR {}
261impl PWR {
262    ///Pointer to the register block
263    pub const PTR: *const pwr::RegisterBlock = 0x4000_7000 as *const _;
264    ///Return the pointer to the register block
265    #[inline(always)]
266    pub const fn ptr() -> *const pwr::RegisterBlock {
267        Self::PTR
268    }
269}
270impl Deref for PWR {
271    type Target = pwr::RegisterBlock;
272    #[inline(always)]
273    fn deref(&self) -> &Self::Target {
274        unsafe { &*Self::PTR }
275    }
276}
277impl core::fmt::Debug for PWR {
278    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
279        f.debug_struct("PWR").finish()
280    }
281}
282///Power control
283pub mod pwr;
284///General-purpose I/Os
285pub struct GPIOA {
286    _marker: PhantomData<*const ()>,
287}
288unsafe impl Send for GPIOA {}
289impl GPIOA {
290    ///Pointer to the register block
291    pub const PTR: *const gpioa::RegisterBlock = 0x5000_0000 as *const _;
292    ///Return the pointer to the register block
293    #[inline(always)]
294    pub const fn ptr() -> *const gpioa::RegisterBlock {
295        Self::PTR
296    }
297}
298impl Deref for GPIOA {
299    type Target = gpioa::RegisterBlock;
300    #[inline(always)]
301    fn deref(&self) -> &Self::Target {
302        unsafe { &*Self::PTR }
303    }
304}
305impl core::fmt::Debug for GPIOA {
306    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
307        f.debug_struct("GPIOA").finish()
308    }
309}
310///General-purpose I/Os
311pub mod gpioa;
312///General-purpose I/Os
313pub struct GPIOB {
314    _marker: PhantomData<*const ()>,
315}
316unsafe impl Send for GPIOB {}
317impl GPIOB {
318    ///Pointer to the register block
319    pub const PTR: *const gpiob::RegisterBlock = 0x5000_0400 as *const _;
320    ///Return the pointer to the register block
321    #[inline(always)]
322    pub const fn ptr() -> *const gpiob::RegisterBlock {
323        Self::PTR
324    }
325}
326impl Deref for GPIOB {
327    type Target = gpiob::RegisterBlock;
328    #[inline(always)]
329    fn deref(&self) -> &Self::Target {
330        unsafe { &*Self::PTR }
331    }
332}
333impl core::fmt::Debug for GPIOB {
334    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
335        f.debug_struct("GPIOB").finish()
336    }
337}
338///General-purpose I/Os
339pub mod gpiob;
340///General-purpose I/Os
341pub struct GPIOF {
342    _marker: PhantomData<*const ()>,
343}
344unsafe impl Send for GPIOF {}
345impl GPIOF {
346    ///Pointer to the register block
347    pub const PTR: *const gpiob::RegisterBlock = 0x5000_1400 as *const _;
348    ///Return the pointer to the register block
349    #[inline(always)]
350    pub const fn ptr() -> *const gpiob::RegisterBlock {
351        Self::PTR
352    }
353}
354impl Deref for GPIOF {
355    type Target = gpiob::RegisterBlock;
356    #[inline(always)]
357    fn deref(&self) -> &Self::Target {
358        unsafe { &*Self::PTR }
359    }
360}
361impl core::fmt::Debug for GPIOF {
362    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
363        f.debug_struct("GPIOF").finish()
364    }
365}
366///General-purpose I/Os
367pub use self::gpiob as gpiof;
368///External interrupt/event controller
369pub struct EXTI {
370    _marker: PhantomData<*const ()>,
371}
372unsafe impl Send for EXTI {}
373impl EXTI {
374    ///Pointer to the register block
375    pub const PTR: *const exti::RegisterBlock = 0x4002_1800 as *const _;
376    ///Return the pointer to the register block
377    #[inline(always)]
378    pub const fn ptr() -> *const exti::RegisterBlock {
379        Self::PTR
380    }
381}
382impl Deref for EXTI {
383    type Target = exti::RegisterBlock;
384    #[inline(always)]
385    fn deref(&self) -> &Self::Target {
386        unsafe { &*Self::PTR }
387    }
388}
389impl core::fmt::Debug for EXTI {
390    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
391        f.debug_struct("EXTI").finish()
392    }
393}
394///External interrupt/event controller
395pub mod exti;
396///Low power timer
397pub struct LPTIM {
398    _marker: PhantomData<*const ()>,
399}
400unsafe impl Send for LPTIM {}
401impl LPTIM {
402    ///Pointer to the register block
403    pub const PTR: *const lptim::RegisterBlock = 0x4000_7c00 as *const _;
404    ///Return the pointer to the register block
405    #[inline(always)]
406    pub const fn ptr() -> *const lptim::RegisterBlock {
407        Self::PTR
408    }
409}
410impl Deref for LPTIM {
411    type Target = lptim::RegisterBlock;
412    #[inline(always)]
413    fn deref(&self) -> &Self::Target {
414        unsafe { &*Self::PTR }
415    }
416}
417impl core::fmt::Debug for LPTIM {
418    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
419        f.debug_struct("LPTIM").finish()
420    }
421}
422///Low power timer
423pub mod lptim;
424///Universal synchronous asynchronous receiver transmitter
425pub struct USART1 {
426    _marker: PhantomData<*const ()>,
427}
428unsafe impl Send for USART1 {}
429impl USART1 {
430    ///Pointer to the register block
431    pub const PTR: *const usart1::RegisterBlock = 0x4001_3800 as *const _;
432    ///Return the pointer to the register block
433    #[inline(always)]
434    pub const fn ptr() -> *const usart1::RegisterBlock {
435        Self::PTR
436    }
437}
438impl Deref for USART1 {
439    type Target = usart1::RegisterBlock;
440    #[inline(always)]
441    fn deref(&self) -> &Self::Target {
442        unsafe { &*Self::PTR }
443    }
444}
445impl core::fmt::Debug for USART1 {
446    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
447        f.debug_struct("USART1").finish()
448    }
449}
450///Universal synchronous asynchronous receiver transmitter
451pub mod usart1;
452///Universal synchronous asynchronous receiver transmitter
453pub struct USART2 {
454    _marker: PhantomData<*const ()>,
455}
456unsafe impl Send for USART2 {}
457impl USART2 {
458    ///Pointer to the register block
459    pub const PTR: *const usart1::RegisterBlock = 0x4000_4400 as *const _;
460    ///Return the pointer to the register block
461    #[inline(always)]
462    pub const fn ptr() -> *const usart1::RegisterBlock {
463        Self::PTR
464    }
465}
466impl Deref for USART2 {
467    type Target = usart1::RegisterBlock;
468    #[inline(always)]
469    fn deref(&self) -> &Self::Target {
470        unsafe { &*Self::PTR }
471    }
472}
473impl core::fmt::Debug for USART2 {
474    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
475        f.debug_struct("USART2").finish()
476    }
477}
478///Universal synchronous asynchronous receiver transmitter
479pub use self::usart1 as usart2;
480///Real time clock
481pub struct RTC {
482    _marker: PhantomData<*const ()>,
483}
484unsafe impl Send for RTC {}
485impl RTC {
486    ///Pointer to the register block
487    pub const PTR: *const rtc::RegisterBlock = 0x4000_2800 as *const _;
488    ///Return the pointer to the register block
489    #[inline(always)]
490    pub const fn ptr() -> *const rtc::RegisterBlock {
491        Self::PTR
492    }
493}
494impl Deref for RTC {
495    type Target = rtc::RegisterBlock;
496    #[inline(always)]
497    fn deref(&self) -> &Self::Target {
498        unsafe { &*Self::PTR }
499    }
500}
501impl core::fmt::Debug for RTC {
502    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
503        f.debug_struct("RTC").finish()
504    }
505}
506///Real time clock
507pub mod rtc;
508///Independent watchdog
509pub struct IWDG {
510    _marker: PhantomData<*const ()>,
511}
512unsafe impl Send for IWDG {}
513impl IWDG {
514    ///Pointer to the register block
515    pub const PTR: *const iwdg::RegisterBlock = 0x4000_3000 as *const _;
516    ///Return the pointer to the register block
517    #[inline(always)]
518    pub const fn ptr() -> *const iwdg::RegisterBlock {
519        Self::PTR
520    }
521}
522impl Deref for IWDG {
523    type Target = iwdg::RegisterBlock;
524    #[inline(always)]
525    fn deref(&self) -> &Self::Target {
526        unsafe { &*Self::PTR }
527    }
528}
529impl core::fmt::Debug for IWDG {
530    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
531        f.debug_struct("IWDG").finish()
532    }
533}
534///Independent watchdog
535pub mod iwdg;
536///Window watchdog
537pub struct WWDG {
538    _marker: PhantomData<*const ()>,
539}
540unsafe impl Send for WWDG {}
541impl WWDG {
542    ///Pointer to the register block
543    pub const PTR: *const wwdg::RegisterBlock = 0x4000_2c00 as *const _;
544    ///Return the pointer to the register block
545    #[inline(always)]
546    pub const fn ptr() -> *const wwdg::RegisterBlock {
547        Self::PTR
548    }
549}
550impl Deref for WWDG {
551    type Target = wwdg::RegisterBlock;
552    #[inline(always)]
553    fn deref(&self) -> &Self::Target {
554        unsafe { &*Self::PTR }
555    }
556}
557impl core::fmt::Debug for WWDG {
558    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
559        f.debug_struct("WWDG").finish()
560    }
561}
562///Window watchdog
563pub mod wwdg;
564///Advanced timer
565pub struct TIM1 {
566    _marker: PhantomData<*const ()>,
567}
568unsafe impl Send for TIM1 {}
569impl TIM1 {
570    ///Pointer to the register block
571    pub const PTR: *const tim1::RegisterBlock = 0x4001_2c00 as *const _;
572    ///Return the pointer to the register block
573    #[inline(always)]
574    pub const fn ptr() -> *const tim1::RegisterBlock {
575        Self::PTR
576    }
577}
578impl Deref for TIM1 {
579    type Target = tim1::RegisterBlock;
580    #[inline(always)]
581    fn deref(&self) -> &Self::Target {
582        unsafe { &*Self::PTR }
583    }
584}
585impl core::fmt::Debug for TIM1 {
586    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
587        f.debug_struct("TIM1").finish()
588    }
589}
590///Advanced timer
591pub mod tim1;
592///General purpose timer
593pub struct TIM3 {
594    _marker: PhantomData<*const ()>,
595}
596unsafe impl Send for TIM3 {}
597impl TIM3 {
598    ///Pointer to the register block
599    pub const PTR: *const tim3::RegisterBlock = 0x4000_0400 as *const _;
600    ///Return the pointer to the register block
601    #[inline(always)]
602    pub const fn ptr() -> *const tim3::RegisterBlock {
603        Self::PTR
604    }
605}
606impl Deref for TIM3 {
607    type Target = tim3::RegisterBlock;
608    #[inline(always)]
609    fn deref(&self) -> &Self::Target {
610        unsafe { &*Self::PTR }
611    }
612}
613impl core::fmt::Debug for TIM3 {
614    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
615        f.debug_struct("TIM3").finish()
616    }
617}
618///General purpose timer
619pub mod tim3;
620///General purpose timer
621pub struct TIM14 {
622    _marker: PhantomData<*const ()>,
623}
624unsafe impl Send for TIM14 {}
625impl TIM14 {
626    ///Pointer to the register block
627    pub const PTR: *const tim14::RegisterBlock = 0x4000_2000 as *const _;
628    ///Return the pointer to the register block
629    #[inline(always)]
630    pub const fn ptr() -> *const tim14::RegisterBlock {
631        Self::PTR
632    }
633}
634impl Deref for TIM14 {
635    type Target = tim14::RegisterBlock;
636    #[inline(always)]
637    fn deref(&self) -> &Self::Target {
638        unsafe { &*Self::PTR }
639    }
640}
641impl core::fmt::Debug for TIM14 {
642    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
643        f.debug_struct("TIM14").finish()
644    }
645}
646///General purpose timer
647pub mod tim14;
648///General purpose timer
649pub struct TIM16 {
650    _marker: PhantomData<*const ()>,
651}
652unsafe impl Send for TIM16 {}
653impl TIM16 {
654    ///Pointer to the register block
655    pub const PTR: *const tim16::RegisterBlock = 0x4001_4400 as *const _;
656    ///Return the pointer to the register block
657    #[inline(always)]
658    pub const fn ptr() -> *const tim16::RegisterBlock {
659        Self::PTR
660    }
661}
662impl Deref for TIM16 {
663    type Target = tim16::RegisterBlock;
664    #[inline(always)]
665    fn deref(&self) -> &Self::Target {
666        unsafe { &*Self::PTR }
667    }
668}
669impl core::fmt::Debug for TIM16 {
670    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
671        f.debug_struct("TIM16").finish()
672    }
673}
674///General purpose timer
675pub mod tim16;
676///General purpose timer
677pub struct TIM17 {
678    _marker: PhantomData<*const ()>,
679}
680unsafe impl Send for TIM17 {}
681impl TIM17 {
682    ///Pointer to the register block
683    pub const PTR: *const tim16::RegisterBlock = 0x4001_4800 as *const _;
684    ///Return the pointer to the register block
685    #[inline(always)]
686    pub const fn ptr() -> *const tim16::RegisterBlock {
687        Self::PTR
688    }
689}
690impl Deref for TIM17 {
691    type Target = tim16::RegisterBlock;
692    #[inline(always)]
693    fn deref(&self) -> &Self::Target {
694        unsafe { &*Self::PTR }
695    }
696}
697impl core::fmt::Debug for TIM17 {
698    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
699        f.debug_struct("TIM17").finish()
700    }
701}
702///General purpose timer
703pub use self::tim16 as tim17;
704///System configuration controller
705pub struct SYSCFG {
706    _marker: PhantomData<*const ()>,
707}
708unsafe impl Send for SYSCFG {}
709impl SYSCFG {
710    ///Pointer to the register block
711    pub const PTR: *const syscfg::RegisterBlock = 0x4001_0000 as *const _;
712    ///Return the pointer to the register block
713    #[inline(always)]
714    pub const fn ptr() -> *const syscfg::RegisterBlock {
715        Self::PTR
716    }
717}
718impl Deref for SYSCFG {
719    type Target = syscfg::RegisterBlock;
720    #[inline(always)]
721    fn deref(&self) -> &Self::Target {
722        unsafe { &*Self::PTR }
723    }
724}
725impl core::fmt::Debug for SYSCFG {
726    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
727        f.debug_struct("SYSCFG").finish()
728    }
729}
730///System configuration controller
731pub mod syscfg;
732///Direct memory access
733pub struct DMA {
734    _marker: PhantomData<*const ()>,
735}
736unsafe impl Send for DMA {}
737impl DMA {
738    ///Pointer to the register block
739    pub const PTR: *const dma::RegisterBlock = 0x4002_0000 as *const _;
740    ///Return the pointer to the register block
741    #[inline(always)]
742    pub const fn ptr() -> *const dma::RegisterBlock {
743        Self::PTR
744    }
745}
746impl Deref for DMA {
747    type Target = dma::RegisterBlock;
748    #[inline(always)]
749    fn deref(&self) -> &Self::Target {
750        unsafe { &*Self::PTR }
751    }
752}
753impl core::fmt::Debug for DMA {
754    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
755        f.debug_struct("DMA").finish()
756    }
757}
758///Direct memory access
759pub mod dma;
760///Flash
761pub struct FLASH {
762    _marker: PhantomData<*const ()>,
763}
764unsafe impl Send for FLASH {}
765impl FLASH {
766    ///Pointer to the register block
767    pub const PTR: *const flash::RegisterBlock = 0x4002_2000 as *const _;
768    ///Return the pointer to the register block
769    #[inline(always)]
770    pub const fn ptr() -> *const flash::RegisterBlock {
771        Self::PTR
772    }
773}
774impl Deref for FLASH {
775    type Target = flash::RegisterBlock;
776    #[inline(always)]
777    fn deref(&self) -> &Self::Target {
778        unsafe { &*Self::PTR }
779    }
780}
781impl core::fmt::Debug for FLASH {
782    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
783        f.debug_struct("FLASH").finish()
784    }
785}
786///Flash
787pub mod flash;
788///CRC calculation unit
789pub struct CRC {
790    _marker: PhantomData<*const ()>,
791}
792unsafe impl Send for CRC {}
793impl CRC {
794    ///Pointer to the register block
795    pub const PTR: *const crc::RegisterBlock = 0x4002_3000 as *const _;
796    ///Return the pointer to the register block
797    #[inline(always)]
798    pub const fn ptr() -> *const crc::RegisterBlock {
799        Self::PTR
800    }
801}
802impl Deref for CRC {
803    type Target = crc::RegisterBlock;
804    #[inline(always)]
805    fn deref(&self) -> &Self::Target {
806        unsafe { &*Self::PTR }
807    }
808}
809impl core::fmt::Debug for CRC {
810    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
811        f.debug_struct("CRC").finish()
812    }
813}
814///CRC calculation unit
815pub mod crc;
816///Serial peripheral interface
817pub struct SPI1 {
818    _marker: PhantomData<*const ()>,
819}
820unsafe impl Send for SPI1 {}
821impl SPI1 {
822    ///Pointer to the register block
823    pub const PTR: *const spi1::RegisterBlock = 0x4001_3000 as *const _;
824    ///Return the pointer to the register block
825    #[inline(always)]
826    pub const fn ptr() -> *const spi1::RegisterBlock {
827        Self::PTR
828    }
829}
830impl Deref for SPI1 {
831    type Target = spi1::RegisterBlock;
832    #[inline(always)]
833    fn deref(&self) -> &Self::Target {
834        unsafe { &*Self::PTR }
835    }
836}
837impl core::fmt::Debug for SPI1 {
838    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
839        f.debug_struct("SPI1").finish()
840    }
841}
842///Serial peripheral interface
843pub mod spi1;
844///Inter integrated circuit
845pub struct I2C {
846    _marker: PhantomData<*const ()>,
847}
848unsafe impl Send for I2C {}
849impl I2C {
850    ///Pointer to the register block
851    pub const PTR: *const i2c::RegisterBlock = 0x4000_5400 as *const _;
852    ///Return the pointer to the register block
853    #[inline(always)]
854    pub const fn ptr() -> *const i2c::RegisterBlock {
855        Self::PTR
856    }
857}
858impl Deref for I2C {
859    type Target = i2c::RegisterBlock;
860    #[inline(always)]
861    fn deref(&self) -> &Self::Target {
862        unsafe { &*Self::PTR }
863    }
864}
865impl core::fmt::Debug for I2C {
866    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
867        f.debug_struct("I2C").finish()
868    }
869}
870///Inter integrated circuit
871pub mod i2c;
872///Debug support
873pub struct DBG {
874    _marker: PhantomData<*const ()>,
875}
876unsafe impl Send for DBG {}
877impl DBG {
878    ///Pointer to the register block
879    pub const PTR: *const dbg::RegisterBlock = 0x4001_5800 as *const _;
880    ///Return the pointer to the register block
881    #[inline(always)]
882    pub const fn ptr() -> *const dbg::RegisterBlock {
883        Self::PTR
884    }
885}
886impl Deref for DBG {
887    type Target = dbg::RegisterBlock;
888    #[inline(always)]
889    fn deref(&self) -> &Self::Target {
890        unsafe { &*Self::PTR }
891    }
892}
893impl core::fmt::Debug for DBG {
894    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
895        f.debug_struct("DBG").finish()
896    }
897}
898///Debug support
899pub mod dbg;
900#[no_mangle]
901static mut DEVICE_PERIPHERALS: bool = false;
902/// All the peripherals.
903#[allow(non_snake_case)]
904pub struct Peripherals {
905    ///ADC
906    pub ADC: ADC,
907    ///COMP1
908    pub COMP1: COMP1,
909    ///COMP2
910    pub COMP2: COMP2,
911    ///RCC
912    pub RCC: RCC,
913    ///PWR
914    pub PWR: PWR,
915    ///GPIOA
916    pub GPIOA: GPIOA,
917    ///GPIOB
918    pub GPIOB: GPIOB,
919    ///GPIOF
920    pub GPIOF: GPIOF,
921    ///EXTI
922    pub EXTI: EXTI,
923    ///LPTIM
924    pub LPTIM: LPTIM,
925    ///USART1
926    pub USART1: USART1,
927    ///USART2
928    pub USART2: USART2,
929    ///RTC
930    pub RTC: RTC,
931    ///IWDG
932    pub IWDG: IWDG,
933    ///WWDG
934    pub WWDG: WWDG,
935    ///TIM1
936    pub TIM1: TIM1,
937    ///TIM3
938    pub TIM3: TIM3,
939    ///TIM14
940    pub TIM14: TIM14,
941    ///TIM16
942    pub TIM16: TIM16,
943    ///TIM17
944    pub TIM17: TIM17,
945    ///SYSCFG
946    pub SYSCFG: SYSCFG,
947    ///DMA
948    pub DMA: DMA,
949    ///FLASH
950    pub FLASH: FLASH,
951    ///CRC
952    pub CRC: CRC,
953    ///SPI1
954    pub SPI1: SPI1,
955    ///I2C
956    pub I2C: I2C,
957    ///DBG
958    pub DBG: DBG,
959}
960impl Peripherals {
961    /// Returns all the peripherals *once*.
962    #[cfg(feature = "critical-section")]
963    #[inline]
964    pub fn take() -> Option<Self> {
965        critical_section::with(|_| {
966            if unsafe { DEVICE_PERIPHERALS } {
967                return None;
968            }
969            Some(unsafe { Peripherals::steal() })
970        })
971    }
972    /// Unchecked version of `Peripherals::take`.
973    ///
974    /// # Safety
975    ///
976    /// Each of the returned peripherals must be used at most once.
977    #[inline]
978    pub unsafe fn steal() -> Self {
979        DEVICE_PERIPHERALS = true;
980        Peripherals {
981            ADC: ADC {
982                _marker: PhantomData,
983            },
984            COMP1: COMP1 {
985                _marker: PhantomData,
986            },
987            COMP2: COMP2 {
988                _marker: PhantomData,
989            },
990            RCC: RCC {
991                _marker: PhantomData,
992            },
993            PWR: PWR {
994                _marker: PhantomData,
995            },
996            GPIOA: GPIOA {
997                _marker: PhantomData,
998            },
999            GPIOB: GPIOB {
1000                _marker: PhantomData,
1001            },
1002            GPIOF: GPIOF {
1003                _marker: PhantomData,
1004            },
1005            EXTI: EXTI {
1006                _marker: PhantomData,
1007            },
1008            LPTIM: LPTIM {
1009                _marker: PhantomData,
1010            },
1011            USART1: USART1 {
1012                _marker: PhantomData,
1013            },
1014            USART2: USART2 {
1015                _marker: PhantomData,
1016            },
1017            RTC: RTC {
1018                _marker: PhantomData,
1019            },
1020            IWDG: IWDG {
1021                _marker: PhantomData,
1022            },
1023            WWDG: WWDG {
1024                _marker: PhantomData,
1025            },
1026            TIM1: TIM1 {
1027                _marker: PhantomData,
1028            },
1029            TIM3: TIM3 {
1030                _marker: PhantomData,
1031            },
1032            TIM14: TIM14 {
1033                _marker: PhantomData,
1034            },
1035            TIM16: TIM16 {
1036                _marker: PhantomData,
1037            },
1038            TIM17: TIM17 {
1039                _marker: PhantomData,
1040            },
1041            SYSCFG: SYSCFG {
1042                _marker: PhantomData,
1043            },
1044            DMA: DMA {
1045                _marker: PhantomData,
1046            },
1047            FLASH: FLASH {
1048                _marker: PhantomData,
1049            },
1050            CRC: CRC {
1051                _marker: PhantomData,
1052            },
1053            SPI1: SPI1 {
1054                _marker: PhantomData,
1055            },
1056            I2C: I2C {
1057                _marker: PhantomData,
1058            },
1059            DBG: DBG {
1060                _marker: PhantomData,
1061            },
1062        }
1063    }
1064}