diff options
| author | Michael Medin <[email protected]> | 2025-04-24 10:54:35 +0200 |
|---|---|---|
| committer | Michael Medin <[email protected]> | 2025-04-24 10:54:35 +0200 |
| commit | b2c32a947ea724facb75f81978dfb5d3ca331ddb (patch) | |
| tree | 03af091407bd2f6e7151777d6e7cc45ee154f70a /embassy-stm32 | |
| parent | 6842ced7cb858f7735bc9376db9d39386dadec58 (diff) | |
Updated based on feedback
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/lib.rs | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 1ad30d522..af7ef9fe0 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -222,6 +222,7 @@ pub(crate) use stm32_metapac as pac; | |||
| 222 | use crate::interrupt::Priority; | 222 | use crate::interrupt::Priority; |
| 223 | #[cfg(feature = "rt")] | 223 | #[cfg(feature = "rt")] |
| 224 | pub use crate::pac::NVIC_PRIO_BITS; | 224 | pub use crate::pac::NVIC_PRIO_BITS; |
| 225 | use critical_section::CriticalSection; | ||
| 225 | 226 | ||
| 226 | /// `embassy-stm32` global configuration. | 227 | /// `embassy-stm32` global configuration. |
| 227 | #[non_exhaustive] | 228 | #[non_exhaustive] |
| @@ -600,17 +601,7 @@ fn init_hw(config: Config) -> Peripherals { | |||
| 600 | #[cfg(feature = "exti")] | 601 | #[cfg(feature = "exti")] |
| 601 | exti::init(cs); | 602 | exti::init(cs); |
| 602 | 603 | ||
| 603 | rcc::init(config.rcc); | 604 | init_rcc(cs, config.rcc); |
| 604 | |||
| 605 | // must be after rcc init | ||
| 606 | #[cfg(feature = "_time-driver")] | ||
| 607 | time_driver::init(cs); | ||
| 608 | |||
| 609 | #[cfg(feature = "low-power")] | ||
| 610 | { | ||
| 611 | crate::rcc::REFCOUNT_STOP2 = 0; | ||
| 612 | crate::rcc::REFCOUNT_STOP1 = 0; | ||
| 613 | } | ||
| 614 | } | 605 | } |
| 615 | 606 | ||
| 616 | p | 607 | p |
| @@ -626,20 +617,23 @@ fn init_hw(config: Config) -> Peripherals { | |||
| 626 | /// | 617 | /// |
| 627 | /// This should only be called after `init`. | 618 | /// This should only be called after `init`. |
| 628 | #[cfg(not(feature = "_dual-core"))] | 619 | #[cfg(not(feature = "_dual-core"))] |
| 629 | pub fn reinitialize_rcc(config: Config) { | 620 | pub fn reinit(config: rcc::Config) { |
| 630 | critical_section::with(|_cs| { | 621 | critical_section::with(|cs| init_rcc(cs, config)) |
| 631 | unsafe { | 622 | } |
| 632 | rcc::init(config.rcc); | ||
| 633 | 623 | ||
| 634 | // must be after rcc init | 624 | #[cfg(not(feature = "_dual-core"))] |
| 635 | #[cfg(feature = "_time-driver")] | 625 | fn init_rcc(_cs: CriticalSection, config: rcc::Config) { |
| 636 | time_driver::init(_cs); | 626 | unsafe { |
| 627 | rcc::init(config); | ||
| 637 | 628 | ||
| 638 | #[cfg(feature = "low-power")] | 629 | // must be after rcc init |
| 639 | { | 630 | #[cfg(feature = "_time-driver")] |
| 640 | crate::rcc::REFCOUNT_STOP2 = 0; | 631 | time_driver::init(_cs); |
| 641 | crate::rcc::REFCOUNT_STOP1 = 0; | 632 | |
| 642 | } | 633 | #[cfg(feature = "low-power")] |
| 634 | { | ||
| 635 | crate::rcc::REFCOUNT_STOP2 = 0; | ||
| 636 | crate::rcc::REFCOUNT_STOP1 = 0; | ||
| 643 | } | 637 | } |
| 644 | }) | 638 | } |
| 645 | } | 639 | } |
