pub const NVIC_PRIO_BITS: u8 = 2;
#[cfg(feature = "rt")]
pub use self::Interrupt as interrupt;
pub use cortex_m::peripheral::Peripherals as CorePeripherals;
pub use cortex_m::peripheral::{CBP, CPUID, DCB, DWT, FPB, ITM, MPU, NVIC, SCB, SYST, TPIU};
#[cfg(feature = "rt")]
pub use cortex_m_rt::interrupt;
#[cfg(feature = "rt")]
extern "C" {
fn WWDG();
fn PVD();
fn RTC();
fn FLASH();
fn RCC();
fn EXTI0_1();
fn EXTI2_3();
fn EXTI4_15();
fn DMA1_CH1();
fn DMA1_CH2_3();
fn DMA1_CH4_5();
fn ADC();
fn TIM1_BRK_UP_TRG_COM();
fn TIM1_CC();
fn TIM3();
fn TIM6();
fn TIM14();
fn TIM15();
fn TIM16();
fn TIM17();
fn I2C1();
fn I2C2();
fn SPI1();
fn SPI2();
fn USART1();
fn USART2();
fn USART3_4_5_6();
fn USB();
}
#[doc(hidden)]
#[repr(C)]
pub union Vector {
_handler: unsafe extern "C" fn(),
_reserved: u32,
}
#[cfg(feature = "rt")]
#[doc(hidden)]
#[link_section = ".vector_table.interrupts"]
#[no_mangle]
pub static __INTERRUPTS: [Vector; 32] = [
Vector { _handler: WWDG },
Vector { _handler: PVD },
Vector { _handler: RTC },
Vector { _handler: FLASH },
Vector { _handler: RCC },
Vector { _handler: EXTI0_1 },
Vector { _handler: EXTI2_3 },
Vector { _handler: EXTI4_15 },
Vector { _reserved: 0 },
Vector { _handler: DMA1_CH1 },
Vector {
_handler: DMA1_CH2_3,
},
Vector {
_handler: DMA1_CH4_5,
},
Vector { _handler: ADC },
Vector {
_handler: TIM1_BRK_UP_TRG_COM,
},
Vector { _handler: TIM1_CC },
Vector { _reserved: 0 },
Vector { _handler: TIM3 },
Vector { _handler: TIM6 },
Vector { _reserved: 0 },
Vector { _handler: TIM14 },
Vector { _handler: TIM15 },
Vector { _handler: TIM16 },
Vector { _handler: TIM17 },
Vector { _handler: I2C1 },
Vector { _handler: I2C2 },
Vector { _handler: SPI1 },
Vector { _handler: SPI2 },
Vector { _handler: USART1 },
Vector { _handler: USART2 },
Vector {
_handler: USART3_4_5_6,
},
Vector { _reserved: 0 },
Vector { _handler: USB },
];
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum Interrupt {
WWDG = 0,
PVD = 1,
RTC = 2,
FLASH = 3,
RCC = 4,
EXTI0_1 = 5,
EXTI2_3 = 6,
EXTI4_15 = 7,
DMA1_CH1 = 9,
DMA1_CH2_3 = 10,
DMA1_CH4_5 = 11,
ADC = 12,
TIM1_BRK_UP_TRG_COM = 13,
TIM1_CC = 14,
TIM3 = 16,
TIM6 = 17,
TIM14 = 19,
TIM15 = 20,
TIM16 = 21,
TIM17 = 22,
I2C1 = 23,
I2C2 = 24,
SPI1 = 25,
SPI2 = 26,
USART1 = 27,
USART2 = 28,
USART3_4_5_6 = 29,
USB = 31,
}
unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
#[inline(always)]
fn number(self) -> u16 {
self as u16
}
}
pub type CRC = crate::Periph<crc::RegisterBlock, 0x4002_3000>;
impl core::fmt::Debug for CRC {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CRC").finish()
}
}
pub mod crc;
pub type GPIOF = crate::Periph<gpiof::RegisterBlock, 0x4800_1400>;
impl core::fmt::Debug for GPIOF {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("GPIOF").finish()
}
}
pub mod gpiof;
pub type GPIOD = crate::Periph<gpiof::RegisterBlock, 0x4800_0c00>;
impl core::fmt::Debug for GPIOD {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("GPIOD").finish()
}
}
pub use self::gpiof as gpiod;
pub type GPIOC = crate::Periph<gpiof::RegisterBlock, 0x4800_0800>;
impl core::fmt::Debug for GPIOC {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("GPIOC").finish()
}
}
pub use self::gpiof as gpioc;
pub type GPIOB = crate::Periph<gpiof::RegisterBlock, 0x4800_0400>;
impl core::fmt::Debug for GPIOB {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("GPIOB").finish()
}
}
pub use self::gpiof as gpiob;
pub type GPIOA = crate::Periph<gpioa::RegisterBlock, 0x4800_0000>;
impl core::fmt::Debug for GPIOA {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("GPIOA").finish()
}
}
pub mod gpioa;
pub type SPI1 = crate::Periph<spi1::RegisterBlock, 0x4001_3000>;
impl core::fmt::Debug for SPI1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SPI1").finish()
}
}
pub mod spi1;
pub type SPI2 = crate::Periph<spi1::RegisterBlock, 0x4000_3800>;
impl core::fmt::Debug for SPI2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SPI2").finish()
}
}
pub use self::spi1 as spi2;
pub type PWR = crate::Periph<pwr::RegisterBlock, 0x4000_7000>;
impl core::fmt::Debug for PWR {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PWR").finish()
}
}
pub mod pwr;
pub type I2C1 = crate::Periph<i2c1::RegisterBlock, 0x4000_5400>;
impl core::fmt::Debug for I2C1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("I2C1").finish()
}
}
pub mod i2c1;
pub type I2C2 = crate::Periph<i2c1::RegisterBlock, 0x4000_5800>;
impl core::fmt::Debug for I2C2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("I2C2").finish()
}
}
pub use self::i2c1 as i2c2;
pub type IWDG = crate::Periph<iwdg::RegisterBlock, 0x4000_3000>;
impl core::fmt::Debug for IWDG {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("IWDG").finish()
}
}
pub mod iwdg;
pub type WWDG = crate::Periph<wwdg::RegisterBlock, 0x4000_2c00>;
impl core::fmt::Debug for WWDG {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("WWDG").finish()
}
}
pub mod wwdg;
pub type TIM1 = crate::Periph<tim1::RegisterBlock, 0x4001_2c00>;
impl core::fmt::Debug for TIM1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM1").finish()
}
}
pub mod tim1;
pub type TIM3 = crate::Periph<tim3::RegisterBlock, 0x4000_0400>;
impl core::fmt::Debug for TIM3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM3").finish()
}
}
pub mod tim3;
pub type TIM14 = crate::Periph<tim14::RegisterBlock, 0x4000_2000>;
impl core::fmt::Debug for TIM14 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM14").finish()
}
}
pub mod tim14;
pub type TIM6 = crate::Periph<tim6::RegisterBlock, 0x4000_1000>;
impl core::fmt::Debug for TIM6 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM6").finish()
}
}
pub mod tim6;
pub type TIM7 = crate::Periph<tim6::RegisterBlock, 0x4000_1400>;
impl core::fmt::Debug for TIM7 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM7").finish()
}
}
pub use self::tim6 as tim7;
pub type EXTI = crate::Periph<exti::RegisterBlock, 0x4001_0400>;
impl core::fmt::Debug for EXTI {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EXTI").finish()
}
}
pub mod exti;
pub type DMA1 = crate::Periph<dma1::RegisterBlock, 0x4002_0000>;
impl core::fmt::Debug for DMA1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DMA1").finish()
}
}
pub mod dma1;
pub type RCC = crate::Periph<rcc::RegisterBlock, 0x4002_1000>;
impl core::fmt::Debug for RCC {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RCC").finish()
}
}
pub mod rcc;
pub type SYSCFG = crate::Periph<syscfg::RegisterBlock, 0x4001_0000>;
impl core::fmt::Debug for SYSCFG {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SYSCFG").finish()
}
}
pub mod syscfg;
pub type ADC = crate::Periph<adc::RegisterBlock, 0x4001_2400>;
impl core::fmt::Debug for ADC {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ADC").finish()
}
}
pub mod adc;
pub type USART1 = crate::Periph<usart1::RegisterBlock, 0x4001_3800>;
impl core::fmt::Debug for USART1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART1").finish()
}
}
pub mod usart1;
pub type USART2 = crate::Periph<usart1::RegisterBlock, 0x4000_4400>;
impl core::fmt::Debug for USART2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART2").finish()
}
}
pub use self::usart1 as usart2;
pub type USART3 = crate::Periph<usart1::RegisterBlock, 0x4000_4800>;
impl core::fmt::Debug for USART3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART3").finish()
}
}
pub use self::usart1 as usart3;
pub type USART4 = crate::Periph<usart1::RegisterBlock, 0x4000_4c00>;
impl core::fmt::Debug for USART4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART4").finish()
}
}
pub use self::usart1 as usart4;
pub type USART6 = crate::Periph<usart1::RegisterBlock, 0x4001_1400>;
impl core::fmt::Debug for USART6 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART6").finish()
}
}
pub use self::usart1 as usart6;
pub type USART5 = crate::Periph<usart1::RegisterBlock, 0x4000_5000>;
impl core::fmt::Debug for USART5 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USART5").finish()
}
}
pub use self::usart1 as usart5;
pub type RTC = crate::Periph<rtc::RegisterBlock, 0x4000_2800>;
impl core::fmt::Debug for RTC {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RTC").finish()
}
}
pub mod rtc;
pub type TIM15 = crate::Periph<tim15::RegisterBlock, 0x4001_4000>;
impl core::fmt::Debug for TIM15 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM15").finish()
}
}
pub mod tim15;
pub type TIM16 = crate::Periph<tim16::RegisterBlock, 0x4001_4400>;
impl core::fmt::Debug for TIM16 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM16").finish()
}
}
pub mod tim16;
pub type TIM17 = crate::Periph<tim16::RegisterBlock, 0x4001_4800>;
impl core::fmt::Debug for TIM17 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIM17").finish()
}
}
pub use self::tim16 as tim17;
pub type FLASH = crate::Periph<flash::RegisterBlock, 0x4002_2000>;
impl core::fmt::Debug for FLASH {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("FLASH").finish()
}
}
pub mod flash;
pub type DBGMCU = crate::Periph<dbgmcu::RegisterBlock, 0x4001_5800>;
impl core::fmt::Debug for DBGMCU {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DBGMCU").finish()
}
}
pub mod dbgmcu;
pub type USB = crate::Periph<usb::RegisterBlock, 0x4000_5c00>;
impl core::fmt::Debug for USB {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("USB").finish()
}
}
pub mod usb;
pub type STK = crate::Periph<stk::RegisterBlock, 0xe000_e010>;
impl core::fmt::Debug for STK {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("STK").finish()
}
}
pub mod stk;
#[no_mangle]
static mut DEVICE_PERIPHERALS: bool = false;
#[allow(non_snake_case)]
pub struct Peripherals {
pub CRC: CRC,
pub GPIOF: GPIOF,
pub GPIOD: GPIOD,
pub GPIOC: GPIOC,
pub GPIOB: GPIOB,
pub GPIOA: GPIOA,
pub SPI1: SPI1,
pub SPI2: SPI2,
pub PWR: PWR,
pub I2C1: I2C1,
pub I2C2: I2C2,
pub IWDG: IWDG,
pub WWDG: WWDG,
pub TIM1: TIM1,
pub TIM3: TIM3,
pub TIM14: TIM14,
pub TIM6: TIM6,
pub TIM7: TIM7,
pub EXTI: EXTI,
pub DMA1: DMA1,
pub RCC: RCC,
pub SYSCFG: SYSCFG,
pub ADC: ADC,
pub USART1: USART1,
pub USART2: USART2,
pub USART3: USART3,
pub USART4: USART4,
pub USART6: USART6,
pub USART5: USART5,
pub RTC: RTC,
pub TIM15: TIM15,
pub TIM16: TIM16,
pub TIM17: TIM17,
pub FLASH: FLASH,
pub DBGMCU: DBGMCU,
pub USB: USB,
pub STK: STK,
}
impl Peripherals {
#[cfg(feature = "critical-section")]
#[inline]
pub fn take() -> Option<Self> {
critical_section::with(|_| {
if unsafe { DEVICE_PERIPHERALS } {
return None;
}
Some(unsafe { Peripherals::steal() })
})
}
#[inline]
pub unsafe fn steal() -> Self {
DEVICE_PERIPHERALS = true;
Peripherals {
CRC: CRC::steal(),
GPIOF: GPIOF::steal(),
GPIOD: GPIOD::steal(),
GPIOC: GPIOC::steal(),
GPIOB: GPIOB::steal(),
GPIOA: GPIOA::steal(),
SPI1: SPI1::steal(),
SPI2: SPI2::steal(),
PWR: PWR::steal(),
I2C1: I2C1::steal(),
I2C2: I2C2::steal(),
IWDG: IWDG::steal(),
WWDG: WWDG::steal(),
TIM1: TIM1::steal(),
TIM3: TIM3::steal(),
TIM14: TIM14::steal(),
TIM6: TIM6::steal(),
TIM7: TIM7::steal(),
EXTI: EXTI::steal(),
DMA1: DMA1::steal(),
RCC: RCC::steal(),
SYSCFG: SYSCFG::steal(),
ADC: ADC::steal(),
USART1: USART1::steal(),
USART2: USART2::steal(),
USART3: USART3::steal(),
USART4: USART4::steal(),
USART6: USART6::steal(),
USART5: USART5::steal(),
RTC: RTC::steal(),
TIM15: TIM15::steal(),
TIM16: TIM16::steal(),
TIM17: TIM17::steal(),
FLASH: FLASH::steal(),
DBGMCU: DBGMCU::steal(),
USB: USB::steal(),
STK: STK::steal(),
}
}
}