PY32f001xx_pac/
lib.rs

1#![doc = "Peripheral access API for PY32F0XX_DFP microcontrollers (generated using svd2rust v0.25.1 ( ))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next]
2svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.\n\n[here]: https://docs.rs/svd2rust/0.25.1/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
3#![deny(const_err)]
4#![deny(dead_code)]
5#![deny(improper_ctypes)]
6#![deny(missing_docs)]
7#![deny(no_mangle_generic_items)]
8#![deny(non_shorthand_field_patterns)]
9#![deny(overflowing_literals)]
10#![deny(path_statements)]
11#![deny(patterns_in_fns_without_body)]
12#![deny(private_in_public)]
13#![deny(unconditional_recursion)]
14#![deny(unused_allocation)]
15#![deny(unused_comparisons)]
16#![deny(unused_parens)]
17#![deny(while_true)]
18#![allow(non_camel_case_types)]
19#![allow(non_snake_case)]
20#![no_std]
21use core::marker::PhantomData;
22use core::ops::Deref;
23#[doc = r"Number available in the NVIC for configuring priority"]
24pub const NVIC_PRIO_BITS: u8 = 4;
25#[cfg(feature = "rt")]
26pub use self::Interrupt as interrupt;
27pub use cortex_m::peripheral::Peripherals as CorePeripherals;
28pub use cortex_m::peripheral::{CBP, CPUID, DCB, DWT, FPB, ITM, MPU, NVIC, SCB, SYST, TPIU};
29#[cfg(feature = "rt")]
30pub use cortex_m_rt::interrupt;
31#[allow(unused_imports)]
32use generic::*;
33#[doc = r"Common register and bit access and modify traits"]
34pub mod generic;
35#[cfg(feature = "rt")]
36extern "C" {
37    fn FLASH();
38    fn RCC();
39    fn EXTI0_1();
40    fn EXTI2_3();
41    fn EXTI4_15();
42    fn ADC_COMP();
43    fn TIM1_BRK_UP_TRG_COM();
44    fn TIM1_CC();
45    fn LPTIM1_DAC();
46    fn TIM14();
47}
48#[doc(hidden)]
49pub union Vector {
50    _handler: unsafe extern "C" fn(),
51    _reserved: u32,
52}
53#[cfg(feature = "rt")]
54#[doc(hidden)]
55#[link_section = ".vector_table.interrupts"]
56#[no_mangle]
57pub static __INTERRUPTS: [Vector; 20] = [
58    Vector { _reserved: 0 },
59    Vector { _reserved: 0 },
60    Vector { _reserved: 0 },
61    Vector { _handler: FLASH },
62    Vector { _handler: RCC },
63    Vector { _handler: EXTI0_1 },
64    Vector { _handler: EXTI2_3 },
65    Vector { _handler: EXTI4_15 },
66    Vector { _reserved: 0 },
67    Vector { _reserved: 0 },
68    Vector { _reserved: 0 },
69    Vector { _reserved: 0 },
70    Vector { _handler: ADC_COMP },
71    Vector {
72        _handler: TIM1_BRK_UP_TRG_COM,
73    },
74    Vector { _handler: TIM1_CC },
75    Vector { _reserved: 0 },
76    Vector { _reserved: 0 },
77    Vector {
78        _handler: LPTIM1_DAC,
79    },
80    Vector { _reserved: 0 },
81    Vector { _handler: TIM14 },
82];
83#[doc = r"Enumeration of all the interrupts."]
84#[derive(Copy, Clone, Debug, PartialEq, Eq)]
85#[repr(u16)]
86pub enum Interrupt {
87    #[doc = "3 - FLASH global Interrupt"]
88    FLASH = 3,
89    #[doc = "4 - RCC global Interrupt"]
90    RCC = 4,
91    #[doc = "5 - EXTI Line 0 and 1 Interrupt"]
92    EXTI0_1 = 5,
93    #[doc = "6 - EXTI Line 2 and 3 Interrupt"]
94    EXTI2_3 = 6,
95    #[doc = "7 - EXTI Line 4 to 15 Interrupt"]
96    EXTI4_15 = 7,
97    #[doc = "12 - ADC and COMP Interrupt"]
98    ADC_COMP = 12,
99    #[doc = "13 - TIM1 Break, Update, Trigger and Commutation Interrupt"]
100    TIM1_BRK_UP_TRG_COM = 13,
101    #[doc = "14 - TIM1 Capture Compare Interrupt"]
102    TIM1_CC = 14,
103    #[doc = "17 - LPTIM1, DAC global Interrupts"]
104    LPTIM1_DAC = 17,
105    #[doc = "19 - TIM14 global Interrupt"]
106    TIM14 = 19,
107}
108unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
109    #[inline(always)]
110    fn number(self) -> u16 {
111        self as u16
112    }
113}
114#[doc = "Comparator 1"]
115pub struct COMP1 {
116    _marker: PhantomData<*const ()>,
117}
118unsafe impl Send for COMP1 {}
119impl COMP1 {
120    #[doc = r"Pointer to the register block"]
121    pub const PTR: *const comp1::RegisterBlock = 0x4001_0200 as *const _;
122    #[doc = r"Return the pointer to the register block"]
123    #[inline(always)]
124    pub const fn ptr() -> *const comp1::RegisterBlock {
125        Self::PTR
126    }
127}
128impl Deref for COMP1 {
129    type Target = comp1::RegisterBlock;
130    #[inline(always)]
131    fn deref(&self) -> &Self::Target {
132        unsafe { &*Self::PTR }
133    }
134}
135impl core::fmt::Debug for COMP1 {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("COMP1").finish()
138    }
139}
140#[doc = "Comparator 1"]
141pub mod comp1;
142#[doc = "Comparator2"]
143pub struct COMP2 {
144    _marker: PhantomData<*const ()>,
145}
146unsafe impl Send for COMP2 {}
147impl COMP2 {
148    #[doc = r"Pointer to the register block"]
149    pub const PTR: *const comp2::RegisterBlock = 0x4001_0210 as *const _;
150    #[doc = r"Return the pointer to the register block"]
151    #[inline(always)]
152    pub const fn ptr() -> *const comp2::RegisterBlock {
153        Self::PTR
154    }
155}
156impl Deref for COMP2 {
157    type Target = comp2::RegisterBlock;
158    #[inline(always)]
159    fn deref(&self) -> &Self::Target {
160        unsafe { &*Self::PTR }
161    }
162}
163impl core::fmt::Debug for COMP2 {
164    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
165        f.debug_struct("COMP2").finish()
166    }
167}
168#[doc = "Comparator2"]
169pub mod comp2;
170#[doc = "Reset and clock control"]
171pub struct RCC {
172    _marker: PhantomData<*const ()>,
173}
174unsafe impl Send for RCC {}
175impl RCC {
176    #[doc = r"Pointer to the register block"]
177    pub const PTR: *const rcc::RegisterBlock = 0x4002_1000 as *const _;
178    #[doc = r"Return the pointer to the register block"]
179    #[inline(always)]
180    pub const fn ptr() -> *const rcc::RegisterBlock {
181        Self::PTR
182    }
183}
184impl Deref for RCC {
185    type Target = rcc::RegisterBlock;
186    #[inline(always)]
187    fn deref(&self) -> &Self::Target {
188        unsafe { &*Self::PTR }
189    }
190}
191impl core::fmt::Debug for RCC {
192    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
193        f.debug_struct("RCC").finish()
194    }
195}
196#[doc = "Reset and clock control"]
197pub mod rcc;
198#[doc = "Power control"]
199pub struct PWR {
200    _marker: PhantomData<*const ()>,
201}
202unsafe impl Send for PWR {}
203impl PWR {
204    #[doc = r"Pointer to the register block"]
205    pub const PTR: *const pwr::RegisterBlock = 0x4000_7000 as *const _;
206    #[doc = r"Return the pointer to the register block"]
207    #[inline(always)]
208    pub const fn ptr() -> *const pwr::RegisterBlock {
209        Self::PTR
210    }
211}
212impl Deref for PWR {
213    type Target = pwr::RegisterBlock;
214    #[inline(always)]
215    fn deref(&self) -> &Self::Target {
216        unsafe { &*Self::PTR }
217    }
218}
219impl core::fmt::Debug for PWR {
220    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
221        f.debug_struct("PWR").finish()
222    }
223}
224#[doc = "Power control"]
225pub mod pwr;
226#[doc = "General-purpose I/Os"]
227pub struct GPIOA {
228    _marker: PhantomData<*const ()>,
229}
230unsafe impl Send for GPIOA {}
231impl GPIOA {
232    #[doc = r"Pointer to the register block"]
233    pub const PTR: *const gpioa::RegisterBlock = 0x5000_0000 as *const _;
234    #[doc = r"Return the pointer to the register block"]
235    #[inline(always)]
236    pub const fn ptr() -> *const gpioa::RegisterBlock {
237        Self::PTR
238    }
239}
240impl Deref for GPIOA {
241    type Target = gpioa::RegisterBlock;
242    #[inline(always)]
243    fn deref(&self) -> &Self::Target {
244        unsafe { &*Self::PTR }
245    }
246}
247impl core::fmt::Debug for GPIOA {
248    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
249        f.debug_struct("GPIOA").finish()
250    }
251}
252#[doc = "General-purpose I/Os"]
253pub mod gpioa;
254#[doc = "General-purpose I/Os"]
255pub struct GPIOB {
256    _marker: PhantomData<*const ()>,
257}
258unsafe impl Send for GPIOB {}
259impl GPIOB {
260    #[doc = r"Pointer to the register block"]
261    pub const PTR: *const gpiob::RegisterBlock = 0x5000_0400 as *const _;
262    #[doc = r"Return the pointer to the register block"]
263    #[inline(always)]
264    pub const fn ptr() -> *const gpiob::RegisterBlock {
265        Self::PTR
266    }
267}
268impl Deref for GPIOB {
269    type Target = gpiob::RegisterBlock;
270    #[inline(always)]
271    fn deref(&self) -> &Self::Target {
272        unsafe { &*Self::PTR }
273    }
274}
275impl core::fmt::Debug for GPIOB {
276    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
277        f.debug_struct("GPIOB").finish()
278    }
279}
280#[doc = "General-purpose I/Os"]
281pub mod gpiob;
282#[doc = "General-purpose I/Os"]
283pub struct GPIOC {
284    _marker: PhantomData<*const ()>,
285}
286unsafe impl Send for GPIOC {}
287impl GPIOC {
288    #[doc = r"Pointer to the register block"]
289    pub const PTR: *const gpiob::RegisterBlock = 0x5000_0800 as *const _;
290    #[doc = r"Return the pointer to the register block"]
291    #[inline(always)]
292    pub const fn ptr() -> *const gpiob::RegisterBlock {
293        Self::PTR
294    }
295}
296impl Deref for GPIOC {
297    type Target = gpiob::RegisterBlock;
298    #[inline(always)]
299    fn deref(&self) -> &Self::Target {
300        unsafe { &*Self::PTR }
301    }
302}
303impl core::fmt::Debug for GPIOC {
304    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
305        f.debug_struct("GPIOC").finish()
306    }
307}
308#[doc = "General-purpose I/Os"]
309pub use gpiob as gpioc;
310#[doc = "External interrupt/event controller"]
311pub struct EXTI {
312    _marker: PhantomData<*const ()>,
313}
314unsafe impl Send for EXTI {}
315impl EXTI {
316    #[doc = r"Pointer to the register block"]
317    pub const PTR: *const exti::RegisterBlock = 0x4002_1800 as *const _;
318    #[doc = r"Return the pointer to the register block"]
319    #[inline(always)]
320    pub const fn ptr() -> *const exti::RegisterBlock {
321        Self::PTR
322    }
323}
324impl Deref for EXTI {
325    type Target = exti::RegisterBlock;
326    #[inline(always)]
327    fn deref(&self) -> &Self::Target {
328        unsafe { &*Self::PTR }
329    }
330}
331impl core::fmt::Debug for EXTI {
332    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
333        f.debug_struct("EXTI").finish()
334    }
335}
336#[doc = "External interrupt/event controller"]
337pub mod exti;
338#[doc = "Low power timer"]
339pub struct LPTIM1 {
340    _marker: PhantomData<*const ()>,
341}
342unsafe impl Send for LPTIM1 {}
343impl LPTIM1 {
344    #[doc = r"Pointer to the register block"]
345    pub const PTR: *const lptim1::RegisterBlock = 0x4000_7c00 as *const _;
346    #[doc = r"Return the pointer to the register block"]
347    #[inline(always)]
348    pub const fn ptr() -> *const lptim1::RegisterBlock {
349        Self::PTR
350    }
351}
352impl Deref for LPTIM1 {
353    type Target = lptim1::RegisterBlock;
354    #[inline(always)]
355    fn deref(&self) -> &Self::Target {
356        unsafe { &*Self::PTR }
357    }
358}
359impl core::fmt::Debug for LPTIM1 {
360    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
361        f.debug_struct("LPTIM1").finish()
362    }
363}
364#[doc = "Low power timer"]
365pub mod lptim1;
366#[doc = "Independent watchdog"]
367pub struct IWDG {
368    _marker: PhantomData<*const ()>,
369}
370unsafe impl Send for IWDG {}
371impl IWDG {
372    #[doc = r"Pointer to the register block"]
373    pub const PTR: *const iwdg::RegisterBlock = 0x4000_3000 as *const _;
374    #[doc = r"Return the pointer to the register block"]
375    #[inline(always)]
376    pub const fn ptr() -> *const iwdg::RegisterBlock {
377        Self::PTR
378    }
379}
380impl Deref for IWDG {
381    type Target = iwdg::RegisterBlock;
382    #[inline(always)]
383    fn deref(&self) -> &Self::Target {
384        unsafe { &*Self::PTR }
385    }
386}
387impl core::fmt::Debug for IWDG {
388    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
389        f.debug_struct("IWDG").finish()
390    }
391}
392#[doc = "Independent watchdog"]
393pub mod iwdg;
394#[doc = "Advanced timer"]
395pub struct TIM1 {
396    _marker: PhantomData<*const ()>,
397}
398unsafe impl Send for TIM1 {}
399impl TIM1 {
400    #[doc = r"Pointer to the register block"]
401    pub const PTR: *const tim1::RegisterBlock = 0x4001_2c00 as *const _;
402    #[doc = r"Return the pointer to the register block"]
403    #[inline(always)]
404    pub const fn ptr() -> *const tim1::RegisterBlock {
405        Self::PTR
406    }
407}
408impl Deref for TIM1 {
409    type Target = tim1::RegisterBlock;
410    #[inline(always)]
411    fn deref(&self) -> &Self::Target {
412        unsafe { &*Self::PTR }
413    }
414}
415impl core::fmt::Debug for TIM1 {
416    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
417        f.debug_struct("TIM1").finish()
418    }
419}
420#[doc = "Advanced timer"]
421pub mod tim1;
422#[doc = "General purpose timer"]
423pub struct TIM14 {
424    _marker: PhantomData<*const ()>,
425}
426unsafe impl Send for TIM14 {}
427impl TIM14 {
428    #[doc = r"Pointer to the register block"]
429    pub const PTR: *const tim14::RegisterBlock = 0x4000_2000 as *const _;
430    #[doc = r"Return the pointer to the register block"]
431    #[inline(always)]
432    pub const fn ptr() -> *const tim14::RegisterBlock {
433        Self::PTR
434    }
435}
436impl Deref for TIM14 {
437    type Target = tim14::RegisterBlock;
438    #[inline(always)]
439    fn deref(&self) -> &Self::Target {
440        unsafe { &*Self::PTR }
441    }
442}
443impl core::fmt::Debug for TIM14 {
444    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
445        f.debug_struct("TIM14").finish()
446    }
447}
448#[doc = "General purpose timer"]
449pub mod tim14;
450#[doc = "System configuration controller"]
451pub struct SYSCFG {
452    _marker: PhantomData<*const ()>,
453}
454unsafe impl Send for SYSCFG {}
455impl SYSCFG {
456    #[doc = r"Pointer to the register block"]
457    pub const PTR: *const syscfg::RegisterBlock = 0x4001_0000 as *const _;
458    #[doc = r"Return the pointer to the register block"]
459    #[inline(always)]
460    pub const fn ptr() -> *const syscfg::RegisterBlock {
461        Self::PTR
462    }
463}
464impl Deref for SYSCFG {
465    type Target = syscfg::RegisterBlock;
466    #[inline(always)]
467    fn deref(&self) -> &Self::Target {
468        unsafe { &*Self::PTR }
469    }
470}
471impl core::fmt::Debug for SYSCFG {
472    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
473        f.debug_struct("SYSCFG").finish()
474    }
475}
476#[doc = "System configuration controller"]
477pub mod syscfg;
478#[doc = "Flash"]
479pub struct FLASH {
480    _marker: PhantomData<*const ()>,
481}
482unsafe impl Send for FLASH {}
483impl FLASH {
484    #[doc = r"Pointer to the register block"]
485    pub const PTR: *const flash::RegisterBlock = 0x4002_2000 as *const _;
486    #[doc = r"Return the pointer to the register block"]
487    #[inline(always)]
488    pub const fn ptr() -> *const flash::RegisterBlock {
489        Self::PTR
490    }
491}
492impl Deref for FLASH {
493    type Target = flash::RegisterBlock;
494    #[inline(always)]
495    fn deref(&self) -> &Self::Target {
496        unsafe { &*Self::PTR }
497    }
498}
499impl core::fmt::Debug for FLASH {
500    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
501        f.debug_struct("FLASH").finish()
502    }
503}
504#[doc = "Flash"]
505pub mod flash;
506#[doc = "CRC calculation unit"]
507pub struct CRC {
508    _marker: PhantomData<*const ()>,
509}
510unsafe impl Send for CRC {}
511impl CRC {
512    #[doc = r"Pointer to the register block"]
513    pub const PTR: *const crc::RegisterBlock = 0x4002_3000 as *const _;
514    #[doc = r"Return the pointer to the register block"]
515    #[inline(always)]
516    pub const fn ptr() -> *const crc::RegisterBlock {
517        Self::PTR
518    }
519}
520impl Deref for CRC {
521    type Target = crc::RegisterBlock;
522    #[inline(always)]
523    fn deref(&self) -> &Self::Target {
524        unsafe { &*Self::PTR }
525    }
526}
527impl core::fmt::Debug for CRC {
528    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
529        f.debug_struct("CRC").finish()
530    }
531}
532#[doc = "CRC calculation unit"]
533pub mod crc;
534#[doc = "Debug support"]
535pub struct DBGMCU {
536    _marker: PhantomData<*const ()>,
537}
538unsafe impl Send for DBGMCU {}
539impl DBGMCU {
540    #[doc = r"Pointer to the register block"]
541    pub const PTR: *const dbgmcu::RegisterBlock = 0x4001_5800 as *const _;
542    #[doc = r"Return the pointer to the register block"]
543    #[inline(always)]
544    pub const fn ptr() -> *const dbgmcu::RegisterBlock {
545        Self::PTR
546    }
547}
548impl Deref for DBGMCU {
549    type Target = dbgmcu::RegisterBlock;
550    #[inline(always)]
551    fn deref(&self) -> &Self::Target {
552        unsafe { &*Self::PTR }
553    }
554}
555impl core::fmt::Debug for DBGMCU {
556    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
557        f.debug_struct("DBGMCU").finish()
558    }
559}
560#[doc = "Debug support"]
561pub mod dbgmcu;
562#[no_mangle]
563static mut DEVICE_PERIPHERALS: bool = false;
564#[doc = r"All the peripherals"]
565#[allow(non_snake_case)]
566pub struct Peripherals {
567    #[doc = "COMP1"]
568    pub COMP1: COMP1,
569    #[doc = "COMP2"]
570    pub COMP2: COMP2,
571    #[doc = "RCC"]
572    pub RCC: RCC,
573    #[doc = "PWR"]
574    pub PWR: PWR,
575    #[doc = "GPIOA"]
576    pub GPIOA: GPIOA,
577    #[doc = "GPIOB"]
578    pub GPIOB: GPIOB,
579    #[doc = "GPIOC"]
580    pub GPIOC: GPIOC,
581    #[doc = "EXTI"]
582    pub EXTI: EXTI,
583    #[doc = "LPTIM1"]
584    pub LPTIM1: LPTIM1,
585    #[doc = "IWDG"]
586    pub IWDG: IWDG,
587    #[doc = "TIM1"]
588    pub TIM1: TIM1,
589    #[doc = "TIM14"]
590    pub TIM14: TIM14,
591    #[doc = "SYSCFG"]
592    pub SYSCFG: SYSCFG,
593    #[doc = "FLASH"]
594    pub FLASH: FLASH,
595    #[doc = "CRC"]
596    pub CRC: CRC,
597    #[doc = "DBGMCU"]
598    pub DBGMCU: DBGMCU,
599}
600impl Peripherals {
601    #[doc = r"Returns all the peripherals *once*"]
602    #[inline]
603    pub fn take() -> Option<Self> {
604        cortex_m::interrupt::free(|_| {
605            if unsafe { DEVICE_PERIPHERALS } {
606                None
607            } else {
608                Some(unsafe { Peripherals::steal() })
609            }
610        })
611    }
612    #[doc = r"Unchecked version of `Peripherals::take`"]
613    #[inline]
614    pub unsafe fn steal() -> Self {
615        DEVICE_PERIPHERALS = true;
616        Peripherals {
617            COMP1: COMP1 {
618                _marker: PhantomData,
619            },
620            COMP2: COMP2 {
621                _marker: PhantomData,
622            },
623            RCC: RCC {
624                _marker: PhantomData,
625            },
626            PWR: PWR {
627                _marker: PhantomData,
628            },
629            GPIOA: GPIOA {
630                _marker: PhantomData,
631            },
632            GPIOB: GPIOB {
633                _marker: PhantomData,
634            },
635            GPIOC: GPIOC {
636                _marker: PhantomData,
637            },
638            EXTI: EXTI {
639                _marker: PhantomData,
640            },
641            LPTIM1: LPTIM1 {
642                _marker: PhantomData,
643            },
644            IWDG: IWDG {
645                _marker: PhantomData,
646            },
647            TIM1: TIM1 {
648                _marker: PhantomData,
649            },
650            TIM14: TIM14 {
651                _marker: PhantomData,
652            },
653            SYSCFG: SYSCFG {
654                _marker: PhantomData,
655            },
656            FLASH: FLASH {
657                _marker: PhantomData,
658            },
659            CRC: CRC {
660                _marker: PhantomData,
661            },
662            DBGMCU: DBGMCU {
663                _marker: PhantomData,
664            },
665        }
666    }
667}