1use super::*;
2
3macro_rules! bus_enable {
4 ($PER:ident => $en:ident) => {
5 impl Enable for crate::pac::$PER {
6 #[inline(always)]
7 fn enable(bus: &mut Self::Bus) {
8 bus.enr().modify(|_, w| w.$en().set_bit());
9 cortex_m::asm::dsb();
11 }
12 #[inline(always)]
13 fn disable(bus: &mut Self::Bus) {
14 bus.enr().modify(|_, w| w.$en().clear_bit());
15 }
16 #[inline(always)]
17 fn is_enabled() -> bool {
18 Self::Bus::new().enr().read().$en().bit_is_set()
19 }
20 #[inline(always)]
21 fn is_disabled() -> bool {
22 Self::Bus::new().enr().read().$en().bit_is_clear()
23 }
24 #[inline(always)]
25 unsafe fn enable_unchecked() {
26 Self::enable(&mut Self::Bus::new());
27 }
28 #[inline(always)]
29 unsafe fn disable_unchecked() {
30 Self::disable(&mut Self::Bus::new());
31 }
32 }
33 };
34}
35
36macro_rules! bus_lpenable {
37 ($PER:ident => $lpen:ident) => {
38 impl LPEnable for crate::pac::$PER {
39 #[inline(always)]
40 fn low_power_enable(bus: &mut Self::Bus) {
41 bus.lpenr().modify(|_, w| w.$lpen().set_bit());
42 cortex_m::asm::dsb();
44 }
45 #[inline(always)]
46 fn low_power_disable(bus: &mut Self::Bus) {
47 bus.lpenr().modify(|_, w| w.$lpen().clear_bit());
48 }
49 #[inline(always)]
50 fn is_low_power_enabled() -> bool {
51 Self::Bus::new().lpenr().read().$lpen().bit_is_set()
52 }
53 #[inline(always)]
54 fn is_low_power_disabled() -> bool {
55 Self::Bus::new().lpenr().read().$lpen().bit_is_clear()
56 }
57 #[inline(always)]
58 unsafe fn low_power_enable_unchecked() {
59 Self::enable(&mut Self::Bus::new());
60 }
61 #[inline(always)]
62 unsafe fn low_power_disable_unchecked() {
63 Self::disable(&mut Self::Bus::new());
64 }
65 }
66 };
67}
68macro_rules! bus_reset {
69 ($PER:ident => $rst:ident) => {
70 impl Reset for crate::pac::$PER {
71 #[inline(always)]
72 fn reset(bus: &mut Self::Bus) {
73 bus.rstr().modify(|_, w| w.$rst().set_bit());
74 bus.rstr().modify(|_, w| w.$rst().clear_bit());
75 }
76 #[inline(always)]
77 unsafe fn reset_unchecked() {
78 Self::reset(&mut Self::Bus::new());
79 }
80 }
81 };
82}
83
84macro_rules! bus {
85 ($($PER:ident => ($busX:ty, $($en:ident)?, $($lpen:ident)?, $($rst:ident)?),)+) => {
86 $(
87 impl crate::Sealed for crate::pac::$PER {}
88 impl RccBus for crate::pac::$PER {
89 type Bus = $busX;
90 }
91 $(bus_enable!($PER => $en);)?
92 $(bus_lpenable!($PER => $lpen);)?
93 $(bus_reset!($PER => $rst);)?
94 )+
95 };
96}
97
98bus! {
101 GPIOA => (AHB1, gpioaen, gpioalpen, gpioarst), GPIOB => (AHB1, gpioben, gpioblpen, gpiobrst), GPIOC => (AHB1, gpiocen, gpioclpen, gpiocrst), GPIOD => (AHB1, gpioden, gpiodlpen, gpiodrst), GPIOE => (AHB1, gpioeen, gpioelpen, gpioerst), GPIOF => (AHB1, gpiofen, gpioflpen, gpiofrst), GPIOG => (AHB1, gpiogen, gpioglpen, gpiogrst), GPIOH => (AHB1, gpiohen, gpiohlpen, gpiohrst), GPIOI => (AHB1, gpioien, gpioilpen, gpioirst), CRC => (AHB1, crcen, crclpen, crcrst), DMA1 => (AHB1, dma1en, dma1lpen, dma1rst), DMA2 => (AHB1, dma2en, dma2lpen, dma2rst), OTG_HS_GLOBAL => (AHB1, otghsen, otghslpen, otghsrst), RNG => (AHB2, rngen, rnglpen, rngrst), OTG_FS_GLOBAL => (AHB2, otgfsen, otgfslpen, otgfsrst), FMC => (AHB3, fmcen, fmclpen, fmcrst), QUADSPI => (AHB3, qspien, qspilpen, qspirst), TIM2 => (APB1, tim2en, tim2lpen, tim2rst), TIM3 => (APB1, tim3en, tim3lpen, tim3rst), TIM4 => (APB1, tim4en, tim4lpen, tim4rst), TIM5 => (APB1, tim5en, tim5lpen, tim5rst), TIM6 => (APB1, tim6en, tim6lpen, tim6rst), TIM7 => (APB1, tim7en, tim7lpen, tim7rst), TIM12 => (APB1, tim12en, tim12lpen, tim12rst), TIM13 => (APB1, tim13en, tim13lpen, tim13rst), TIM14 => (APB1, tim14en, tim14lpen, tim14rst), LPTIM1 => (APB1, lptim1en, lptim1lpen, lptim1rst), WWDG => (APB1, wwdgen, wwdglpen, wwdgrst), SPI2 => (APB1, spi2en, spi2lpen, spi2rst), SPI3 => (APB1, spi3en, spi3lpen, spi3rst), USART2 => (APB1, usart2en, usart2lpen, usart2rst), USART3 => (APB1, usart3en, usart3lpen, usart3rst), UART4 => (APB1, uart4en, uart4lpen, uart4rst), UART5 => (APB1, uart5en, uart5lpen, uart5rst), I2C1 => (APB1, i2c1en, i2c1lpen, i2c1rst), I2C2 => (APB1, i2c2en, i2c2lpen, i2c2rst), I2C3 => (APB1, i2c3en, i2c3lpen, i2c3rst), CAN1 => (APB1, can1en, can1lpen, can1rst), PWR => (APB1, pwren, pwrlpen, pwrrst), DAC => (APB1, dacen, daclpen, dacrst), UART7 => (APB1, uart7en, uart7lpen, uart7rst), UART8 => (APB1, uart8en, uart8lpen, uart8rst), TIM1 => (APB2, tim1en, tim1lpen, tim1rst), TIM8 => (APB2, tim8en, tim8lpen, tim8rst), USART1 => (APB2, usart1en, usart1lpen, usart1rst), USART6 => (APB2, usart6en, usart6lpen, usart6rst), ADC1 => (APB2, adc1en, adc1lpen, adcrst), ADC2 => (APB2, adc2en, adc2lpen, adcrst), ADC3 => (APB2, adc3en, adc3lpen, adcrst), SDMMC1 => (APB2, sdmmc1en, sdmmc1lpen, sdmmc1rst), SPI1 => (APB2, spi1en, spi1lpen, spi1rst), SPI4 => (APB2, spi4en, spi4lpen, spi4rst), SYSCFG => (APB2, syscfgen, syscfglpen, syscfgrst), TIM9 => (APB2, tim9en, tim9lpen, tim9rst), TIM10 => (APB2, tim10en, tim10lpen, tim10rst), TIM11 => (APB2, tim11en, tim11lpen, tim11rst), SPI5 => (APB2, spi5en, spi5lpen, spi5rst), SAI1 => (APB2, sai1en, sai1lpen, sai1rst), SAI2 => (APB2, sai2en, sai2lpen, sai2rst), }
165
166#[cfg(any(feature = "svd-f730", feature = "svd-f7x2", feature = "svd-f7x3",))]
167bus! {
168 AES => (AHB2, aesen, aeslpen, aesrst), SDMMC2 => (APB2, sdmmc2en, sdmmc2lpen, sdmmc2rst), USBPHYC => (APB2, usbphycen,, usbphycrst), }
173
174#[cfg(any(
175 feature = "svd-f745",
176 feature = "svd-f750",
177 feature = "svd-f7x6",
178 feature = "svd-f765",
179 feature = "svd-f7x7",
180 feature = "svd-f7x9",
181))]
182bus! {
183 GPIOJ => (AHB1, gpiojen, gpiojlpen, gpiojrst), GPIOK => (AHB1, gpioken, gpioklpen, gpiokrst), DMA2D => (AHB1, dma2den, dma2dlpen, dma2drst), ETHERNET_MAC => (AHB1, ethmacen, ethmaclpen, ethmacrst), DCMI => (AHB2, dcmien, dcmilpen, dcmirst), CRYP => (AHB2, crypen, cryplpen, cryprst), HASH => (AHB2, hashen, hashlpen,), SPDIFRX => (APB1, spdifrxen, spdifrxlpen, spdifrxrst), I2C4 => (APB1, i2c4en, i2c4lpen, i2c4rst), CAN2 => (APB1, can2en, can2lpen, can2rst), CEC => (APB1, cecen, ceclpen, cecrst), SPI6 => (APB2, spi6en, spi6lpen, spi6rst), LTDC => (APB2, ltdcen, ltdclpen, ltdcrst), }
200
201#[cfg(any(feature = "svd-f765", feature = "svd-f7x7", feature = "svd-f7x9"))]
202bus! {
203 JPEG => (AHB2, jpegen, jpeglpen,), CAN3 => (APB1, can3en, can3lpen, can3rst), DSI => (APB2, dsien, dsilpen, dsirst), MDIOS => (APB2, mdioen, mdiolpen, mdiorst), }
210
211#[cfg(any(feature = "svd-f7x9", feature = "svd-f7x9"))]
212bus! {
213 DFSDM => (APB2, dfsdm1en, dfsdm1lpen, dfsdm1rst), }
215
216#[cfg(feature = "svd-f765")]
217bus! {
218 DFSDM1 => (APB2, dfsdm1en, dfsdm1lpen, dfsdm1rst), }