aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/lib.rs
diff options
context:
space:
mode:
authorTyler <[email protected]>2023-09-29 20:02:24 -0600
committerGitHub <[email protected]>2023-09-29 20:02:24 -0600
commit2f9b59c5cf21f1e2761a9ccefdfd86f0edea829c (patch)
tree8964744b4fb753cf98f6f413464106c4d2a72976 /embassy-stm32/src/lib.rs
parentce91fb2bfc846570ef543a09396c428d70675245 (diff)
parent95b3d9eb3b3657de3d7bc9c04f8fb83eae901640 (diff)
Merge branch 'main' into issue-1974-add-sai-driver
Diffstat (limited to 'embassy-stm32/src/lib.rs')
-rw-r--r--embassy-stm32/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index b5a128596..2718c96da 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -90,6 +90,7 @@ pub use crate::_generated::interrupt;
90#[macro_export] 90#[macro_export]
91macro_rules! bind_interrupts { 91macro_rules! bind_interrupts {
92 ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { 92 ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => {
93 #[derive(Copy, Clone)]
93 $vis struct $name; 94 $vis struct $name;
94 95
95 $( 96 $(
@@ -119,6 +120,7 @@ pub(crate) use stm32_metapac as pac;
119use crate::interrupt::Priority; 120use crate::interrupt::Priority;
120#[cfg(feature = "rt")] 121#[cfg(feature = "rt")]
121pub use crate::pac::NVIC_PRIO_BITS; 122pub use crate::pac::NVIC_PRIO_BITS;
123use crate::rcc::sealed::RccPeripheral;
122 124
123#[non_exhaustive] 125#[non_exhaustive]
124pub struct Config { 126pub struct Config {
@@ -156,7 +158,7 @@ pub fn init(config: Config) -> Peripherals {
156 #[cfg(dbgmcu)] 158 #[cfg(dbgmcu)]
157 if config.enable_debug_during_sleep { 159 if config.enable_debug_during_sleep {
158 crate::pac::DBGMCU.cr().modify(|cr| { 160 crate::pac::DBGMCU.cr().modify(|cr| {
159 #[cfg(any(dbgmcu_f0, dbgmcu_c0, dbgmcu_g0, dbgmcu_u5))] 161 #[cfg(any(dbgmcu_f0, dbgmcu_c0, dbgmcu_g0, dbgmcu_u5, dbgmcu_wba))]
160 { 162 {
161 cr.set_dbg_stop(true); 163 cr.set_dbg_stop(true);
162 cr.set_dbg_standby(true); 164 cr.set_dbg_standby(true);
@@ -181,6 +183,13 @@ pub fn init(config: Config) -> Peripherals {
181 }); 183 });
182 } 184 }
183 185
186 #[cfg(not(any(stm32f1, stm32wb, stm32wl)))]
187 peripherals::SYSCFG::enable();
188 #[cfg(not(any(stm32h5, stm32h7, stm32wb, stm32wl)))]
189 peripherals::PWR::enable();
190 #[cfg(not(any(stm32f2, stm32f4, stm32f7, stm32l0, stm32h5, stm32h7)))]
191 peripherals::FLASH::enable();
192
184 unsafe { 193 unsafe {
185 gpio::init(); 194 gpio::init();
186 dma::init( 195 dma::init(
@@ -199,6 +208,11 @@ pub fn init(config: Config) -> Peripherals {
199 // must be after rcc init 208 // must be after rcc init
200 #[cfg(feature = "_time-driver")] 209 #[cfg(feature = "_time-driver")]
201 time_driver::init(); 210 time_driver::init();
211
212 #[cfg(feature = "low-power")]
213 while !crate::rcc::low_power_ready() {
214 crate::rcc::clock_refcount_sub();
215 }
202 } 216 }
203 217
204 p 218 p