diff options
Diffstat (limited to 'embassy-stm32/src/lib.rs')
| -rw-r--r-- | embassy-stm32/src/lib.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 680edf433..2f783bf64 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -95,6 +95,8 @@ pub mod i2c; | |||
| 95 | pub mod i2s; | 95 | pub mod i2s; |
| 96 | #[cfg(stm32wb)] | 96 | #[cfg(stm32wb)] |
| 97 | pub mod ipcc; | 97 | pub mod ipcc; |
| 98 | #[cfg(lcd)] | ||
| 99 | pub mod lcd; | ||
| 98 | #[cfg(feature = "low-power")] | 100 | #[cfg(feature = "low-power")] |
| 99 | pub mod low_power; | 101 | pub mod low_power; |
| 100 | #[cfg(lptim)] | 102 | #[cfg(lptim)] |
| @@ -151,7 +153,7 @@ pub use crate::_generated::interrupt; | |||
| 151 | /// Macro to bind interrupts to handlers. | 153 | /// Macro to bind interrupts to handlers. |
| 152 | /// | 154 | /// |
| 153 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 155 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) |
| 154 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 156 | /// and implements the right [`Binding`](crate::interrupt::typelevel::Binding)s for it. You can pass this struct to drivers to |
| 155 | /// prove at compile-time that the right interrupts have been bound. | 157 | /// prove at compile-time that the right interrupts have been bound. |
| 156 | /// | 158 | /// |
| 157 | /// Example of how to bind one interrupt: | 159 | /// Example of how to bind one interrupt: |
| @@ -178,6 +180,10 @@ pub use crate::_generated::interrupt; | |||
| 178 | /// } | 180 | /// } |
| 179 | /// ); | 181 | /// ); |
| 180 | /// ``` | 182 | /// ``` |
| 183 | /// | ||
| 184 | /// Some chips collate multiple interrupt signals into a single interrupt vector. In the above example, I2C2_3 is a | ||
| 185 | /// single vector which is activated by events and errors on both peripherals I2C2 and I2C3. Check your chip's list | ||
| 186 | /// of interrupt vectors if you get an unexpected compile error trying to bind the standard name. | ||
| 181 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. | 187 | // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. |
| 182 | #[macro_export] | 188 | #[macro_export] |
| 183 | macro_rules! bind_interrupts { | 189 | macro_rules! bind_interrupts { |
| @@ -649,12 +655,26 @@ fn init_hw(config: Config) -> Peripherals { | |||
| 649 | rcc::init_rcc(cs, config.rcc); | 655 | rcc::init_rcc(cs, config.rcc); |
| 650 | 656 | ||
| 651 | #[cfg(feature = "low-power")] | 657 | #[cfg(feature = "low-power")] |
| 652 | crate::rtc::init_rtc(cs, config.rtc); | 658 | rtc::init_rtc(cs, config.rtc, config.min_stop_pause); |
| 653 | 659 | ||
| 654 | #[cfg(feature = "low-power")] | 660 | #[cfg(all(stm32wb, feature = "low-power"))] |
| 655 | crate::time_driver::get_driver().set_min_stop_pause(cs, config.min_stop_pause); | 661 | hsem::init_hsem(cs); |
| 656 | } | 662 | } |
| 657 | 663 | ||
| 658 | p | 664 | p |
| 659 | }) | 665 | }) |
| 660 | } | 666 | } |
| 667 | |||
| 668 | /// Performs a busy-wait delay for a specified number of microseconds. | ||
| 669 | #[allow(unused)] | ||
| 670 | pub(crate) fn block_for_us(us: u64) { | ||
| 671 | cfg_if::cfg_if! { | ||
| 672 | // this does strange things on stm32wlx in low power mode depending on exactly when it's called | ||
| 673 | // as in sometimes 15 us (1 tick) would take > 20 seconds. | ||
| 674 | if #[cfg(all(feature = "time", all(not(feature = "low-power"), not(stm32wlex))))] { | ||
| 675 | embassy_time::block_for(embassy_time::Duration::from_micros(us)); | ||
| 676 | } else { | ||
| 677 | cortex_m::asm::delay(unsafe { rcc::get_freqs().sys.to_hertz().unwrap().0 as u64 * us / 1_000_000 } as u32); | ||
| 678 | } | ||
| 679 | } | ||
| 680 | } | ||
