diff options
| author | Jan Špaček <[email protected]> | 2024-05-24 22:04:04 +0200 |
|---|---|---|
| committer | Jan Špaček <[email protected]> | 2024-05-25 18:44:55 +0200 |
| commit | 081afca3f065dfd91e157d7c9a9477e2d914c99d (patch) | |
| tree | 574b29636674d3e5a9e3763d00f709635856403e /embassy-stm32/src/can | |
| parent | 01c1cb2764300625f80b24e70052f250de27d814 (diff) | |
stm32/rcc: replace generated enable/disable code with runtime info
Diffstat (limited to 'embassy-stm32/src/can')
| -rw-r--r-- | embassy-stm32/src/can/bxcan/mod.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/can/fdcan.rs | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/embassy-stm32/src/can/bxcan/mod.rs b/embassy-stm32/src/can/bxcan/mod.rs index 912634b84..f6657f57e 100644 --- a/embassy-stm32/src/can/bxcan/mod.rs +++ b/embassy-stm32/src/can/bxcan/mod.rs | |||
| @@ -19,7 +19,7 @@ use super::util; | |||
| 19 | use crate::can::enums::{BusError, TryReadError}; | 19 | use crate::can::enums::{BusError, TryReadError}; |
| 20 | use crate::gpio::AFType; | 20 | use crate::gpio::AFType; |
| 21 | use crate::interrupt::typelevel::Interrupt; | 21 | use crate::interrupt::typelevel::Interrupt; |
| 22 | use crate::rcc::RccPeripheral; | 22 | use crate::rcc::{self, RccPeripheral}; |
| 23 | use crate::{interrupt, peripherals, Peripheral}; | 23 | use crate::{interrupt, peripherals, Peripheral}; |
| 24 | 24 | ||
| 25 | /// Interrupt handler. | 25 | /// Interrupt handler. |
| @@ -183,7 +183,7 @@ impl<'d, T: Instance> Can<'d, T> { | |||
| 183 | rx.set_as_af(rx.af_num(), AFType::Input); | 183 | rx.set_as_af(rx.af_num(), AFType::Input); |
| 184 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); | 184 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); |
| 185 | 185 | ||
| 186 | T::enable_and_reset(); | 186 | rcc::enable_and_reset::<T>(); |
| 187 | 187 | ||
| 188 | { | 188 | { |
| 189 | T::regs().ier().write(|w| { | 189 | T::regs().ier().write(|w| { |
| @@ -720,7 +720,7 @@ impl<'d, T: Instance> Drop for Can<'d, T> { | |||
| 720 | // Cannot call `free()` because it moves the instance. | 720 | // Cannot call `free()` because it moves the instance. |
| 721 | // Manually reset the peripheral. | 721 | // Manually reset the peripheral. |
| 722 | T::regs().mcr().write(|w| w.set_reset(true)); | 722 | T::regs().mcr().write(|w| w.set_reset(true)); |
| 723 | T::disable(); | 723 | rcc::disable::<T>(); |
| 724 | } | 724 | } |
| 725 | } | 725 | } |
| 726 | 726 | ||
diff --git a/embassy-stm32/src/can/fdcan.rs b/embassy-stm32/src/can/fdcan.rs index 81ceb06aa..d7b15274c 100644 --- a/embassy-stm32/src/can/fdcan.rs +++ b/embassy-stm32/src/can/fdcan.rs | |||
| @@ -11,7 +11,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 11 | use crate::can::fd::peripheral::Registers; | 11 | use crate::can::fd::peripheral::Registers; |
| 12 | use crate::gpio::AFType; | 12 | use crate::gpio::AFType; |
| 13 | use crate::interrupt::typelevel::Interrupt; | 13 | use crate::interrupt::typelevel::Interrupt; |
| 14 | use crate::rcc::RccPeripheral; | 14 | use crate::rcc::{self, RccPeripheral}; |
| 15 | use crate::{interrupt, peripherals, Peripheral}; | 15 | use crate::{interrupt, peripherals, Peripheral}; |
| 16 | 16 | ||
| 17 | pub(crate) mod fd; | 17 | pub(crate) mod fd; |
| @@ -180,7 +180,7 @@ impl<'d, T: Instance> CanConfigurator<'d, T> { | |||
| 180 | rx.set_as_af(rx.af_num(), AFType::Input); | 180 | rx.set_as_af(rx.af_num(), AFType::Input); |
| 181 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); | 181 | tx.set_as_af(tx.af_num(), AFType::OutputPushPull); |
| 182 | 182 | ||
| 183 | T::enable_and_reset(); | 183 | rcc::enable_and_reset::<T>(); |
| 184 | 184 | ||
| 185 | let mut config = crate::can::fd::config::FdCanConfig::default(); | 185 | let mut config = crate::can::fd::config::FdCanConfig::default(); |
| 186 | config.timestamp_source = TimestampSource::Prescaler(TimestampPrescaler::_1); | 186 | config.timestamp_source = TimestampSource::Prescaler(TimestampPrescaler::_1); |
