1pub const NVIC_PRIO_BITS: u8 = 2;
12#[cfg(feature = "rt")]
13pub use self::Interrupt as interrupt;
14pub use cortex_m::peripheral::Peripherals as CorePeripherals;
15pub use cortex_m::peripheral::{CBP, CPUID, DCB, DWT, FPB, ITM, MPU, NVIC, SCB, SYST, TPIU};
16#[cfg(feature = "rt")]
17pub use cortex_m_rt::interrupt;
18#[cfg(feature = "rt")]
19extern "C" {
20 fn WWDG();
21 fn RTC();
22 fn FLASH();
23 fn RCC();
24 fn EXTI0_1();
25 fn EXTI2_3();
26 fn EXTI4_15();
27 fn DMA1_CHANNEL1();
28 fn DMA1_CHANNEL2_3();
29 fn DMA1_CHANNEL4_7();
30 fn ADC();
31 fn LPTIM1();
32 fn TIM2();
33 fn TIM21();
34 fn TIM22();
35 fn I2C1();
36 fn SPI1();
37 fn USART2();
38 fn LPUART1();
39}
40#[doc(hidden)]
41#[repr(C)]
42pub union Vector {
43 _handler: unsafe extern "C" fn(),
44 _reserved: u32,
45}
46#[cfg(feature = "rt")]
47#[doc(hidden)]
48#[link_section = ".vector_table.interrupts"]
49#[no_mangle]
50pub static __INTERRUPTS: [Vector; 30] = [
51 Vector { _handler: WWDG },
52 Vector { _reserved: 0 },
53 Vector { _handler: RTC },
54 Vector { _handler: FLASH },
55 Vector { _handler: RCC },
56 Vector { _handler: EXTI0_1 },
57 Vector { _handler: EXTI2_3 },
58 Vector { _handler: EXTI4_15 },
59 Vector { _reserved: 0 },
60 Vector {
61 _handler: DMA1_CHANNEL1,
62 },
63 Vector {
64 _handler: DMA1_CHANNEL2_3,
65 },
66 Vector {
67 _handler: DMA1_CHANNEL4_7,
68 },
69 Vector { _handler: ADC },
70 Vector { _handler: LPTIM1 },
71 Vector { _reserved: 0 },
72 Vector { _handler: TIM2 },
73 Vector { _reserved: 0 },
74 Vector { _reserved: 0 },
75 Vector { _reserved: 0 },
76 Vector { _reserved: 0 },
77 Vector { _handler: TIM21 },
78 Vector { _reserved: 0 },
79 Vector { _handler: TIM22 },
80 Vector { _handler: I2C1 },
81 Vector { _reserved: 0 },
82 Vector { _handler: SPI1 },
83 Vector { _reserved: 0 },
84 Vector { _reserved: 0 },
85 Vector { _handler: USART2 },
86 Vector { _handler: LPUART1 },
87];
88#[cfg_attr(feature = "defmt", derive(defmt::Format))]
90#[derive(Copy, Clone, Debug, PartialEq, Eq)]
91#[repr(u16)]
92pub enum Interrupt {
93 WWDG = 0,
95 RTC = 2,
97 FLASH = 3,
99 RCC = 4,
101 EXTI0_1 = 5,
103 EXTI2_3 = 6,
105 EXTI4_15 = 7,
107 DMA1_CHANNEL1 = 9,
109 DMA1_CHANNEL2_3 = 10,
111 DMA1_CHANNEL4_7 = 11,
113 ADC = 12,
115 LPTIM1 = 13,
117 TIM2 = 15,
119 TIM21 = 20,
121 TIM22 = 22,
123 I2C1 = 23,
125 SPI1 = 25,
127 USART2 = 28,
129 LPUART1 = 29,
131}
132unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
133 #[inline(always)]
134 fn number(self) -> u16 {
135 self as u16
136 }
137}
138pub type DMA1 = crate::Periph<dma1::RegisterBlock, 0x4002_0000>;
142impl core::fmt::Debug for DMA1 {
143 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
144 f.debug_struct("DMA1").finish()
145 }
146}
147pub mod dma1;
149pub type CRC = crate::Periph<crc::RegisterBlock, 0x4002_3000>;
153impl core::fmt::Debug for CRC {
154 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
155 f.debug_struct("CRC").finish()
156 }
157}
158pub mod crc;
160pub type GPIOA = crate::Periph<gpioa::RegisterBlock, 0x5000_0000>;
164impl core::fmt::Debug for GPIOA {
165 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
166 f.debug_struct("GPIOA").finish()
167 }
168}
169pub mod gpioa;
171pub type GPIOB = crate::Periph<gpiob::RegisterBlock, 0x5000_0400>;
175impl core::fmt::Debug for GPIOB {
176 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
177 f.debug_struct("GPIOB").finish()
178 }
179}
180pub mod gpiob;
182pub type GPIOC = crate::Periph<gpiob::RegisterBlock, 0x5000_0800>;
186impl core::fmt::Debug for GPIOC {
187 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
188 f.debug_struct("GPIOC").finish()
189 }
190}
191pub use self::gpiob as gpioc;
193pub type GPIOD = crate::Periph<gpiob::RegisterBlock, 0x5000_0c00>;
197impl core::fmt::Debug for GPIOD {
198 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
199 f.debug_struct("GPIOD").finish()
200 }
201}
202pub use self::gpiob as gpiod;
204pub type GPIOH = crate::Periph<gpiob::RegisterBlock, 0x5000_1c00>;
208impl core::fmt::Debug for GPIOH {
209 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
210 f.debug_struct("GPIOH").finish()
211 }
212}
213pub use self::gpiob as gpioh;
215pub type GPIOE = crate::Periph<gpiob::RegisterBlock, 0x5000_1000>;
219impl core::fmt::Debug for GPIOE {
220 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
221 f.debug_struct("GPIOE").finish()
222 }
223}
224pub use self::gpiob as gpioe;
226pub type LPTIM = crate::Periph<lptim::RegisterBlock, 0x4000_7c00>;
230impl core::fmt::Debug for LPTIM {
231 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
232 f.debug_struct("LPTIM").finish()
233 }
234}
235pub mod lptim;
237pub type RTC = crate::Periph<rtc::RegisterBlock, 0x4000_2800>;
241impl core::fmt::Debug for RTC {
242 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
243 f.debug_struct("RTC").finish()
244 }
245}
246pub mod rtc;
248pub type USART2 = crate::Periph<usart2::RegisterBlock, 0x4000_4400>;
252impl core::fmt::Debug for USART2 {
253 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
254 f.debug_struct("USART2").finish()
255 }
256}
257pub mod usart2;
259pub type IWDG = crate::Periph<iwdg::RegisterBlock, 0x4000_3000>;
263impl core::fmt::Debug for IWDG {
264 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
265 f.debug_struct("IWDG").finish()
266 }
267}
268pub mod iwdg;
270pub type WWDG = crate::Periph<wwdg::RegisterBlock, 0x4000_2c00>;
274impl core::fmt::Debug for WWDG {
275 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
276 f.debug_struct("WWDG").finish()
277 }
278}
279pub mod wwdg;
281pub type FW = crate::Periph<fw::RegisterBlock, 0x4001_1c00>;
285impl core::fmt::Debug for FW {
286 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
287 f.debug_struct("FW").finish()
288 }
289}
290pub mod fw;
292pub type RCC = crate::Periph<rcc::RegisterBlock, 0x4002_1000>;
296impl core::fmt::Debug for RCC {
297 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
298 f.debug_struct("RCC").finish()
299 }
300}
301pub mod rcc;
303pub type SYSCFG = crate::Periph<syscfg::RegisterBlock, 0x4001_0000>;
307impl core::fmt::Debug for SYSCFG {
308 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
309 f.debug_struct("SYSCFG").finish()
310 }
311}
312pub mod syscfg;
314pub type SPI1 = crate::Periph<spi1::RegisterBlock, 0x4001_3000>;
318impl core::fmt::Debug for SPI1 {
319 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
320 f.debug_struct("SPI1").finish()
321 }
322}
323pub mod spi1;
325pub type I2C1 = crate::Periph<i2c1::RegisterBlock, 0x4000_5400>;
329impl core::fmt::Debug for I2C1 {
330 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
331 f.debug_struct("I2C1").finish()
332 }
333}
334pub mod i2c1;
336pub type PWR = crate::Periph<pwr::RegisterBlock, 0x4000_7000>;
340impl core::fmt::Debug for PWR {
341 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
342 f.debug_struct("PWR").finish()
343 }
344}
345pub mod pwr;
347pub type FLASH = crate::Periph<flash::RegisterBlock, 0x4002_2000>;
351impl core::fmt::Debug for FLASH {
352 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
353 f.debug_struct("FLASH").finish()
354 }
355}
356pub mod flash;
358pub type EXTI = crate::Periph<exti::RegisterBlock, 0x4001_0400>;
362impl core::fmt::Debug for EXTI {
363 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
364 f.debug_struct("EXTI").finish()
365 }
366}
367pub mod exti;
369pub type ADC = crate::Periph<adc::RegisterBlock, 0x4001_2400>;
373impl core::fmt::Debug for ADC {
374 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
375 f.debug_struct("ADC").finish()
376 }
377}
378pub mod adc;
380pub type DBG = crate::Periph<dbg::RegisterBlock, 0x4001_5800>;
384impl core::fmt::Debug for DBG {
385 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
386 f.debug_struct("DBG").finish()
387 }
388}
389pub mod dbg;
391pub type TIM2 = crate::Periph<tim2::RegisterBlock, 0x4000_0000>;
395impl core::fmt::Debug for TIM2 {
396 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
397 f.debug_struct("TIM2").finish()
398 }
399}
400pub mod tim2;
402pub type TIM21 = crate::Periph<tim21::RegisterBlock, 0x4001_0800>;
406impl core::fmt::Debug for TIM21 {
407 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
408 f.debug_struct("TIM21").finish()
409 }
410}
411pub mod tim21;
413pub type TIM22 = crate::Periph<tim22::RegisterBlock, 0x4001_1400>;
417impl core::fmt::Debug for TIM22 {
418 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
419 f.debug_struct("TIM22").finish()
420 }
421}
422pub mod tim22;
424pub type LPUART1 = crate::Periph<lpuart1::RegisterBlock, 0x4000_4800>;
428impl core::fmt::Debug for LPUART1 {
429 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
430 f.debug_struct("LPUART1").finish()
431 }
432}
433pub mod lpuart1;
435#[no_mangle]
436static mut DEVICE_PERIPHERALS: bool = false;
437#[allow(non_snake_case)]
439pub struct Peripherals {
440 pub DMA1: DMA1,
442 pub CRC: CRC,
444 pub GPIOA: GPIOA,
446 pub GPIOB: GPIOB,
448 pub GPIOC: GPIOC,
450 pub GPIOD: GPIOD,
452 pub GPIOH: GPIOH,
454 pub GPIOE: GPIOE,
456 pub LPTIM: LPTIM,
458 pub RTC: RTC,
460 pub USART2: USART2,
462 pub IWDG: IWDG,
464 pub WWDG: WWDG,
466 pub FW: FW,
468 pub RCC: RCC,
470 pub SYSCFG: SYSCFG,
472 pub SPI1: SPI1,
474 pub I2C1: I2C1,
476 pub PWR: PWR,
478 pub FLASH: FLASH,
480 pub EXTI: EXTI,
482 pub ADC: ADC,
484 pub DBG: DBG,
486 pub TIM2: TIM2,
488 pub TIM21: TIM21,
490 pub TIM22: TIM22,
492 pub LPUART1: LPUART1,
494}
495impl Peripherals {
496 #[cfg(feature = "critical-section")]
498 #[inline]
499 pub fn take() -> Option<Self> {
500 critical_section::with(|_| {
501 if unsafe { DEVICE_PERIPHERALS } {
502 return None;
503 }
504 Some(unsafe { Peripherals::steal() })
505 })
506 }
507 #[inline]
513 pub unsafe fn steal() -> Self {
514 DEVICE_PERIPHERALS = true;
515 Peripherals {
516 DMA1: DMA1::steal(),
517 CRC: CRC::steal(),
518 GPIOA: GPIOA::steal(),
519 GPIOB: GPIOB::steal(),
520 GPIOC: GPIOC::steal(),
521 GPIOD: GPIOD::steal(),
522 GPIOH: GPIOH::steal(),
523 GPIOE: GPIOE::steal(),
524 LPTIM: LPTIM::steal(),
525 RTC: RTC::steal(),
526 USART2: USART2::steal(),
527 IWDG: IWDG::steal(),
528 WWDG: WWDG::steal(),
529 FW: FW::steal(),
530 RCC: RCC::steal(),
531 SYSCFG: SYSCFG::steal(),
532 SPI1: SPI1::steal(),
533 I2C1: I2C1::steal(),
534 PWR: PWR::steal(),
535 FLASH: FLASH::steal(),
536 EXTI: EXTI::steal(),
537 ADC: ADC::steal(),
538 DBG: DBG::steal(),
539 TIM2: TIM2::steal(),
540 TIM21: TIM21::steal(),
541 TIM22: TIM22::steal(),
542 LPUART1: LPUART1::steal(),
543 }
544 }
545}