diff options
| author | pbert <[email protected]> | 2023-10-11 21:38:41 +0200 |
|---|---|---|
| committer | pbert <[email protected]> | 2023-10-12 11:04:44 +0200 |
| commit | ecdd7c0e2f9dcc07e53e136557140d3ccc6a5ee1 (patch) | |
| tree | 6db9bf875d3e83d94f6bf8e8a2e7ff03a83c5bb4 /embassy-stm32 | |
| parent | d7d79f3068a4a2d883b078b8900ad194f7c98203 (diff) | |
enable clock first
Diffstat (limited to 'embassy-stm32')
35 files changed, 56 insertions, 56 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 719a52d1d..63cf6b21f 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -556,14 +556,14 @@ fn main() { | |||
| 556 | fn frequency() -> crate::time::Hertz { | 556 | fn frequency() -> crate::time::Hertz { |
| 557 | #clock_frequency | 557 | #clock_frequency |
| 558 | } | 558 | } |
| 559 | fn enable() { | 559 | fn enable_and_reset() { |
| 560 | critical_section::with(|_cs| { | 560 | critical_section::with(|_cs| { |
| 561 | #before_enable | 561 | #before_enable |
| 562 | #rst | ||
| 563 | #[cfg(feature = "low-power")] | 562 | #[cfg(feature = "low-power")] |
| 564 | crate::rcc::clock_refcount_add(_cs); | 563 | crate::rcc::clock_refcount_add(_cs); |
| 565 | crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true)); | 564 | crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true)); |
| 566 | #after_enable | 565 | #after_enable |
| 566 | #rst | ||
| 567 | }) | 567 | }) |
| 568 | } | 568 | } |
| 569 | fn disable() { | 569 | fn disable() { |
diff --git a/embassy-stm32/src/adc/f1.rs b/embassy-stm32/src/adc/f1.rs index 5f5bf4bfa..ad0f13826 100644 --- a/embassy-stm32/src/adc/f1.rs +++ b/embassy-stm32/src/adc/f1.rs | |||
| @@ -51,7 +51,7 @@ impl<T: Instance> super::sealed::AdcPin<T> for Temperature { | |||
| 51 | impl<'d, T: Instance> Adc<'d, T> { | 51 | impl<'d, T: Instance> Adc<'d, T> { |
| 52 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { | 52 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { |
| 53 | into_ref!(adc); | 53 | into_ref!(adc); |
| 54 | T::reset_and_enable(); | 54 | T::enable_and_reset(); |
| 55 | T::regs().cr2().modify(|reg| reg.set_adon(true)); | 55 | T::regs().cr2().modify(|reg| reg.set_adon(true)); |
| 56 | 56 | ||
| 57 | // 11.4: Before starting a calibration, the ADC must have been in power-on state (ADON bit = ‘1’) | 57 | // 11.4: Before starting a calibration, the ADC must have been in power-on state (ADON bit = ‘1’) |
diff --git a/embassy-stm32/src/adc/f3.rs b/embassy-stm32/src/adc/f3.rs index e94f61413..6f59c230f 100644 --- a/embassy-stm32/src/adc/f3.rs +++ b/embassy-stm32/src/adc/f3.rs | |||
| @@ -64,7 +64,7 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 64 | 64 | ||
| 65 | into_ref!(adc); | 65 | into_ref!(adc); |
| 66 | 66 | ||
| 67 | T::reset_and_enable(); | 67 | T::enable_and_reset(); |
| 68 | 68 | ||
| 69 | // Enable the adc regulator | 69 | // Enable the adc regulator |
| 70 | T::regs().cr().modify(|w| w.set_advregen(vals::Advregen::INTERMEDIATE)); | 70 | T::regs().cr().modify(|w| w.set_advregen(vals::Advregen::INTERMEDIATE)); |
diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index f03acdcf4..852b027df 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs | |||
| @@ -61,7 +61,7 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 61 | delay: &mut impl DelayUs<u32>, | 61 | delay: &mut impl DelayUs<u32>, |
| 62 | ) -> Self { | 62 | ) -> Self { |
| 63 | into_ref!(adc); | 63 | into_ref!(adc); |
| 64 | T::reset_and_enable(); | 64 | T::enable_and_reset(); |
| 65 | 65 | ||
| 66 | // Delay 1μs when using HSI14 as the ADC clock. | 66 | // Delay 1μs when using HSI14 as the ADC clock. |
| 67 | // | 67 | // |
diff --git a/embassy-stm32/src/adc/v2.rs b/embassy-stm32/src/adc/v2.rs index 89e7616bc..eda1324de 100644 --- a/embassy-stm32/src/adc/v2.rs +++ b/embassy-stm32/src/adc/v2.rs | |||
| @@ -95,7 +95,7 @@ where | |||
| 95 | { | 95 | { |
| 96 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { | 96 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { |
| 97 | into_ref!(adc); | 97 | into_ref!(adc); |
| 98 | T::reset_and_enable(); | 98 | T::enable_and_reset(); |
| 99 | 99 | ||
| 100 | let presc = Prescaler::from_pclk2(T::frequency()); | 100 | let presc = Prescaler::from_pclk2(T::frequency()); |
| 101 | T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre())); | 101 | T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre())); |
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs index e50e6482c..281a99f72 100644 --- a/embassy-stm32/src/adc/v3.rs +++ b/embassy-stm32/src/adc/v3.rs | |||
| @@ -48,7 +48,7 @@ impl<T: Instance> super::sealed::AdcPin<T> for Vbat { | |||
| 48 | impl<'d, T: Instance> Adc<'d, T> { | 48 | impl<'d, T: Instance> Adc<'d, T> { |
| 49 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { | 49 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { |
| 50 | into_ref!(adc); | 50 | into_ref!(adc); |
| 51 | T::reset_and_enable(); | 51 | T::enable_and_reset(); |
| 52 | T::regs().cr().modify(|reg| { | 52 | T::regs().cr().modify(|reg| { |
| 53 | #[cfg(not(adc_g0))] | 53 | #[cfg(not(adc_g0))] |
| 54 | reg.set_deeppwd(false); | 54 | reg.set_deeppwd(false); |
diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs index 6d86e5cdf..d74617cb3 100644 --- a/embassy-stm32/src/adc/v4.rs +++ b/embassy-stm32/src/adc/v4.rs | |||
| @@ -127,7 +127,7 @@ impl Prescaler { | |||
| 127 | impl<'d, T: Instance> Adc<'d, T> { | 127 | impl<'d, T: Instance> Adc<'d, T> { |
| 128 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u16>) -> Self { | 128 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u16>) -> Self { |
| 129 | embassy_hal_internal::into_ref!(adc); | 129 | embassy_hal_internal::into_ref!(adc); |
| 130 | T::reset_and_enable(); | 130 | T::enable_and_reset(); |
| 131 | 131 | ||
| 132 | let prescaler = Prescaler::from_ker_ck(T::frequency()); | 132 | let prescaler = Prescaler::from_ker_ck(T::frequency()); |
| 133 | 133 | ||
diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs index 903f7e48b..0d4bf692d 100644 --- a/embassy-stm32/src/can/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs | |||
| @@ -136,7 +136,7 @@ impl<'d, T: Instance> Can<'d, T> { | |||
| 136 | rx.set_as_af(rx.af_num(), AFType::Input); | 136 | rx.set_as_af(rx.af_num(), AFType::Input); |
| 137 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); | 137 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); |
| 138 | 138 | ||
| 139 | T::reset_and_enable(); | 139 | T::enable_and_reset(); |
| 140 | 140 | ||
| 141 | { | 141 | { |
| 142 | use crate::pac::can::vals::{Errie, Fmpie, Tmeie}; | 142 | use crate::pac::can::vals::{Errie, Fmpie, Tmeie}; |
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index 282e1ad88..c0f580830 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs | |||
| @@ -16,7 +16,7 @@ impl<'d> Crc<'d> { | |||
| 16 | 16 | ||
| 17 | // Note: enable and reset come from RccPeripheral. | 17 | // Note: enable and reset come from RccPeripheral. |
| 18 | // enable CRC clock in RCC. | 18 | // enable CRC clock in RCC. |
| 19 | CRC::reset_and_enable(); | 19 | CRC::enable_and_reset(); |
| 20 | // Peripheral the peripheral | 20 | // Peripheral the peripheral |
| 21 | let mut instance = Self { _peri: peripheral }; | 21 | let mut instance = Self { _peri: peripheral }; |
| 22 | instance.reset(); | 22 | instance.reset(); |
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index 2ab25e6fb..b36f6018c 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs | |||
| @@ -70,7 +70,7 @@ impl<'d> Crc<'d> { | |||
| 70 | pub fn new(peripheral: impl Peripheral<P = CRC> + 'd, config: Config) -> Self { | 70 | pub fn new(peripheral: impl Peripheral<P = CRC> + 'd, config: Config) -> Self { |
| 71 | // Note: enable and reset come from RccPeripheral. | 71 | // Note: enable and reset come from RccPeripheral. |
| 72 | // reset to default values and enable CRC clock in RCC. | 72 | // reset to default values and enable CRC clock in RCC. |
| 73 | CRC::reset_and_enable(); | 73 | CRC::enable_and_reset(); |
| 74 | into_ref!(peripheral); | 74 | into_ref!(peripheral); |
| 75 | let mut instance = Self { | 75 | let mut instance = Self { |
| 76 | _peripheral: peripheral, | 76 | _peripheral: peripheral, |
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index e93fca954..6458572f2 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs | |||
| @@ -255,7 +255,7 @@ impl<'d, T: Instance, Tx> DacCh1<'d, T, Tx> { | |||
| 255 | ) -> Self { | 255 | ) -> Self { |
| 256 | pin.set_as_analog(); | 256 | pin.set_as_analog(); |
| 257 | into_ref!(peri, dma); | 257 | into_ref!(peri, dma); |
| 258 | T::reset_and_enable(); | 258 | T::enable_and_reset(); |
| 259 | 259 | ||
| 260 | let mut dac = Self { _peri: peri, dma }; | 260 | let mut dac = Self { _peri: peri, dma }; |
| 261 | 261 | ||
| @@ -365,7 +365,7 @@ impl<'d, T: Instance, Tx> DacCh2<'d, T, Tx> { | |||
| 365 | ) -> Self { | 365 | ) -> Self { |
| 366 | pin.set_as_analog(); | 366 | pin.set_as_analog(); |
| 367 | into_ref!(_peri, dma); | 367 | into_ref!(_peri, dma); |
| 368 | T::reset_and_enable(); | 368 | T::enable_and_reset(); |
| 369 | 369 | ||
| 370 | let mut dac = Self { | 370 | let mut dac = Self { |
| 371 | phantom: PhantomData, | 371 | phantom: PhantomData, |
| @@ -481,7 +481,7 @@ impl<'d, T: Instance, TxCh1, TxCh2> Dac<'d, T, TxCh1, TxCh2> { | |||
| 481 | pin_ch1.set_as_analog(); | 481 | pin_ch1.set_as_analog(); |
| 482 | pin_ch2.set_as_analog(); | 482 | pin_ch2.set_as_analog(); |
| 483 | into_ref!(peri, dma_ch1, dma_ch2); | 483 | into_ref!(peri, dma_ch1, dma_ch2); |
| 484 | T::reset_and_enable(); | 484 | T::enable_and_reset(); |
| 485 | 485 | ||
| 486 | let mut dac_ch1 = DacCh1 { | 486 | let mut dac_ch1 = DacCh1 { |
| 487 | _peri: peri, | 487 | _peri: peri, |
| @@ -567,7 +567,7 @@ foreach_peripheral!( | |||
| 567 | critical_section::with(|_| unsafe { crate::rcc::get_freqs().apb1 }) | 567 | critical_section::with(|_| unsafe { crate::rcc::get_freqs().apb1 }) |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | fn reset_and_enable() { | 570 | fn enable_and_reset() { |
| 571 | critical_section::with(|_| { | 571 | critical_section::with(|_| { |
| 572 | crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(true)); | 572 | crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(true)); |
| 573 | crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(false)); | 573 | crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(false)); |
diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index 6a63e6ee5..b12230794 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs | |||
| @@ -330,7 +330,7 @@ where | |||
| 330 | use_embedded_synchronization: bool, | 330 | use_embedded_synchronization: bool, |
| 331 | edm: u8, | 331 | edm: u8, |
| 332 | ) -> Self { | 332 | ) -> Self { |
| 333 | T::reset_and_enable(); | 333 | T::enable_and_reset(); |
| 334 | 334 | ||
| 335 | peri.regs().cr().modify(|r| { | 335 | peri.regs().cr().modify(|r| { |
| 336 | r.set_cm(true); // disable continuous mode (snapshot mode) | 336 | r.set_cm(true); // disable continuous mode (snapshot mode) |
diff --git a/embassy-stm32/src/fmc.rs b/embassy-stm32/src/fmc.rs index 51c75aeb3..d6e25996c 100644 --- a/embassy-stm32/src/fmc.rs +++ b/embassy-stm32/src/fmc.rs | |||
| @@ -19,7 +19,7 @@ where | |||
| 19 | const REGISTERS: *const () = T::REGS.as_ptr() as *const _; | 19 | const REGISTERS: *const () = T::REGS.as_ptr() as *const _; |
| 20 | 20 | ||
| 21 | fn enable(&mut self) { | 21 | fn enable(&mut self) { |
| 22 | T::reset_and_enable(); | 22 | T::enable_and_reset(); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | fn memory_controller_enable(&mut self) { | 25 | fn memory_controller_enable(&mut self) { |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 9192f731f..37fedf8e1 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -759,7 +759,7 @@ foreach_pin!( | |||
| 759 | 759 | ||
| 760 | pub(crate) unsafe fn init() { | 760 | pub(crate) unsafe fn init() { |
| 761 | #[cfg(afio)] | 761 | #[cfg(afio)] |
| 762 | <crate::peripherals::AFIO as crate::rcc::sealed::RccPeripheral>::reset_and_enable(); | 762 | <crate::peripherals::AFIO as crate::rcc::sealed::RccPeripheral>::enable_and_reset(); |
| 763 | 763 | ||
| 764 | crate::_generated::init_gpio(); | 764 | crate::_generated::init_gpio(); |
| 765 | } | 765 | } |
diff --git a/embassy-stm32/src/hrtim/mod.rs b/embassy-stm32/src/hrtim/mod.rs index 0c730ef7e..17096d48c 100644 --- a/embassy-stm32/src/hrtim/mod.rs +++ b/embassy-stm32/src/hrtim/mod.rs | |||
| @@ -157,7 +157,7 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> { | |||
| 157 | fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self { | 157 | fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self { |
| 158 | into_ref!(tim); | 158 | into_ref!(tim); |
| 159 | 159 | ||
| 160 | T::reset_and_enable(); | 160 | T::enable_and_reset(); |
| 161 | 161 | ||
| 162 | #[cfg(stm32f334)] | 162 | #[cfg(stm32f334)] |
| 163 | if unsafe { get_freqs() }.hrtim.is_some() { | 163 | if unsafe { get_freqs() }.hrtim.is_some() { |
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index cc2b23a7f..ab59f5ab9 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -56,7 +56,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 56 | ) -> Self { | 56 | ) -> Self { |
| 57 | into_ref!(scl, sda, tx_dma, rx_dma); | 57 | into_ref!(scl, sda, tx_dma, rx_dma); |
| 58 | 58 | ||
| 59 | T::reset_and_enable(); | 59 | T::enable_and_reset(); |
| 60 | 60 | ||
| 61 | scl.set_as_af_pull( | 61 | scl.set_as_af_pull( |
| 62 | scl.af_num(), | 62 | scl.af_num(), |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 1a49ecb24..b6d880d57 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -86,7 +86,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 86 | ) -> Self { | 86 | ) -> Self { |
| 87 | into_ref!(peri, scl, sda, tx_dma, rx_dma); | 87 | into_ref!(peri, scl, sda, tx_dma, rx_dma); |
| 88 | 88 | ||
| 89 | T::reset_and_enable(); | 89 | T::enable_and_reset(); |
| 90 | 90 | ||
| 91 | scl.set_as_af_pull( | 91 | scl.set_as_af_pull( |
| 92 | scl.af_num(), | 92 | scl.af_num(), |
diff --git a/embassy-stm32/src/ipcc.rs b/embassy-stm32/src/ipcc.rs index 2e58fe622..1b1e182f0 100644 --- a/embassy-stm32/src/ipcc.rs +++ b/embassy-stm32/src/ipcc.rs | |||
| @@ -93,7 +93,7 @@ pub struct Ipcc; | |||
| 93 | 93 | ||
| 94 | impl Ipcc { | 94 | impl Ipcc { |
| 95 | pub fn enable(_config: Config) { | 95 | pub fn enable(_config: Config) { |
| 96 | IPCC::reset_and_enable(); | 96 | IPCC::enable_and_reset(); |
| 97 | IPCC::set_cpu2(true); | 97 | IPCC::set_cpu2(true); |
| 98 | 98 | ||
| 99 | _configure_pwr(); | 99 | _configure_pwr(); |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 438494223..b93e5ee87 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -186,11 +186,11 @@ pub fn init(config: Config) -> Peripherals { | |||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | #[cfg(not(any(stm32f1, stm32wb, stm32wl)))] | 188 | #[cfg(not(any(stm32f1, stm32wb, stm32wl)))] |
| 189 | peripherals::SYSCFG::reset_and_enable(); | 189 | peripherals::SYSCFG::enable_and_reset(); |
| 190 | #[cfg(not(any(stm32h5, stm32h7, stm32wb, stm32wl)))] | 190 | #[cfg(not(any(stm32h5, stm32h7, stm32wb, stm32wl)))] |
| 191 | peripherals::PWR::reset_and_enable(); | 191 | peripherals::PWR::enable_and_reset(); |
| 192 | #[cfg(not(any(stm32f2, stm32f4, stm32f7, stm32l0, stm32h5, stm32h7)))] | 192 | #[cfg(not(any(stm32f2, stm32f4, stm32f7, stm32l0, stm32h5, stm32h7)))] |
| 193 | peripherals::FLASH::reset_and_enable(); | 193 | peripherals::FLASH::enable_and_reset(); |
| 194 | 194 | ||
| 195 | unsafe { | 195 | unsafe { |
| 196 | #[cfg(feature = "_split-pins-enabled")] | 196 | #[cfg(feature = "_split-pins-enabled")] |
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index 1c8bcbae9..4b0e8ecef 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs | |||
| @@ -177,7 +177,7 @@ impl<'d, T: Instance, Dma> Qspi<'d, T, Dma> { | |||
| 177 | ) -> Self { | 177 | ) -> Self { |
| 178 | into_ref!(peri, dma); | 178 | into_ref!(peri, dma); |
| 179 | 179 | ||
| 180 | T::reset_and_enable(); | 180 | T::enable_and_reset(); |
| 181 | 181 | ||
| 182 | while T::REGS.sr().read().busy() {} | 182 | while T::REGS.sr().read().busy() {} |
| 183 | 183 | ||
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index 1b6b5e85e..afdf5cc73 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs | |||
| @@ -296,7 +296,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 296 | 296 | ||
| 297 | // Enable and setup CRS if needed | 297 | // Enable and setup CRS if needed |
| 298 | if let Some(crs_config) = crs_config { | 298 | if let Some(crs_config) = crs_config { |
| 299 | crate::peripherals::CRS::reset_and_enable(); | 299 | crate::peripherals::CRS::enable_and_reset(); |
| 300 | 300 | ||
| 301 | let sync_src = match crs_config.sync_src { | 301 | let sync_src = match crs_config.sync_src { |
| 302 | CrsSyncSource::Gpio => crate::pac::crs::vals::Syncsrc::GPIO, | 302 | CrsSyncSource::Gpio => crate::pac::crs::vals::Syncsrc::GPIO, |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 451e12fec..0263c97aa 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -231,7 +231,7 @@ pub mod low_level { | |||
| 231 | pub(crate) mod sealed { | 231 | pub(crate) mod sealed { |
| 232 | pub trait RccPeripheral { | 232 | pub trait RccPeripheral { |
| 233 | fn frequency() -> crate::time::Hertz; | 233 | fn frequency() -> crate::time::Hertz; |
| 234 | fn reset_and_enable(); | 234 | fn enable_and_reset(); |
| 235 | fn disable(); | 235 | fn disable(); |
| 236 | } | 236 | } |
| 237 | } | 237 | } |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 0a3b966b6..fc003ebe6 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -43,7 +43,7 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 43 | inner: impl Peripheral<P = T> + 'd, | 43 | inner: impl Peripheral<P = T> + 'd, |
| 44 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 44 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 45 | ) -> Self { | 45 | ) -> Self { |
| 46 | T::reset_and_enable(); | 46 | T::enable_and_reset(); |
| 47 | into_ref!(inner); | 47 | into_ref!(inner); |
| 48 | let mut random = Self { _inner: inner }; | 48 | let mut random = Self { _inner: inner }; |
| 49 | random.reset(); | 49 | random.reset(); |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index 2eb0cde14..552dcc76f 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -184,7 +184,7 @@ impl Default for RtcCalibrationCyclePeriod { | |||
| 184 | impl Rtc { | 184 | impl Rtc { |
| 185 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { | 185 | pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self { |
| 186 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] | 186 | #[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))] |
| 187 | <RTC as crate::rcc::sealed::RccPeripheral>::reset_and_enable(); | 187 | <RTC as crate::rcc::sealed::RccPeripheral>::enable_and_reset(); |
| 188 | 188 | ||
| 189 | let mut this = Self { | 189 | let mut this = Self { |
| 190 | #[cfg(feature = "low-power")] | 190 | #[cfg(feature = "low-power")] |
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs index a394ba717..a0b4ddac7 100644 --- a/embassy-stm32/src/sai/mod.rs +++ b/embassy-stm32/src/sai/mod.rs | |||
| @@ -580,7 +580,7 @@ fn get_ring_buffer<'d, T: Instance, C: Channel, W: word::Word>( | |||
| 580 | 580 | ||
| 581 | impl<'d, T: Instance> Sai<'d, T> { | 581 | impl<'d, T: Instance> Sai<'d, T> { |
| 582 | pub fn new(peri: impl Peripheral<P = T> + 'd) -> Self { | 582 | pub fn new(peri: impl Peripheral<P = T> + 'd) -> Self { |
| 583 | T::reset_and_enable(); | 583 | T::enable_and_reset(); |
| 584 | 584 | ||
| 585 | Self { | 585 | Self { |
| 586 | _peri: unsafe { peri.clone_unchecked().into_ref() }, | 586 | _peri: unsafe { peri.clone_unchecked().into_ref() }, |
| @@ -960,7 +960,7 @@ impl<'d, T: Instance, C: Channel, W: word::Word> SubBlock<'d, T, C, W> { | |||
| 960 | } | 960 | } |
| 961 | 961 | ||
| 962 | pub fn reset() { | 962 | pub fn reset() { |
| 963 | T::reset_and_enable(); | 963 | T::enable_and_reset(); |
| 964 | } | 964 | } |
| 965 | 965 | ||
| 966 | pub fn flush(&mut self) { | 966 | pub fn flush(&mut self) { |
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index 595d2c199..bc29fe549 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -452,7 +452,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> { | |||
| 452 | ) -> Self { | 452 | ) -> Self { |
| 453 | into_ref!(sdmmc, dma); | 453 | into_ref!(sdmmc, dma); |
| 454 | 454 | ||
| 455 | T::reset_and_enable(); | 455 | T::enable_and_reset(); |
| 456 | 456 | ||
| 457 | T::Interrupt::unpend(); | 457 | T::Interrupt::unpend(); |
| 458 | unsafe { T::Interrupt::enable() }; | 458 | unsafe { T::Interrupt::enable() }; |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index ea7132e06..211b55231 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -230,7 +230,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 230 | 230 | ||
| 231 | let lsbfirst = config.raw_byte_order(); | 231 | let lsbfirst = config.raw_byte_order(); |
| 232 | 232 | ||
| 233 | T::reset_and_enable(); | 233 | T::enable_and_reset(); |
| 234 | 234 | ||
| 235 | #[cfg(any(spi_v1, spi_f1))] | 235 | #[cfg(any(spi_v1, spi_f1))] |
| 236 | { | 236 | { |
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 1468d9b6a..baea20aef 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs | |||
| @@ -155,7 +155,7 @@ impl RtcDriver { | |||
| 155 | fn init(&'static self) { | 155 | fn init(&'static self) { |
| 156 | let r = T::regs_gp16(); | 156 | let r = T::regs_gp16(); |
| 157 | 157 | ||
| 158 | <T as RccPeripheral>::reset_and_enable(); | 158 | <T as RccPeripheral>::enable_and_reset(); |
| 159 | 159 | ||
| 160 | let timer_freq = T::frequency(); | 160 | let timer_freq = T::frequency(); |
| 161 | 161 | ||
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 3818cc03c..9349a6fad 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -64,7 +64,7 @@ impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T> { | |||
| 64 | fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self { | 64 | fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self { |
| 65 | into_ref!(tim); | 65 | into_ref!(tim); |
| 66 | 66 | ||
| 67 | T::reset_and_enable(); | 67 | T::enable_and_reset(); |
| 68 | 68 | ||
| 69 | let mut this = Self { inner: tim }; | 69 | let mut this = Self { inner: tim }; |
| 70 | 70 | ||
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index ecc9fabc7..01d028bf9 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -55,7 +55,7 @@ impl<'d, T: CaptureCompare16bitInstance> Qei<'d, T> { | |||
| 55 | fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self { | 55 | fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self { |
| 56 | into_ref!(tim); | 56 | into_ref!(tim); |
| 57 | 57 | ||
| 58 | T::reset_and_enable(); | 58 | T::enable_and_reset(); |
| 59 | 59 | ||
| 60 | // Configure TxC1 and TxC2 as captures | 60 | // Configure TxC1 and TxC2 as captures |
| 61 | T::regs_gp16().ccmr_input(0).modify(|w| { | 61 | T::regs_gp16().ccmr_input(0).modify(|w| { |
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 83c812775..18ecc1964 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -63,7 +63,7 @@ impl<'d, T: CaptureCompare16bitInstance> SimplePwm<'d, T> { | |||
| 63 | fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self { | 63 | fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self { |
| 64 | into_ref!(tim); | 64 | into_ref!(tim); |
| 65 | 65 | ||
| 66 | T::reset_and_enable(); | 66 | T::enable_and_reset(); |
| 67 | 67 | ||
| 68 | let mut this = Self { inner: tim }; | 68 | let mut this = Self { inner: tim }; |
| 69 | 69 | ||
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index b4a74dc46..82d925a43 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -152,8 +152,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> { | |||
| 152 | config: Config, | 152 | config: Config, |
| 153 | ) -> Result<Self, ConfigError> { | 153 | ) -> Result<Self, ConfigError> { |
| 154 | // UartRx and UartTx have one refcount ea. | 154 | // UartRx and UartTx have one refcount ea. |
| 155 | T::reset_and_enable(); | 155 | T::enable_and_reset(); |
| 156 | T::reset_and_enable(); | 156 | T::enable_and_reset(); |
| 157 | 157 | ||
| 158 | Self::new_inner(peri, rx, tx, tx_buffer, rx_buffer, config) | 158 | Self::new_inner(peri, rx, tx, tx_buffer, rx_buffer, config) |
| 159 | } | 159 | } |
| @@ -172,8 +172,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> { | |||
| 172 | into_ref!(cts, rts); | 172 | into_ref!(cts, rts); |
| 173 | 173 | ||
| 174 | // UartRx and UartTx have one refcount ea. | 174 | // UartRx and UartTx have one refcount ea. |
| 175 | T::reset_and_enable(); | 175 | T::enable_and_reset(); |
| 176 | T::reset_and_enable(); | 176 | T::enable_and_reset(); |
| 177 | 177 | ||
| 178 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); | 178 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); |
| 179 | cts.set_as_af(cts.af_num(), AFType::Input); | 179 | cts.set_as_af(cts.af_num(), AFType::Input); |
| @@ -199,8 +199,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> { | |||
| 199 | into_ref!(de); | 199 | into_ref!(de); |
| 200 | 200 | ||
| 201 | // UartRx and UartTx have one refcount ea. | 201 | // UartRx and UartTx have one refcount ea. |
| 202 | T::reset_and_enable(); | 202 | T::enable_and_reset(); |
| 203 | T::reset_and_enable(); | 203 | T::enable_and_reset(); |
| 204 | 204 | ||
| 205 | de.set_as_af(de.af_num(), AFType::OutputPushPull); | 205 | de.set_as_af(de.af_num(), AFType::OutputPushPull); |
| 206 | T::regs().cr3().write(|w| { | 206 | T::regs().cr3().write(|w| { |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 93e21ccb6..3b7f5184d 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -228,7 +228,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> { | |||
| 228 | tx_dma: impl Peripheral<P = TxDma> + 'd, | 228 | tx_dma: impl Peripheral<P = TxDma> + 'd, |
| 229 | config: Config, | 229 | config: Config, |
| 230 | ) -> Result<Self, ConfigError> { | 230 | ) -> Result<Self, ConfigError> { |
| 231 | T::reset_and_enable(); | 231 | T::enable_and_reset(); |
| 232 | 232 | ||
| 233 | Self::new_inner(peri, tx, tx_dma, config) | 233 | Self::new_inner(peri, tx, tx_dma, config) |
| 234 | } | 234 | } |
| @@ -242,7 +242,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> { | |||
| 242 | ) -> Result<Self, ConfigError> { | 242 | ) -> Result<Self, ConfigError> { |
| 243 | into_ref!(cts); | 243 | into_ref!(cts); |
| 244 | 244 | ||
| 245 | T::reset_and_enable(); | 245 | T::enable_and_reset(); |
| 246 | 246 | ||
| 247 | cts.set_as_af(cts.af_num(), AFType::Input); | 247 | cts.set_as_af(cts.af_num(), AFType::Input); |
| 248 | T::regs().cr3().write(|w| { | 248 | T::regs().cr3().write(|w| { |
| @@ -319,7 +319,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> { | |||
| 319 | rx_dma: impl Peripheral<P = RxDma> + 'd, | 319 | rx_dma: impl Peripheral<P = RxDma> + 'd, |
| 320 | config: Config, | 320 | config: Config, |
| 321 | ) -> Result<Self, ConfigError> { | 321 | ) -> Result<Self, ConfigError> { |
| 322 | T::reset_and_enable(); | 322 | T::enable_and_reset(); |
| 323 | 323 | ||
| 324 | Self::new_inner(peri, rx, rx_dma, config) | 324 | Self::new_inner(peri, rx, rx_dma, config) |
| 325 | } | 325 | } |
| @@ -334,7 +334,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> { | |||
| 334 | ) -> Result<Self, ConfigError> { | 334 | ) -> Result<Self, ConfigError> { |
| 335 | into_ref!(rts); | 335 | into_ref!(rts); |
| 336 | 336 | ||
| 337 | T::reset_and_enable(); | 337 | T::enable_and_reset(); |
| 338 | 338 | ||
| 339 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); | 339 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); |
| 340 | T::regs().cr3().write(|w| { | 340 | T::regs().cr3().write(|w| { |
| @@ -691,8 +691,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 691 | config: Config, | 691 | config: Config, |
| 692 | ) -> Result<Self, ConfigError> { | 692 | ) -> Result<Self, ConfigError> { |
| 693 | // UartRx and UartTx have one refcount ea. | 693 | // UartRx and UartTx have one refcount ea. |
| 694 | T::reset_and_enable(); | 694 | T::enable_and_reset(); |
| 695 | T::reset_and_enable(); | 695 | T::enable_and_reset(); |
| 696 | 696 | ||
| 697 | Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config) | 697 | Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config) |
| 698 | } | 698 | } |
| @@ -711,8 +711,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 711 | into_ref!(cts, rts); | 711 | into_ref!(cts, rts); |
| 712 | 712 | ||
| 713 | // UartRx and UartTx have one refcount ea. | 713 | // UartRx and UartTx have one refcount ea. |
| 714 | T::reset_and_enable(); | 714 | T::enable_and_reset(); |
| 715 | T::reset_and_enable(); | 715 | T::enable_and_reset(); |
| 716 | 716 | ||
| 717 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); | 717 | rts.set_as_af(rts.af_num(), AFType::OutputPushPull); |
| 718 | cts.set_as_af(cts.af_num(), AFType::Input); | 718 | cts.set_as_af(cts.af_num(), AFType::Input); |
| @@ -737,8 +737,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | |||
| 737 | into_ref!(de); | 737 | into_ref!(de); |
| 738 | 738 | ||
| 739 | // UartRx and UartTx have one refcount ea. | 739 | // UartRx and UartTx have one refcount ea. |
| 740 | T::reset_and_enable(); | 740 | T::enable_and_reset(); |
| 741 | T::reset_and_enable(); | 741 | T::enable_and_reset(); |
| 742 | 742 | ||
| 743 | de.set_as_af(de.af_num(), AFType::OutputPushPull); | 743 | de.set_as_af(de.af_num(), AFType::OutputPushPull); |
| 744 | T::regs().cr3().write(|w| { | 744 | T::regs().cr3().write(|w| { |
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index d05207d1d..9269ddd88 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -269,7 +269,7 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 269 | #[cfg(pwr_h5)] | 269 | #[cfg(pwr_h5)] |
| 270 | crate::pac::PWR.usbscr().modify(|w| w.set_usb33sv(true)); | 270 | crate::pac::PWR.usbscr().modify(|w| w.set_usb33sv(true)); |
| 271 | 271 | ||
| 272 | <T as RccPeripheral>::reset_and_enable(); | 272 | <T as RccPeripheral>::enable_and_reset(); |
| 273 | 273 | ||
| 274 | regs.cntr().write(|w| { | 274 | regs.cntr().write(|w| { |
| 275 | w.set_pdwn(false); | 275 | w.set_pdwn(false); |
diff --git a/embassy-stm32/src/usb_otg/usb.rs b/embassy-stm32/src/usb_otg/usb.rs index 9edffa901..e45e4ac43 100644 --- a/embassy-stm32/src/usb_otg/usb.rs +++ b/embassy-stm32/src/usb_otg/usb.rs | |||
| @@ -632,7 +632,7 @@ impl<'d, T: Instance> Bus<'d, T> { | |||
| 632 | }); | 632 | }); |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | <T as RccPeripheral>::reset_and_enable(); | 635 | <T as RccPeripheral>::enable_and_reset(); |
| 636 | 636 | ||
| 637 | T::Interrupt::unpend(); | 637 | T::Interrupt::unpend(); |
| 638 | unsafe { T::Interrupt::enable() }; | 638 | unsafe { T::Interrupt::enable() }; |
