aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/lib.rs
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-11-13 14:42:14 -0600
committerxoviat <[email protected]>2025-11-13 14:42:14 -0600
commit64b9c28eca4822a3ba1bd07d20964c2291c01cf5 (patch)
tree2263e3e12375ce83b14bf4ca42ba62eec21c3b85 /embassy-stm32/src/lib.rs
parent86fbcbdd7b9a5d37f6a7b1553e1ad0b5e5c8aa96 (diff)
stm32: extract block_for_us
remove from pub api
Diffstat (limited to 'embassy-stm32/src/lib.rs')
-rw-r--r--embassy-stm32/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 680edf433..6e492946a 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -658,3 +658,17 @@ fn init_hw(config: Config) -> Peripherals {
658 p 658 p
659 }) 659 })
660} 660}
661
662/// Performs a busy-wait delay for a specified number of microseconds.
663#[allow(unused)]
664pub(crate) fn block_for_us(us: u64) {
665 cfg_if::cfg_if! {
666 // this does strange things on stm32wlx in low power mode depending on exactly when it's called
667 // as in sometimes 15 us (1 tick) would take > 20 seconds.
668 if #[cfg(all(feature = "time", all(not(feature = "low-power"), not(stm32wlex))))] {
669 embassy_time::block_for(embassy_time::Duration::from_micros(us));
670 } else {
671 cortex_m::asm::delay(unsafe { rcc::get_freqs().sys.to_hertz().unwrap().0 as u64 * us / 1_000_000 } as u32);
672 }
673 }
674}