diff options
174 files changed, 496 insertions, 501 deletions
diff --git a/cyw43/src/bus.rs b/cyw43/src/bus.rs index 0b5632cf8..014109038 100644 --- a/cyw43/src/bus.rs +++ b/cyw43/src/bus.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use embassy_futures::yield_now; | 1 | use embassy_futures::yield_now; |
| 2 | use embassy_time::{Duration, Timer}; | 2 | use embassy_time::Timer; |
| 3 | use embedded_hal_1::digital::OutputPin; | 3 | use embedded_hal_1::digital::OutputPin; |
| 4 | use futures::FutureExt; | 4 | use futures::FutureExt; |
| 5 | 5 | ||
| @@ -51,9 +51,9 @@ where | |||
| 51 | pub async fn init(&mut self) { | 51 | pub async fn init(&mut self) { |
| 52 | // Reset | 52 | // Reset |
| 53 | self.pwr.set_low().unwrap(); | 53 | self.pwr.set_low().unwrap(); |
| 54 | Timer::after(Duration::from_millis(20)).await; | 54 | Timer::after_millis(20).await; |
| 55 | self.pwr.set_high().unwrap(); | 55 | self.pwr.set_high().unwrap(); |
| 56 | Timer::after(Duration::from_millis(250)).await; | 56 | Timer::after_millis(250).await; |
| 57 | 57 | ||
| 58 | while self | 58 | while self |
| 59 | .read32_swapped(REG_BUS_TEST_RO) | 59 | .read32_swapped(REG_BUS_TEST_RO) |
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index a6d1f0bf5..2585b31dc 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -2,7 +2,7 @@ use core::cmp::{max, min}; | |||
| 2 | 2 | ||
| 3 | use ch::driver::LinkState; | 3 | use ch::driver::LinkState; |
| 4 | use embassy_net_driver_channel as ch; | 4 | use embassy_net_driver_channel as ch; |
| 5 | use embassy_time::{Duration, Timer}; | 5 | use embassy_time::Timer; |
| 6 | 6 | ||
| 7 | pub use crate::bus::SpiBusCyw43; | 7 | pub use crate::bus::SpiBusCyw43; |
| 8 | use crate::consts::*; | 8 | use crate::consts::*; |
| @@ -87,22 +87,22 @@ impl<'a> Control<'a> { | |||
| 87 | self.set_iovar("country", &country_info.to_bytes()).await; | 87 | self.set_iovar("country", &country_info.to_bytes()).await; |
| 88 | 88 | ||
| 89 | // set country takes some time, next ioctls fail if we don't wait. | 89 | // set country takes some time, next ioctls fail if we don't wait. |
| 90 | Timer::after(Duration::from_millis(100)).await; | 90 | Timer::after_millis(100).await; |
| 91 | 91 | ||
| 92 | // Set antenna to chip antenna | 92 | // Set antenna to chip antenna |
| 93 | self.ioctl_set_u32(IOCTL_CMD_ANTDIV, 0, 0).await; | 93 | self.ioctl_set_u32(IOCTL_CMD_ANTDIV, 0, 0).await; |
| 94 | 94 | ||
| 95 | self.set_iovar_u32("bus:txglom", 0).await; | 95 | self.set_iovar_u32("bus:txglom", 0).await; |
| 96 | Timer::after(Duration::from_millis(100)).await; | 96 | Timer::after_millis(100).await; |
| 97 | //self.set_iovar_u32("apsta", 1).await; // this crashes, also we already did it before...?? | 97 | //self.set_iovar_u32("apsta", 1).await; // this crashes, also we already did it before...?? |
| 98 | //Timer::after(Duration::from_millis(100)).await; | 98 | //Timer::after_millis(100).await; |
| 99 | self.set_iovar_u32("ampdu_ba_wsize", 8).await; | 99 | self.set_iovar_u32("ampdu_ba_wsize", 8).await; |
| 100 | Timer::after(Duration::from_millis(100)).await; | 100 | Timer::after_millis(100).await; |
| 101 | self.set_iovar_u32("ampdu_mpdu", 4).await; | 101 | self.set_iovar_u32("ampdu_mpdu", 4).await; |
| 102 | Timer::after(Duration::from_millis(100)).await; | 102 | Timer::after_millis(100).await; |
| 103 | //self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes | 103 | //self.set_iovar_u32("ampdu_rx_factor", 0).await; // this crashes |
| 104 | 104 | ||
| 105 | //Timer::after(Duration::from_millis(100)).await; | 105 | //Timer::after_millis(100).await; |
| 106 | 106 | ||
| 107 | // evts | 107 | // evts |
| 108 | let mut evts = EventMask { | 108 | let mut evts = EventMask { |
| @@ -121,17 +121,17 @@ impl<'a> Control<'a> { | |||
| 121 | 121 | ||
| 122 | self.set_iovar("bsscfg:event_msgs", &evts.to_bytes()).await; | 122 | self.set_iovar("bsscfg:event_msgs", &evts.to_bytes()).await; |
| 123 | 123 | ||
| 124 | Timer::after(Duration::from_millis(100)).await; | 124 | Timer::after_millis(100).await; |
| 125 | 125 | ||
| 126 | // set wifi up | 126 | // set wifi up |
| 127 | self.up().await; | 127 | self.up().await; |
| 128 | 128 | ||
| 129 | Timer::after(Duration::from_millis(100)).await; | 129 | Timer::after_millis(100).await; |
| 130 | 130 | ||
| 131 | self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto | 131 | self.ioctl_set_u32(110, 0, 1).await; // SET_GMODE = auto |
| 132 | self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any | 132 | self.ioctl_set_u32(142, 0, 0).await; // SET_BAND = any |
| 133 | 133 | ||
| 134 | Timer::after(Duration::from_millis(100)).await; | 134 | Timer::after_millis(100).await; |
| 135 | 135 | ||
| 136 | self.state_ch.set_ethernet_address(mac_addr); | 136 | self.state_ch.set_ethernet_address(mac_addr); |
| 137 | 137 | ||
| @@ -185,7 +185,7 @@ impl<'a> Control<'a> { | |||
| 185 | self.set_iovar_u32x2("bsscfg:sup_wpa2_eapver", 0, 0xFFFF_FFFF).await; | 185 | self.set_iovar_u32x2("bsscfg:sup_wpa2_eapver", 0, 0xFFFF_FFFF).await; |
| 186 | self.set_iovar_u32x2("bsscfg:sup_wpa_tmo", 0, 2500).await; | 186 | self.set_iovar_u32x2("bsscfg:sup_wpa_tmo", 0, 2500).await; |
| 187 | 187 | ||
| 188 | Timer::after(Duration::from_millis(100)).await; | 188 | Timer::after_millis(100).await; |
| 189 | 189 | ||
| 190 | let mut pfi = PassphraseInfo { | 190 | let mut pfi = PassphraseInfo { |
| 191 | len: passphrase.len() as _, | 191 | len: passphrase.len() as _, |
| @@ -297,7 +297,7 @@ impl<'a> Control<'a> { | |||
| 297 | if security != Security::OPEN { | 297 | if security != Security::OPEN { |
| 298 | self.set_iovar_u32x2("bsscfg:wpa_auth", 0, 0x0084).await; // wpa_auth = WPA2_AUTH_PSK | WPA_AUTH_PSK | 298 | self.set_iovar_u32x2("bsscfg:wpa_auth", 0, 0x0084).await; // wpa_auth = WPA2_AUTH_PSK | WPA_AUTH_PSK |
| 299 | 299 | ||
| 300 | Timer::after(Duration::from_millis(100)).await; | 300 | Timer::after_millis(100).await; |
| 301 | 301 | ||
| 302 | // Set passphrase | 302 | // Set passphrase |
| 303 | let mut pfi = PassphraseInfo { | 303 | let mut pfi = PassphraseInfo { |
diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 1c187faa5..83aee6b40 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs | |||
| @@ -555,14 +555,14 @@ where | |||
| 555 | 555 | ||
| 556 | self.bus.bp_write8(base + AI_RESETCTRL_OFFSET, 0).await; | 556 | self.bus.bp_write8(base + AI_RESETCTRL_OFFSET, 0).await; |
| 557 | 557 | ||
| 558 | Timer::after(Duration::from_millis(1)).await; | 558 | Timer::after_millis(1).await; |
| 559 | 559 | ||
| 560 | self.bus | 560 | self.bus |
| 561 | .bp_write8(base + AI_IOCTRL_OFFSET, AI_IOCTRL_BIT_CLOCK_EN) | 561 | .bp_write8(base + AI_IOCTRL_OFFSET, AI_IOCTRL_BIT_CLOCK_EN) |
| 562 | .await; | 562 | .await; |
| 563 | let _ = self.bus.bp_read8(base + AI_IOCTRL_OFFSET).await; | 563 | let _ = self.bus.bp_read8(base + AI_IOCTRL_OFFSET).await; |
| 564 | 564 | ||
| 565 | Timer::after(Duration::from_millis(1)).await; | 565 | Timer::after_millis(1).await; |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | async fn core_is_up(&mut self, core: Core) -> bool { | 568 | async fn core_is_up(&mut self, core: Core) -> bool { |
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index b2a9f1e33..5d3cf658a 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs | |||
| @@ -76,9 +76,7 @@ where | |||
| 76 | #[cfg(not(feature = "time"))] | 76 | #[cfg(not(feature = "time"))] |
| 77 | Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), | 77 | Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), |
| 78 | #[cfg(feature = "time")] | 78 | #[cfg(feature = "time")] |
| 79 | Operation::DelayUs(us) => { | 79 | Operation::DelayUs(us) => embassy_time::Timer::after_micros(*us as _).await, |
| 80 | embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await | ||
| 81 | } | ||
| 82 | } | 80 | } |
| 83 | } | 81 | } |
| 84 | }; | 82 | }; |
| @@ -143,9 +141,7 @@ where | |||
| 143 | #[cfg(not(feature = "time"))] | 141 | #[cfg(not(feature = "time"))] |
| 144 | Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), | 142 | Operation::DelayUs(_) => return Err(SpiDeviceError::DelayUsNotSupported), |
| 145 | #[cfg(feature = "time")] | 143 | #[cfg(feature = "time")] |
| 146 | Operation::DelayUs(us) => { | 144 | Operation::DelayUs(us) => embassy_time::Timer::after_micros(*us as _).await, |
| 147 | embassy_time::Timer::after(embassy_time::Duration::from_micros(*us as _)).await | ||
| 148 | } | ||
| 149 | } | 145 | } |
| 150 | } | 146 | } |
| 151 | }; | 147 | }; |
diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs index 0a9cea16e..5637802bb 100644 --- a/embassy-lora/src/lib.rs +++ b/embassy-lora/src/lib.rs | |||
| @@ -34,6 +34,6 @@ impl lorawan_device::async_device::radio::Timer for LoraTimer { | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | async fn delay_ms(&mut self, millis: u64) { | 36 | async fn delay_ms(&mut self, millis: u64) { |
| 37 | Timer::after(Duration::from_millis(millis)).await | 37 | Timer::after_millis(millis).await |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 53f361284..edee3438b 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs | |||
| @@ -20,7 +20,7 @@ pub use crc32::ETH_FCS; | |||
| 20 | use crc8::crc8; | 20 | use crc8::crc8; |
| 21 | use embassy_futures::select::{select, Either}; | 21 | use embassy_futures::select::{select, Either}; |
| 22 | use embassy_net_driver_channel as ch; | 22 | use embassy_net_driver_channel as ch; |
| 23 | use embassy_time::{Duration, Timer}; | 23 | use embassy_time::Timer; |
| 24 | use embedded_hal_1::digital::OutputPin; | 24 | use embedded_hal_1::digital::OutputPin; |
| 25 | use embedded_hal_async::digital::Wait; | 25 | use embedded_hal_async::digital::Wait; |
| 26 | use embedded_hal_async::spi::{Error, Operation, SpiDevice}; | 26 | use embedded_hal_async::spi::{Error, Operation, SpiDevice}; |
| @@ -609,12 +609,12 @@ pub async fn new<const N_RX: usize, const N_TX: usize, SPI: SpiDevice, INT: Wait | |||
| 609 | reset.set_low().unwrap(); | 609 | reset.set_low().unwrap(); |
| 610 | 610 | ||
| 611 | // Wait t1: 20-43mS | 611 | // Wait t1: 20-43mS |
| 612 | Timer::after(Duration::from_millis(30)).await; | 612 | Timer::after_millis(30).await; |
| 613 | 613 | ||
| 614 | reset.set_high().unwrap(); | 614 | reset.set_high().unwrap(); |
| 615 | 615 | ||
| 616 | // Wait t3: 50mS | 616 | // Wait t3: 50mS |
| 617 | Timer::after(Duration::from_millis(50)).await; | 617 | Timer::after_millis(50).await; |
| 618 | 618 | ||
| 619 | // Create device | 619 | // Create device |
| 620 | let mut mac = ADIN1110::new(spi_dev, spi_crc, append_fcs_on_tx); | 620 | let mut mac = ADIN1110::new(spi_dev, spi_crc, append_fcs_on_tx); |
diff --git a/embassy-net-esp-hosted/src/lib.rs b/embassy-net-esp-hosted/src/lib.rs index 4a318b20d..d61eaef3a 100644 --- a/embassy-net-esp-hosted/src/lib.rs +++ b/embassy-net-esp-hosted/src/lib.rs | |||
| @@ -169,9 +169,9 @@ where | |||
| 169 | pub async fn run(mut self) -> ! { | 169 | pub async fn run(mut self) -> ! { |
| 170 | debug!("resetting..."); | 170 | debug!("resetting..."); |
| 171 | self.reset.set_low().unwrap(); | 171 | self.reset.set_low().unwrap(); |
| 172 | Timer::after(Duration::from_millis(100)).await; | 172 | Timer::after_millis(100).await; |
| 173 | self.reset.set_high().unwrap(); | 173 | self.reset.set_high().unwrap(); |
| 174 | Timer::after(Duration::from_millis(1000)).await; | 174 | Timer::after_millis(1000).await; |
| 175 | 175 | ||
| 176 | let mut tx_buf = [0u8; MAX_SPI_BUFFER_SIZE]; | 176 | let mut tx_buf = [0u8; MAX_SPI_BUFFER_SIZE]; |
| 177 | let mut rx_buf = [0u8; MAX_SPI_BUFFER_SIZE]; | 177 | let mut rx_buf = [0u8; MAX_SPI_BUFFER_SIZE]; |
diff --git a/embassy-net-wiznet/src/lib.rs b/embassy-net-wiznet/src/lib.rs index 3030dfb90..48d17cac2 100644 --- a/embassy-net-wiznet/src/lib.rs +++ b/embassy-net-wiznet/src/lib.rs | |||
| @@ -8,7 +8,7 @@ mod device; | |||
| 8 | use embassy_futures::select::{select, Either}; | 8 | use embassy_futures::select::{select, Either}; |
| 9 | use embassy_net_driver_channel as ch; | 9 | use embassy_net_driver_channel as ch; |
| 10 | use embassy_net_driver_channel::driver::LinkState; | 10 | use embassy_net_driver_channel::driver::LinkState; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use embedded_hal::digital::OutputPin; | 12 | use embedded_hal::digital::OutputPin; |
| 13 | use embedded_hal_async::digital::Wait; | 13 | use embedded_hal_async::digital::Wait; |
| 14 | use embedded_hal_async::spi::SpiDevice; | 14 | use embedded_hal_async::spi::SpiDevice; |
| @@ -95,12 +95,12 @@ pub async fn new<'a, const N_RX: usize, const N_TX: usize, C: Chip, SPI: SpiDevi | |||
| 95 | // Reset the chip. | 95 | // Reset the chip. |
| 96 | reset.set_low().ok(); | 96 | reset.set_low().ok(); |
| 97 | // Ensure the reset is registered. | 97 | // Ensure the reset is registered. |
| 98 | Timer::after(Duration::from_millis(1)).await; | 98 | Timer::after_millis(1).await; |
| 99 | reset.set_high().ok(); | 99 | reset.set_high().ok(); |
| 100 | 100 | ||
| 101 | // Wait for PLL lock. Some chips are slower than others. | 101 | // Wait for PLL lock. Some chips are slower than others. |
| 102 | // Slowest is w5100s which is 100ms, so let's just wait that. | 102 | // Slowest is w5100s which is 100ms, so let's just wait that. |
| 103 | Timer::after(Duration::from_millis(100)).await; | 103 | Timer::after_millis(100).await; |
| 104 | 104 | ||
| 105 | let mac = WiznetDevice::new(spi_dev, mac_addr).await.unwrap(); | 105 | let mac = WiznetDevice::new(spi_dev, mac_addr).await.unwrap(); |
| 106 | 106 | ||
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index 645d703d8..9f638761d 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -5,7 +5,7 @@ use core::task::Poll; | |||
| 5 | use atomic_polyfill::{AtomicU8, Ordering}; | 5 | use atomic_polyfill::{AtomicU8, Ordering}; |
| 6 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; | 6 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; |
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | 9 | ||
| 10 | use super::*; | 10 | use super::*; |
| 11 | use crate::clocks::clk_peri_freq; | 11 | use crate::clocks::clk_peri_freq; |
| @@ -435,7 +435,7 @@ impl<'d, T: Instance> BufferedUartTx<'d, T> { | |||
| 435 | Self::flush().await.unwrap(); | 435 | Self::flush().await.unwrap(); |
| 436 | while self.busy() {} | 436 | while self.busy() {} |
| 437 | regs.uartlcr_h().write_set(|w| w.set_brk(true)); | 437 | regs.uartlcr_h().write_set(|w| w.set_brk(true)); |
| 438 | Timer::after(Duration::from_micros(wait_usecs)).await; | 438 | Timer::after_micros(wait_usecs).await; |
| 439 | regs.uartlcr_h().write_clear(|w| w.set_brk(true)); | 439 | regs.uartlcr_h().write_clear(|w| w.set_brk(true)); |
| 440 | } | 440 | } |
| 441 | } | 441 | } |
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 202b0883e..461986c81 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -6,7 +6,7 @@ use atomic_polyfill::{AtomicU16, Ordering}; | |||
| 6 | use embassy_futures::select::{select, Either}; | 6 | use embassy_futures::select::{select, Either}; |
| 7 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 7 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use pac::uart::regs::Uartris; | 10 | use pac::uart::regs::Uartris; |
| 11 | 11 | ||
| 12 | use crate::clocks::clk_peri_freq; | 12 | use crate::clocks::clk_peri_freq; |
| @@ -187,7 +187,7 @@ impl<'d, T: Instance, M: Mode> UartTx<'d, T, M> { | |||
| 187 | self.blocking_flush().unwrap(); | 187 | self.blocking_flush().unwrap(); |
| 188 | while self.busy() {} | 188 | while self.busy() {} |
| 189 | regs.uartlcr_h().write_set(|w| w.set_brk(true)); | 189 | regs.uartlcr_h().write_set(|w| w.set_brk(true)); |
| 190 | Timer::after(Duration::from_micros(wait_usecs)).await; | 190 | Timer::after_micros(wait_usecs).await; |
| 191 | regs.uartlcr_h().write_clear(|w| w.set_brk(true)); | 191 | regs.uartlcr_h().write_clear(|w| w.set_brk(true)); |
| 192 | } | 192 | } |
| 193 | } | 193 | } |
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs index cf1918724..be962747c 100644 --- a/embassy-time/src/delay.rs +++ b/embassy-time/src/delay.rs | |||
| @@ -36,11 +36,11 @@ mod eha { | |||
| 36 | 36 | ||
| 37 | impl embedded_hal_async::delay::DelayUs for Delay { | 37 | impl embedded_hal_async::delay::DelayUs for Delay { |
| 38 | async fn delay_us(&mut self, micros: u32) { | 38 | async fn delay_us(&mut self, micros: u32) { |
| 39 | Timer::after(Duration::from_micros(micros as _)).await | 39 | Timer::after_micros(micros as _).await |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | async fn delay_ms(&mut self, millis: u32) { | 42 | async fn delay_ms(&mut self, millis: u32) { |
| 43 | Timer::after(Duration::from_millis(millis as _)).await | 43 | Timer::after_millis(millis as _).await |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 15ebce5fa..a88c3c56c 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use panic_reset as _; | 9 | use panic_reset as _; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -19,8 +19,8 @@ async fn main(_spawner: Spawner) { | |||
| 19 | 19 | ||
| 20 | loop { | 20 | loop { |
| 21 | led.set_high(); | 21 | led.set_high(); |
| 22 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after_millis(300).await; |
| 23 | led.set_low(); | 23 | led.set_low(); |
| 24 | Timer::after(Duration::from_millis(300)).await; | 24 | Timer::after_millis(300).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs index a4602a7ed..6fd5d7f60 100644 --- a/examples/boot/application/rp/src/bin/a.rs +++ b/examples/boot/application/rp/src/bin/a.rs | |||
| @@ -41,7 +41,7 @@ async fn main(_s: Spawner) { | |||
| 41 | let mut aligned = AlignedBuffer([0; 1]); | 41 | let mut aligned = AlignedBuffer([0; 1]); |
| 42 | let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0); | 42 | let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0); |
| 43 | 43 | ||
| 44 | Timer::after(Duration::from_secs(5)).await; | 44 | Timer::after_secs(5).await; |
| 45 | watchdog.feed(); | 45 | watchdog.feed(); |
| 46 | led.set_high(); | 46 | led.set_high(); |
| 47 | let mut offset = 0; | 47 | let mut offset = 0; |
| @@ -61,7 +61,7 @@ async fn main(_s: Spawner) { | |||
| 61 | watchdog.feed(); | 61 | watchdog.feed(); |
| 62 | defmt::info!("firmware written, marking update"); | 62 | defmt::info!("firmware written, marking update"); |
| 63 | updater.mark_updated().unwrap(); | 63 | updater.mark_updated().unwrap(); |
| 64 | Timer::after(Duration::from_secs(2)).await; | 64 | Timer::after_secs(2).await; |
| 65 | led.set_low(); | 65 | led.set_low(); |
| 66 | defmt::info!("update marked, resetting"); | 66 | defmt::info!("update marked, resetting"); |
| 67 | cortex_m::peripheral::SCB::sys_reset(); | 67 | cortex_m::peripheral::SCB::sys_reset(); |
diff --git a/examples/boot/application/rp/src/bin/b.rs b/examples/boot/application/rp/src/bin/b.rs index 47dec329c..1eca5b4a2 100644 --- a/examples/boot/application/rp/src/bin/b.rs +++ b/examples/boot/application/rp/src/bin/b.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::gpio; | 6 | use embassy_rp::gpio; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use gpio::{Level, Output}; | 8 | use gpio::{Level, Output}; |
| 9 | use {defmt_rtt as _, panic_reset as _}; | 9 | use {defmt_rtt as _, panic_reset as _}; |
| 10 | 10 | ||
| @@ -15,9 +15,9 @@ async fn main(_s: Spawner) { | |||
| 15 | 15 | ||
| 16 | loop { | 16 | loop { |
| 17 | led.set_high(); | 17 | led.set_high(); |
| 18 | Timer::after(Duration::from_millis(100)).await; | 18 | Timer::after_millis(100).await; |
| 19 | 19 | ||
| 20 | led.set_low(); | 20 | led.set_low(); |
| 21 | Timer::after(Duration::from_millis(100)).await; | 21 | Timer::after_millis(100).await; |
| 22 | } | 22 | } |
| 23 | } | 23 | } |
diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index a5862b1b0..8411f384c 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -16,9 +16,9 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | led.set_high(); | 18 | led.set_high(); |
| 19 | Timer::after(Duration::from_millis(500)).await; | 19 | Timer::after_millis(500).await; |
| 20 | 20 | ||
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after_millis(500).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index 16c94d845..4c2ad06a2 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs | |||
| @@ -6,21 +6,21 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | 14 | let p = embassy_stm32::init(Default::default()); |
| 15 | Timer::after(Duration::from_millis(300)).await; | 15 | Timer::after_millis(300).await; |
| 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
| 17 | led.set_high(); | 17 | led.set_high(); |
| 18 | 18 | ||
| 19 | loop { | 19 | loop { |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | led.set_low(); | 23 | led.set_low(); |
| 24 | Timer::after(Duration::from_millis(500)).await; | 24 | Timer::after_millis(500).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index 34799279c..5c03e2d0c 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs | |||
| @@ -6,21 +6,21 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | 14 | let p = embassy_stm32::init(Default::default()); |
| 15 | Timer::after(Duration::from_millis(300)).await; | 15 | Timer::after_millis(300).await; |
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 17 | led.set_high(); | 17 | led.set_high(); |
| 18 | 18 | ||
| 19 | loop { | 19 | loop { |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | led.set_low(); | 23 | led.set_low(); |
| 24 | Timer::after(Duration::from_millis(500)).await; | 24 | Timer::after_millis(500).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index b4cdcd44d..42e1a71eb 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::exti::ExtiInput; | |||
| 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_sync::mutex::Mutex; | 13 | use embassy_sync::mutex::Mutex; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::Timer; |
| 15 | use panic_reset as _; | 15 | use panic_reset as _; |
| 16 | 16 | ||
| 17 | #[cfg(feature = "skip-include")] | 17 | #[cfg(feature = "skip-include")] |
| @@ -46,6 +46,6 @@ async fn main(_spawner: Spawner) { | |||
| 46 | 46 | ||
| 47 | updater.mark_updated().await.unwrap(); | 47 | updater.mark_updated().await.unwrap(); |
| 48 | led.set_low(); | 48 | led.set_low(); |
| 49 | Timer::after(Duration::from_secs(1)).await; | 49 | Timer::after_secs(1).await; |
| 50 | cortex_m::peripheral::SCB::sys_reset(); | 50 | cortex_m::peripheral::SCB::sys_reset(); |
| 51 | } | 51 | } |
diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index ee40274ff..52d42395f 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -16,9 +16,9 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | led.set_high(); | 18 | led.set_high(); |
| 19 | Timer::after(Duration::from_millis(500)).await; | 19 | Timer::after_millis(500).await; |
| 20 | 20 | ||
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after_millis(500).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index b4cdcd44d..42e1a71eb 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::exti::ExtiInput; | |||
| 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use embassy_sync::mutex::Mutex; | 13 | use embassy_sync::mutex::Mutex; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::Timer; |
| 15 | use panic_reset as _; | 15 | use panic_reset as _; |
| 16 | 16 | ||
| 17 | #[cfg(feature = "skip-include")] | 17 | #[cfg(feature = "skip-include")] |
| @@ -46,6 +46,6 @@ async fn main(_spawner: Spawner) { | |||
| 46 | 46 | ||
| 47 | updater.mark_updated().await.unwrap(); | 47 | updater.mark_updated().await.unwrap(); |
| 48 | led.set_low(); | 48 | led.set_low(); |
| 49 | Timer::after(Duration::from_secs(1)).await; | 49 | Timer::after_secs(1).await; |
| 50 | cortex_m::peripheral::SCB::sys_reset(); | 50 | cortex_m::peripheral::SCB::sys_reset(); |
| 51 | } | 51 | } |
diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index ee40274ff..52d42395f 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -16,9 +16,9 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | led.set_high(); | 18 | led.set_high(); |
| 19 | Timer::after(Duration::from_millis(500)).await; | 19 | Timer::after_millis(500).await; |
| 20 | 20 | ||
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after_millis(500).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index a5862b1b0..8411f384c 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -16,9 +16,9 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | led.set_high(); | 18 | led.set_high(); |
| 19 | Timer::after(Duration::from_millis(500)).await; | 19 | Timer::after_millis(500).await; |
| 20 | 20 | ||
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after_millis(500).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index f9f0ffc60..1ca3c6ea8 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use panic_reset as _; | 10 | use panic_reset as _; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -16,9 +16,9 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | loop { | 17 | loop { |
| 18 | led.set_high(); | 18 | led.set_high(); |
| 19 | Timer::after(Duration::from_millis(500)).await; | 19 | Timer::after_millis(500).await; |
| 20 | 20 | ||
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after_millis(500).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/nrf-rtos-trace/src/bin/rtos_trace.rs b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs index cf8b2f808..888375693 100644 --- a/examples/nrf-rtos-trace/src/bin/rtos_trace.rs +++ b/examples/nrf-rtos-trace/src/bin/rtos_trace.rs | |||
| @@ -6,7 +6,7 @@ use core::future::poll_fn; | |||
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_time::{Duration, Instant, Timer}; | 9 | use embassy_time::{Instant, Timer}; |
| 10 | #[cfg(feature = "log")] | 10 | #[cfg(feature = "log")] |
| 11 | use log::*; | 11 | use log::*; |
| 12 | use panic_probe as _; | 12 | use panic_probe as _; |
| @@ -34,7 +34,7 @@ async fn run1() { | |||
| 34 | info!("DING DONG"); | 34 | info!("DING DONG"); |
| 35 | #[cfg(not(feature = "log"))] | 35 | #[cfg(not(feature = "log"))] |
| 36 | rtos_trace::trace::marker(13); | 36 | rtos_trace::trace::marker(13); |
| 37 | Timer::after(Duration::from_ticks(16000)).await; | 37 | Timer::after_ticks(16000).await; |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
diff --git a/examples/nrf52840-rtic/src/bin/blinky.rs b/examples/nrf52840-rtic/src/bin/blinky.rs index a682c1932..060bb9ebc 100644 --- a/examples/nrf52840-rtic/src/bin/blinky.rs +++ b/examples/nrf52840-rtic/src/bin/blinky.rs | |||
| @@ -9,7 +9,7 @@ mod app { | |||
| 9 | use defmt::info; | 9 | use defmt::info; |
| 10 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 10 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 11 | use embassy_nrf::peripherals; | 11 | use embassy_nrf::peripherals; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | 13 | ||
| 14 | #[shared] | 14 | #[shared] |
| 15 | struct Shared {} | 15 | struct Shared {} |
| @@ -34,10 +34,10 @@ mod app { | |||
| 34 | loop { | 34 | loop { |
| 35 | info!("off!"); | 35 | info!("off!"); |
| 36 | led.set_high(); | 36 | led.set_high(); |
| 37 | Timer::after(Duration::from_millis(300)).await; | 37 | Timer::after_millis(300).await; |
| 38 | info!("on!"); | 38 | info!("on!"); |
| 39 | led.set_low(); | 39 | led.set_low(); |
| 40 | Timer::after(Duration::from_millis(300)).await; | 40 | Timer::after_millis(300).await; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
diff --git a/examples/nrf52840/src/bin/blinky.rs b/examples/nrf52840/src/bin/blinky.rs index 513f6cd82..d3d1a7122 100644 --- a/examples/nrf52840/src/bin/blinky.rs +++ b/examples/nrf52840/src/bin/blinky.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -14,8 +14,8 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | loop { | 15 | loop { |
| 16 | led.set_high(); | 16 | led.set_high(); |
| 17 | Timer::after(Duration::from_millis(300)).await; | 17 | Timer::after_millis(300).await; |
| 18 | led.set_low(); | 18 | led.set_low(); |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after_millis(300).await; |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
diff --git a/examples/nrf52840/src/bin/channel.rs b/examples/nrf52840/src/bin/channel.rs index bd9c909da..d3c7b47d2 100644 --- a/examples/nrf52840/src/bin/channel.rs +++ b/examples/nrf52840/src/bin/channel.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 9 | use embassy_sync::channel::Channel; | 9 | use embassy_sync::channel::Channel; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | enum LedState { | 13 | enum LedState { |
| @@ -21,9 +21,9 @@ static CHANNEL: Channel<ThreadModeRawMutex, LedState, 1> = Channel::new(); | |||
| 21 | async fn my_task() { | 21 | async fn my_task() { |
| 22 | loop { | 22 | loop { |
| 23 | CHANNEL.send(LedState::On).await; | 23 | CHANNEL.send(LedState::On).await; |
| 24 | Timer::after(Duration::from_secs(1)).await; | 24 | Timer::after_secs(1).await; |
| 25 | CHANNEL.send(LedState::Off).await; | 25 | CHANNEL.send(LedState::Off).await; |
| 26 | Timer::after(Duration::from_secs(1)).await; | 26 | Timer::after_secs(1).await; |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
diff --git a/examples/nrf52840/src/bin/channel_sender_receiver.rs b/examples/nrf52840/src/bin/channel_sender_receiver.rs index ec4f1d800..79d2c4048 100644 --- a/examples/nrf52840/src/bin/channel_sender_receiver.rs +++ b/examples/nrf52840/src/bin/channel_sender_receiver.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; | 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; |
| 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; | 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| @@ -22,9 +22,9 @@ static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new | |||
| 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { | 22 | async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { |
| 23 | loop { | 23 | loop { |
| 24 | sender.send(LedState::On).await; | 24 | sender.send(LedState::On).await; |
| 25 | Timer::after(Duration::from_secs(1)).await; | 25 | Timer::after_secs(1).await; |
| 26 | sender.send(LedState::Off).await; | 26 | sender.send(LedState::Off).await; |
| 27 | Timer::after(Duration::from_secs(1)).await; | 27 | Timer::after_secs(1).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
diff --git a/examples/nrf52840/src/bin/executor_fairness_test.rs b/examples/nrf52840/src/bin/executor_fairness_test.rs index 2a28f2763..f111b272e 100644 --- a/examples/nrf52840/src/bin/executor_fairness_test.rs +++ b/examples/nrf52840/src/bin/executor_fairness_test.rs | |||
| @@ -7,14 +7,14 @@ use core::task::Poll; | |||
| 7 | 7 | ||
| 8 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_time::{Duration, Instant, Timer}; | 10 | use embassy_time::{Instant, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::task] | 13 | #[embassy_executor::task] |
| 14 | async fn run1() { | 14 | async fn run1() { |
| 15 | loop { | 15 | loop { |
| 16 | info!("DING DONG"); | 16 | info!("DING DONG"); |
| 17 | Timer::after(Duration::from_ticks(16000)).await; | 17 | Timer::after_ticks(16000).await; |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
diff --git a/examples/nrf52840/src/bin/lora_cad.rs b/examples/nrf52840/src/bin/lora_cad.rs index 3a98133c9..38e6d6197 100644 --- a/examples/nrf52840/src/bin/lora_cad.rs +++ b/examples/nrf52840/src/bin/lora_cad.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mdltn_params = { | 61 | let mdltn_params = { |
| @@ -89,7 +89,7 @@ async fn main(_spawner: Spawner) { | |||
| 89 | info!("cad successful without activity detected") | 89 | info!("cad successful without activity detected") |
| 90 | } | 90 | } |
| 91 | debug_indicator.set_high(); | 91 | debug_indicator.set_high(); |
| 92 | Timer::after(Duration::from_secs(5)).await; | 92 | Timer::after_secs(5).await; |
| 93 | debug_indicator.set_low(); | 93 | debug_indicator.set_low(); |
| 94 | } | 94 | } |
| 95 | Err(err) => info!("cad unsuccessful = {}", err), | 95 | Err(err) => info!("cad unsuccessful = {}", err), |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive.rs b/examples/nrf52840/src/bin/lora_p2p_receive.rs index 1d293c6bf..4f41e1245 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mut receiving_buffer = [00u8; 100]; | 61 | let mut receiving_buffer = [00u8; 100]; |
| @@ -107,7 +107,7 @@ async fn main(_spawner: Spawner) { | |||
| 107 | { | 107 | { |
| 108 | info!("rx successful"); | 108 | info!("rx successful"); |
| 109 | debug_indicator.set_high(); | 109 | debug_indicator.set_high(); |
| 110 | Timer::after(Duration::from_secs(5)).await; | 110 | Timer::after_secs(5).await; |
| 111 | debug_indicator.set_low(); | 111 | debug_indicator.set_low(); |
| 112 | } else { | 112 | } else { |
| 113 | info!("rx unknown packet"); | 113 | info!("rx unknown packet"); |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs index eee4d20e7..3d34f6aef 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; |
| 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; | 13 | use embassy_nrf::{bind_interrupts, peripherals, spim}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | 55 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mut receiving_buffer = [00u8; 100]; | 61 | let mut receiving_buffer = [00u8; 100]; |
| @@ -116,7 +116,7 @@ async fn main(_spawner: Spawner) { | |||
| 116 | { | 116 | { |
| 117 | info!("rx successful"); | 117 | info!("rx successful"); |
| 118 | debug_indicator.set_high(); | 118 | debug_indicator.set_high(); |
| 119 | Timer::after(Duration::from_secs(5)).await; | 119 | Timer::after_secs(5).await; |
| 120 | debug_indicator.set_low(); | 120 | debug_indicator.set_low(); |
| 121 | } else { | 121 | } else { |
| 122 | info!("rx unknown packet") | 122 | info!("rx unknown packet") |
diff --git a/examples/nrf52840/src/bin/manually_create_executor.rs b/examples/nrf52840/src/bin/manually_create_executor.rs index 12ce660f9..80364d34a 100644 --- a/examples/nrf52840/src/bin/manually_create_executor.rs +++ b/examples/nrf52840/src/bin/manually_create_executor.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use defmt::{info, unwrap}; | 9 | use defmt::{info, unwrap}; |
| 10 | use embassy_executor::Executor; | 10 | use embassy_executor::Executor; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use static_cell::StaticCell; | 12 | use static_cell::StaticCell; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| @@ -16,7 +16,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 16 | async fn run1() { | 16 | async fn run1() { |
| 17 | loop { | 17 | loop { |
| 18 | info!("BIG INFREQUENT TICK"); | 18 | info!("BIG INFREQUENT TICK"); |
| 19 | Timer::after(Duration::from_ticks(64000)).await; | 19 | Timer::after_ticks(64000).await; |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | 22 | ||
| @@ -24,7 +24,7 @@ async fn run1() { | |||
| 24 | async fn run2() { | 24 | async fn run2() { |
| 25 | loop { | 25 | loop { |
| 26 | info!("tick"); | 26 | info!("tick"); |
| 27 | Timer::after(Duration::from_ticks(13000)).await; | 27 | Timer::after_ticks(13000).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
diff --git a/examples/nrf52840/src/bin/multiprio.rs b/examples/nrf52840/src/bin/multiprio.rs index aab819117..352f62bf2 100644 --- a/examples/nrf52840/src/bin/multiprio.rs +++ b/examples/nrf52840/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::{info, unwrap}; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_nrf::interrupt; | 63 | use embassy_nrf::interrupt; |
| 64 | use embassy_nrf::interrupt::{InterruptExt, Priority}; | 64 | use embassy_nrf::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Instant, Timer}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | info!(" [high] tick!"); | 72 | info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(27374)).await; | 73 | Timer::after_ticks(27374).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() / 33; | 87 | let ms = end.duration_since(start).as_ticks() / 33; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(23421)).await; | 90 | Timer::after_ticks(23421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() / 33; | 104 | let ms = end.duration_since(start).as_ticks() / 33; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(32983)).await; | 107 | Timer::after_ticks(32983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/nrf52840/src/bin/mutex.rs b/examples/nrf52840/src/bin/mutex.rs index c402c6ba1..11b47d991 100644 --- a/examples/nrf52840/src/bin/mutex.rs +++ b/examples/nrf52840/src/bin/mutex.rs | |||
| @@ -6,7 +6,7 @@ use defmt::{info, unwrap}; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 8 | use embassy_sync::mutex::Mutex; | 8 | use embassy_sync::mutex::Mutex; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); | 12 | static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); |
| @@ -20,11 +20,11 @@ async fn my_task() { | |||
| 20 | *m += 1000; | 20 | *m += 1000; |
| 21 | 21 | ||
| 22 | // Hold the mutex for a long time. | 22 | // Hold the mutex for a long time. |
| 23 | Timer::after(Duration::from_secs(1)).await; | 23 | Timer::after_secs(1).await; |
| 24 | info!("end long operation: count = {}", *m); | 24 | info!("end long operation: count = {}", *m); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | Timer::after(Duration::from_secs(1)).await; | 27 | Timer::after_secs(1).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| @@ -34,7 +34,7 @@ async fn main(spawner: Spawner) { | |||
| 34 | unwrap!(spawner.spawn(my_task())); | 34 | unwrap!(spawner.spawn(my_task())); |
| 35 | 35 | ||
| 36 | loop { | 36 | loop { |
| 37 | Timer::after(Duration::from_millis(300)).await; | 37 | Timer::after_millis(300).await; |
| 38 | let mut m = MUTEX.lock().await; | 38 | let mut m = MUTEX.lock().await; |
| 39 | *m += 1; | 39 | *m += 1; |
| 40 | info!("short operation: count = {}", *m); | 40 | info!("short operation: count = {}", *m); |
diff --git a/examples/nrf52840/src/bin/nvmc.rs b/examples/nrf52840/src/bin/nvmc.rs index 31c6fe4b6..624829863 100644 --- a/examples/nrf52840/src/bin/nvmc.rs +++ b/examples/nrf52840/src/bin/nvmc.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::nvmc::Nvmc; | 7 | use embassy_nrf::nvmc::Nvmc; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 9 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | info!("Hello NVMC!"); | 15 | info!("Hello NVMC!"); |
| 16 | 16 | ||
| 17 | // probe-rs run breaks without this, I'm not sure why. | 17 | // probe-rs run breaks without this, I'm not sure why. |
| 18 | Timer::after(Duration::from_secs(1)).await; | 18 | Timer::after_secs(1).await; |
| 19 | 19 | ||
| 20 | let mut f = Nvmc::new(p.NVMC); | 20 | let mut f = Nvmc::new(p.NVMC); |
| 21 | const ADDR: u32 = 0x80000; | 21 | const ADDR: u32 = 0x80000; |
diff --git a/examples/nrf52840/src/bin/pdm.rs b/examples/nrf52840/src/bin/pdm.rs index 444b9137f..bff323974 100644 --- a/examples/nrf52840/src/bin/pdm.rs +++ b/examples/nrf52840/src/bin/pdm.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pdm::{self, Config, Pdm}; | 7 | use embassy_nrf::pdm::{self, Config, Pdm}; |
| 8 | use embassy_nrf::{bind_interrupts, peripherals}; | 8 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use fixed::types::I7F1; | 10 | use fixed::types::I7F1; |
| 11 | use num_integer::Roots; | 11 | use num_integer::Roots; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -28,7 +28,7 @@ async fn main(_p: Spawner) { | |||
| 28 | pdm.start().await; | 28 | pdm.start().await; |
| 29 | 29 | ||
| 30 | // wait some time till the microphon settled | 30 | // wait some time till the microphon settled |
| 31 | Timer::after(Duration::from_millis(1000)).await; | 31 | Timer::after_millis(1000).await; |
| 32 | 32 | ||
| 33 | const SAMPLES: usize = 2048; | 33 | const SAMPLES: usize = 2048; |
| 34 | let mut buf = [0i16; SAMPLES]; | 34 | let mut buf = [0i16; SAMPLES]; |
| @@ -51,7 +51,7 @@ async fn main(_p: Spawner) { | |||
| 51 | info!("samples: {:?}", &buf); | 51 | info!("samples: {:?}", &buf); |
| 52 | 52 | ||
| 53 | pdm.stop().await; | 53 | pdm.stop().await; |
| 54 | Timer::after(Duration::from_millis(100)).await; | 54 | Timer::after_millis(100).await; |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
diff --git a/examples/nrf52840/src/bin/pubsub.rs b/examples/nrf52840/src/bin/pubsub.rs index cca60ebc9..17d902227 100644 --- a/examples/nrf52840/src/bin/pubsub.rs +++ b/examples/nrf52840/src/bin/pubsub.rs | |||
| @@ -6,7 +6,7 @@ use defmt::unwrap; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 8 | use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; | 8 | use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher | 12 | /// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher |
| @@ -39,7 +39,7 @@ async fn main(spawner: Spawner) { | |||
| 39 | 39 | ||
| 40 | let mut index = 0; | 40 | let mut index = 0; |
| 41 | loop { | 41 | loop { |
| 42 | Timer::after(Duration::from_millis(500)).await; | 42 | Timer::after_millis(500).await; |
| 43 | 43 | ||
| 44 | let message = match index % 3 { | 44 | let message = match index % 3 { |
| 45 | 0 => Message::A, | 45 | 0 => Message::A, |
| @@ -81,7 +81,7 @@ async fn fast_logger(mut messages: Subscriber<'static, ThreadModeRawMutex, Messa | |||
| 81 | async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { | 81 | async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { |
| 82 | loop { | 82 | loop { |
| 83 | // Do some work | 83 | // Do some work |
| 84 | Timer::after(Duration::from_millis(2000)).await; | 84 | Timer::after_millis(2000).await; |
| 85 | 85 | ||
| 86 | // If the publisher has used the `publish_immediate` function, then we may receive a lag message here | 86 | // If the publisher has used the `publish_immediate` function, then we may receive a lag message here |
| 87 | let message = messages.next_message().await; | 87 | let message = messages.next_message().await; |
| @@ -98,7 +98,7 @@ async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { | |||
| 98 | async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { | 98 | async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { |
| 99 | loop { | 99 | loop { |
| 100 | // Do some work | 100 | // Do some work |
| 101 | Timer::after(Duration::from_millis(2000)).await; | 101 | Timer::after_millis(2000).await; |
| 102 | 102 | ||
| 103 | // Instead of receiving lags here, we just ignore that and read the next message | 103 | // Instead of receiving lags here, we just ignore that and read the next message |
| 104 | let message = messages.next_message_pure().await; | 104 | let message = messages.next_message_pure().await; |
diff --git a/examples/nrf52840/src/bin/pwm.rs b/examples/nrf52840/src/bin/pwm.rs index 1698c0bc8..9750935c8 100644 --- a/examples/nrf52840/src/bin/pwm.rs +++ b/examples/nrf52840/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') | 11 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') |
| @@ -84,6 +84,6 @@ async fn main(_spawner: Spawner) { | |||
| 84 | pwm.set_duty(1, DUTY[(i + 256) % 1024]); | 84 | pwm.set_duty(1, DUTY[(i + 256) % 1024]); |
| 85 | pwm.set_duty(2, DUTY[(i + 512) % 1024]); | 85 | pwm.set_duty(2, DUTY[(i + 512) % 1024]); |
| 86 | pwm.set_duty(3, DUTY[(i + 768) % 1024]); | 86 | pwm.set_duty(3, DUTY[(i + 768) % 1024]); |
| 87 | Timer::after(Duration::from_millis(3)).await; | 87 | Timer::after_millis(3).await; |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
diff --git a/examples/nrf52840/src/bin/pwm_double_sequence.rs b/examples/nrf52840/src/bin/pwm_double_sequence.rs index 16e50e909..1bfe6e15a 100644 --- a/examples/nrf52840/src/bin/pwm_double_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_double_sequence.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 8 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, | 8 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, |
| 9 | }; | 9 | }; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | // we can abort a sequence if we need to before its complete with pwm.stop() | 36 | // we can abort a sequence if we need to before its complete with pwm.stop() |
| 37 | // or stop is also implicitly called when the pwm peripheral is dropped | 37 | // or stop is also implicitly called when the pwm peripheral is dropped |
| 38 | // when it goes out of scope | 38 | // when it goes out of scope |
| 39 | Timer::after(Duration::from_millis(40000)).await; | 39 | Timer::after_millis(40000).await; |
| 40 | info!("pwm stopped early!"); | 40 | info!("pwm stopped early!"); |
| 41 | } | 41 | } |
diff --git a/examples/nrf52840/src/bin/pwm_sequence.rs b/examples/nrf52840/src/bin/pwm_sequence.rs index b9aca9aaa..f282cf910 100644 --- a/examples/nrf52840/src/bin/pwm_sequence.rs +++ b/examples/nrf52840/src/bin/pwm_sequence.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; | 7 | use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -31,6 +31,6 @@ async fn main(_spawner: Spawner) { | |||
| 31 | // we can abort a sequence if we need to before its complete with pwm.stop() | 31 | // we can abort a sequence if we need to before its complete with pwm.stop() |
| 32 | // or stop is also implicitly called when the pwm peripheral is dropped | 32 | // or stop is also implicitly called when the pwm peripheral is dropped |
| 33 | // when it goes out of scope | 33 | // when it goes out of scope |
| 34 | Timer::after(Duration::from_millis(20000)).await; | 34 | Timer::after_millis(20000).await; |
| 35 | info!("pwm stopped early!"); | 35 | info!("pwm stopped early!"); |
| 36 | } | 36 | } |
diff --git a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs index 711c8a17b..8596e6545 100644 --- a/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::pwm::{ | 7 | use embassy_nrf::pwm::{ |
| 8 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, | 8 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, |
| 9 | }; | 9 | }; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | // WS2812B LED light demonstration. Drives just one light. | 13 | // WS2812B LED light demonstration. Drives just one light. |
| @@ -52,7 +52,7 @@ async fn main(_spawner: Spawner) { | |||
| 52 | let sequences = SingleSequencer::new(&mut pwm, &seq_words, seq_config.clone()); | 52 | let sequences = SingleSequencer::new(&mut pwm, &seq_words, seq_config.clone()); |
| 53 | unwrap!(sequences.start(SingleSequenceMode::Times(1))); | 53 | unwrap!(sequences.start(SingleSequenceMode::Times(1))); |
| 54 | 54 | ||
| 55 | Timer::after(Duration::from_millis(50)).await; | 55 | Timer::after_millis(50).await; |
| 56 | 56 | ||
| 57 | if bit_value == T0H { | 57 | if bit_value == T0H { |
| 58 | if color_bit == 20 { | 58 | if color_bit == 20 { |
diff --git a/examples/nrf52840/src/bin/pwm_servo.rs b/examples/nrf52840/src/bin/pwm_servo.rs index 19228f433..92ded1f88 100644 --- a/examples/nrf52840/src/bin/pwm_servo.rs +++ b/examples/nrf52840/src/bin/pwm_servo.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -19,29 +19,29 @@ async fn main(_spawner: Spawner) { | |||
| 19 | pwm.set_max_duty(2500); | 19 | pwm.set_max_duty(2500); |
| 20 | info!("pwm initialized!"); | 20 | info!("pwm initialized!"); |
| 21 | 21 | ||
| 22 | Timer::after(Duration::from_millis(5000)).await; | 22 | Timer::after_millis(5000).await; |
| 23 | 23 | ||
| 24 | // 1ms 0deg (1/.008=125), 1.5ms 90deg (1.5/.008=187.5), 2ms 180deg (2/.008=250), | 24 | // 1ms 0deg (1/.008=125), 1.5ms 90deg (1.5/.008=187.5), 2ms 180deg (2/.008=250), |
| 25 | loop { | 25 | loop { |
| 26 | info!("45 deg"); | 26 | info!("45 deg"); |
| 27 | // poor mans inverting, subtract our value from max_duty | 27 | // poor mans inverting, subtract our value from max_duty |
| 28 | pwm.set_duty(0, 2500 - 156); | 28 | pwm.set_duty(0, 2500 - 156); |
| 29 | Timer::after(Duration::from_millis(5000)).await; | 29 | Timer::after_millis(5000).await; |
| 30 | 30 | ||
| 31 | info!("90 deg"); | 31 | info!("90 deg"); |
| 32 | pwm.set_duty(0, 2500 - 187); | 32 | pwm.set_duty(0, 2500 - 187); |
| 33 | Timer::after(Duration::from_millis(5000)).await; | 33 | Timer::after_millis(5000).await; |
| 34 | 34 | ||
| 35 | info!("135 deg"); | 35 | info!("135 deg"); |
| 36 | pwm.set_duty(0, 2500 - 218); | 36 | pwm.set_duty(0, 2500 - 218); |
| 37 | Timer::after(Duration::from_millis(5000)).await; | 37 | Timer::after_millis(5000).await; |
| 38 | 38 | ||
| 39 | info!("180 deg"); | 39 | info!("180 deg"); |
| 40 | pwm.set_duty(0, 2500 - 250); | 40 | pwm.set_duty(0, 2500 - 250); |
| 41 | Timer::after(Duration::from_millis(5000)).await; | 41 | Timer::after_millis(5000).await; |
| 42 | 42 | ||
| 43 | info!("0 deg"); | 43 | info!("0 deg"); |
| 44 | pwm.set_duty(0, 2500 - 125); | 44 | pwm.set_duty(0, 2500 - 125); |
| 45 | Timer::after(Duration::from_millis(5000)).await; | 45 | Timer::after_millis(5000).await; |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
diff --git a/examples/nrf52840/src/bin/qspi_lowpower.rs b/examples/nrf52840/src/bin/qspi_lowpower.rs index 22a5c0c6d..42b5454e0 100644 --- a/examples/nrf52840/src/bin/qspi_lowpower.rs +++ b/examples/nrf52840/src/bin/qspi_lowpower.rs | |||
| @@ -8,7 +8,7 @@ use defmt::{info, unwrap}; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_nrf::qspi::Frequency; | 9 | use embassy_nrf::qspi::Frequency; |
| 10 | use embassy_nrf::{bind_interrupts, peripherals, qspi}; | 10 | use embassy_nrf::{bind_interrupts, peripherals, qspi}; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | // Workaround for alignment requirements. | 14 | // Workaround for alignment requirements. |
| @@ -79,6 +79,6 @@ async fn main(_p: Spawner) { | |||
| 79 | 79 | ||
| 80 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. | 80 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. |
| 81 | // During this sleep, the nRF chip should only use ~3uA | 81 | // During this sleep, the nRF chip should only use ~3uA |
| 82 | Timer::after(Duration::from_secs(1)).await; | 82 | Timer::after_secs(1).await; |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
diff --git a/examples/nrf52840/src/bin/raw_spawn.rs b/examples/nrf52840/src/bin/raw_spawn.rs index 1b067f5e4..717b0faa6 100644 --- a/examples/nrf52840/src/bin/raw_spawn.rs +++ b/examples/nrf52840/src/bin/raw_spawn.rs | |||
| @@ -7,21 +7,21 @@ use cortex_m_rt::entry; | |||
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | async fn run1() { | 14 | async fn run1() { |
| 15 | loop { | 15 | loop { |
| 16 | info!("BIG INFREQUENT TICK"); | 16 | info!("BIG INFREQUENT TICK"); |
| 17 | Timer::after(Duration::from_ticks(64000)).await; | 17 | Timer::after_ticks(64000).await; |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | async fn run2() { | 21 | async fn run2() { |
| 22 | loop { | 22 | loop { |
| 23 | info!("tick"); | 23 | info!("tick"); |
| 24 | Timer::after(Duration::from_ticks(13000)).await; | 24 | Timer::after_ticks(13000).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
diff --git a/examples/nrf52840/src/bin/saadc.rs b/examples/nrf52840/src/bin/saadc.rs index ffd9a7f4b..d651834f5 100644 --- a/examples/nrf52840/src/bin/saadc.rs +++ b/examples/nrf52840/src/bin/saadc.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; | 7 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; |
| 8 | use embassy_nrf::{bind_interrupts, saadc}; | 8 | use embassy_nrf::{bind_interrupts, saadc}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | bind_interrupts!(struct Irqs { | 12 | bind_interrupts!(struct Irqs { |
| @@ -24,6 +24,6 @@ async fn main(_p: Spawner) { | |||
| 24 | let mut buf = [0; 1]; | 24 | let mut buf = [0; 1]; |
| 25 | saadc.sample(&mut buf).await; | 25 | saadc.sample(&mut buf).await; |
| 26 | info!("sample: {=i16}", &buf[0]); | 26 | info!("sample: {=i16}", &buf[0]); |
| 27 | Timer::after(Duration::from_millis(100)).await; | 27 | Timer::after_millis(100).await; |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
diff --git a/examples/nrf52840/src/bin/saadc_continuous.rs b/examples/nrf52840/src/bin/saadc_continuous.rs index a25e17465..a5f8a4dd7 100644 --- a/examples/nrf52840/src/bin/saadc_continuous.rs +++ b/examples/nrf52840/src/bin/saadc_continuous.rs | |||
| @@ -7,7 +7,6 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; | 7 | use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; |
| 8 | use embassy_nrf::timer::Frequency; | 8 | use embassy_nrf::timer::Frequency; |
| 9 | use embassy_nrf::{bind_interrupts, saadc}; | 9 | use embassy_nrf::{bind_interrupts, saadc}; |
| 10 | use embassy_time::Duration; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer | 12 | // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer |
| @@ -32,7 +31,7 @@ async fn main(_p: Spawner) { | |||
| 32 | 31 | ||
| 33 | // This delay demonstrates that starting the timer prior to running | 32 | // This delay demonstrates that starting the timer prior to running |
| 34 | // the task sampler is benign given the calibration that follows. | 33 | // the task sampler is benign given the calibration that follows. |
| 35 | embassy_time::Timer::after(Duration::from_millis(500)).await; | 34 | embassy_time::Timer::after_millis(500).await; |
| 36 | saadc.calibrate().await; | 35 | saadc.calibrate().await; |
| 37 | 36 | ||
| 38 | let mut bufs = [[[0; 3]; 500]; 2]; | 37 | let mut bufs = [[[0; 3]; 500]; 2]; |
diff --git a/examples/nrf52840/src/bin/self_spawn.rs b/examples/nrf52840/src/bin/self_spawn.rs index 31ea6c81e..8a58396a4 100644 --- a/examples/nrf52840/src/bin/self_spawn.rs +++ b/examples/nrf52840/src/bin/self_spawn.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | mod config { | 10 | mod config { |
| @@ -13,7 +13,7 @@ mod config { | |||
| 13 | 13 | ||
| 14 | #[embassy_executor::task(pool_size = config::MY_TASK_POOL_SIZE)] | 14 | #[embassy_executor::task(pool_size = config::MY_TASK_POOL_SIZE)] |
| 15 | async fn my_task(spawner: Spawner, n: u32) { | 15 | async fn my_task(spawner: Spawner, n: u32) { |
| 16 | Timer::after(Duration::from_secs(1)).await; | 16 | Timer::after_secs(1).await; |
| 17 | info!("Spawning self! {}", n); | 17 | info!("Spawning self! {}", n); |
| 18 | unwrap!(spawner.spawn(my_task(spawner, n + 1))); | 18 | unwrap!(spawner.spawn(my_task(spawner, n + 1))); |
| 19 | } | 19 | } |
diff --git a/examples/nrf52840/src/bin/self_spawn_current_executor.rs b/examples/nrf52840/src/bin/self_spawn_current_executor.rs index 8a179886c..65d50f8c3 100644 --- a/examples/nrf52840/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf52840/src/bin/self_spawn_current_executor.rs | |||
| @@ -4,12 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::task(pool_size = 2)] | 10 | #[embassy_executor::task(pool_size = 2)] |
| 11 | async fn my_task(n: u32) { | 11 | async fn my_task(n: u32) { |
| 12 | Timer::after(Duration::from_secs(1)).await; | 12 | Timer::after_secs(1).await; |
| 13 | info!("Spawning self! {}", n); | 13 | info!("Spawning self! {}", n); |
| 14 | unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); | 14 | unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); |
| 15 | } | 15 | } |
diff --git a/examples/nrf52840/src/bin/temp.rs b/examples/nrf52840/src/bin/temp.rs index 70957548f..d94dea38d 100644 --- a/examples/nrf52840/src/bin/temp.rs +++ b/examples/nrf52840/src/bin/temp.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::temp::Temp; | 7 | use embassy_nrf::temp::Temp; |
| 8 | use embassy_nrf::{bind_interrupts, temp}; | 8 | use embassy_nrf::{bind_interrupts, temp}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | bind_interrupts!(struct Irqs { | 12 | bind_interrupts!(struct Irqs { |
| @@ -21,6 +21,6 @@ async fn main(_spawner: Spawner) { | |||
| 21 | loop { | 21 | loop { |
| 22 | let value = temp.read().await; | 22 | let value = temp.read().await; |
| 23 | info!("temperature: {}℃", value.to_num::<u16>()); | 23 | info!("temperature: {}℃", value.to_num::<u16>()); |
| 24 | Timer::after(Duration::from_secs(1)).await; | 24 | Timer::after_secs(1).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
diff --git a/examples/nrf52840/src/bin/timer.rs b/examples/nrf52840/src/bin/timer.rs index c22b5acd5..9b9bb3eb4 100644 --- a/examples/nrf52840/src/bin/timer.rs +++ b/examples/nrf52840/src/bin/timer.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::task] | 10 | #[embassy_executor::task] |
| 11 | async fn run1() { | 11 | async fn run1() { |
| 12 | loop { | 12 | loop { |
| 13 | info!("BIG INFREQUENT TICK"); | 13 | info!("BIG INFREQUENT TICK"); |
| 14 | Timer::after(Duration::from_ticks(64000)).await; | 14 | Timer::after_ticks(64000).await; |
| 15 | } | 15 | } |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -19,7 +19,7 @@ async fn run1() { | |||
| 19 | async fn run2() { | 19 | async fn run2() { |
| 20 | loop { | 20 | loop { |
| 21 | info!("tick"); | 21 | info!("tick"); |
| 22 | Timer::after(Duration::from_ticks(13000)).await; | 22 | Timer::after_ticks(13000).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 | ||
diff --git a/examples/nrf52840/src/bin/twim_lowpower.rs b/examples/nrf52840/src/bin/twim_lowpower.rs index 0970d3c3c..bf9f966ef 100644 --- a/examples/nrf52840/src/bin/twim_lowpower.rs +++ b/examples/nrf52840/src/bin/twim_lowpower.rs | |||
| @@ -14,7 +14,7 @@ use defmt::*; | |||
| 14 | use embassy_executor::Spawner; | 14 | use embassy_executor::Spawner; |
| 15 | use embassy_nrf::twim::{self, Twim}; | 15 | use embassy_nrf::twim::{self, Twim}; |
| 16 | use embassy_nrf::{bind_interrupts, peripherals}; | 16 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 17 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::Timer; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | const ADDRESS: u8 = 0x50; | 20 | const ADDRESS: u8 = 0x50; |
| @@ -48,6 +48,6 @@ async fn main(_p: Spawner) { | |||
| 48 | 48 | ||
| 49 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. | 49 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. |
| 50 | // During this sleep, the nRF chip should only use ~3uA | 50 | // During this sleep, the nRF chip should only use ~3uA |
| 51 | Timer::after(Duration::from_secs(1)).await; | 51 | Timer::after_secs(1).await; |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
diff --git a/examples/nrf52840/src/bin/usb_hid_mouse.rs b/examples/nrf52840/src/bin/usb_hid_mouse.rs index edf634a5e..96fcf8a66 100644 --- a/examples/nrf52840/src/bin/usb_hid_mouse.rs +++ b/examples/nrf52840/src/bin/usb_hid_mouse.rs | |||
| @@ -10,7 +10,7 @@ use embassy_futures::join::join; | |||
| 10 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | 10 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; |
| 11 | use embassy_nrf::usb::Driver; | 11 | use embassy_nrf::usb::Driver; |
| 12 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 12 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 14 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 15 | use embassy_usb::control::OutResponse; | 15 | use embassy_usb::control::OutResponse; |
| 16 | use embassy_usb::{Builder, Config}; | 16 | use embassy_usb::{Builder, Config}; |
| @@ -83,7 +83,7 @@ async fn main(_spawner: Spawner) { | |||
| 83 | let hid_fut = async { | 83 | let hid_fut = async { |
| 84 | let mut y: i8 = 5; | 84 | let mut y: i8 = 5; |
| 85 | loop { | 85 | loop { |
| 86 | Timer::after(Duration::from_millis(500)).await; | 86 | Timer::after_millis(500).await; |
| 87 | 87 | ||
| 88 | y = -y; | 88 | y = -y; |
| 89 | let report = MouseReport { | 89 | let report = MouseReport { |
diff --git a/examples/nrf5340/src/bin/blinky.rs b/examples/nrf5340/src/bin/blinky.rs index 3422cedf0..b784564a5 100644 --- a/examples/nrf5340/src/bin/blinky.rs +++ b/examples/nrf5340/src/bin/blinky.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -14,8 +14,8 @@ async fn main(_spawner: Spawner) { | |||
| 14 | 14 | ||
| 15 | loop { | 15 | loop { |
| 16 | led.set_high(); | 16 | led.set_high(); |
| 17 | Timer::after(Duration::from_millis(300)).await; | 17 | Timer::after_millis(300).await; |
| 18 | led.set_low(); | 18 | led.set_low(); |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after_millis(300).await; |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
diff --git a/examples/rp/src/bin/adc.rs b/examples/rp/src/bin/adc.rs index 02bc493b6..a579be139 100644 --- a/examples/rp/src/bin/adc.rs +++ b/examples/rp/src/bin/adc.rs | |||
| @@ -10,7 +10,7 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler}; | 10 | use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler}; |
| 11 | use embassy_rp::bind_interrupts; | 11 | use embassy_rp::bind_interrupts; |
| 12 | use embassy_rp::gpio::Pull; | 12 | use embassy_rp::gpio::Pull; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
| @@ -36,7 +36,7 @@ async fn main(_spawner: Spawner) { | |||
| 36 | info!("Pin 28 ADC: {}", level); | 36 | info!("Pin 28 ADC: {}", level); |
| 37 | let temp = adc.read(&mut ts).await.unwrap(); | 37 | let temp = adc.read(&mut ts).await.unwrap(); |
| 38 | info!("Temp: {} degrees", convert_to_celsius(temp)); | 38 | info!("Temp: {} degrees", convert_to_celsius(temp)); |
| 39 | Timer::after(Duration::from_secs(1)).await; | 39 | Timer::after_secs(1).await; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 | ||
diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index 295b000f3..66c8773fa 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::gpio; | 11 | use embassy_rp::gpio; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use gpio::{Level, Output}; | 13 | use gpio::{Level, Output}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| @@ -21,10 +21,10 @@ async fn main(_spawner: Spawner) { | |||
| 21 | loop { | 21 | loop { |
| 22 | info!("led on!"); | 22 | info!("led on!"); |
| 23 | led.set_high(); | 23 | led.set_high(); |
| 24 | Timer::after(Duration::from_secs(1)).await; | 24 | Timer::after_secs(1).await; |
| 25 | 25 | ||
| 26 | info!("led off!"); | 26 | info!("led off!"); |
| 27 | led.set_low(); | 27 | led.set_low(); |
| 28 | Timer::after(Duration::from_secs(1)).await; | 28 | Timer::after_secs(1).await; |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index e593acae4..b19362fc1 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs | |||
| @@ -111,7 +111,7 @@ async fn main(spawner: Spawner) { | |||
| 111 | break; | 111 | break; |
| 112 | } | 112 | } |
| 113 | info!("txd: {}", core::str::from_utf8(msg).unwrap()); | 113 | info!("txd: {}", core::str::from_utf8(msg).unwrap()); |
| 114 | Timer::after(Duration::from_secs(1)).await; | 114 | Timer::after_secs(1).await; |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
diff --git a/examples/rp/src/bin/flash.rs b/examples/rp/src/bin/flash.rs index 911a657eb..129a8497f 100644 --- a/examples/rp/src/bin/flash.rs +++ b/examples/rp/src/bin/flash.rs | |||
| @@ -8,7 +8,7 @@ use defmt::*; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; | 9 | use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; |
| 10 | use embassy_rp::peripherals::FLASH; | 10 | use embassy_rp::peripherals::FLASH; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | const ADDR_OFFSET: u32 = 0x100000; | 14 | const ADDR_OFFSET: u32 = 0x100000; |
| @@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | // defmt RTT header. Reading that header might touch flash memory, which | 23 | // defmt RTT header. Reading that header might touch flash memory, which |
| 24 | // interferes with flash write operations. | 24 | // interferes with flash write operations. |
| 25 | // https://github.com/knurling-rs/defmt/pull/683 | 25 | // https://github.com/knurling-rs/defmt/pull/683 |
| 26 | Timer::after(Duration::from_millis(10)).await; | 26 | Timer::after_millis(10).await; |
| 27 | 27 | ||
| 28 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); | 28 | let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); |
| 29 | 29 | ||
diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index bf58044d5..98209fe41 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::gpio; | 11 | use embassy_rp::gpio; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use gpio::{Input, Level, Output, Pull}; | 13 | use gpio::{Input, Level, Output, Pull}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | info!("done wait_for_high. Turn off LED"); | 36 | info!("done wait_for_high. Turn off LED"); |
| 37 | led.set_low(); | 37 | led.set_low(); |
| 38 | 38 | ||
| 39 | Timer::after(Duration::from_secs(2)).await; | 39 | Timer::after_secs(2).await; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
diff --git a/examples/rp/src/bin/gpout.rs b/examples/rp/src/bin/gpout.rs index 0a3b5fa98..896cc15ee 100644 --- a/examples/rp/src/bin/gpout.rs +++ b/examples/rp/src/bin/gpout.rs | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::clocks; | 11 | use embassy_rp::clocks; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -26,13 +26,13 @@ async fn main(_spawner: Spawner) { | |||
| 26 | "Pin 25 is now outputing CLK_SYS/1000, should be toggling at {}", | 26 | "Pin 25 is now outputing CLK_SYS/1000, should be toggling at {}", |
| 27 | gpout3.get_freq() | 27 | gpout3.get_freq() |
| 28 | ); | 28 | ); |
| 29 | Timer::after(Duration::from_secs(2)).await; | 29 | Timer::after_secs(2).await; |
| 30 | 30 | ||
| 31 | gpout3.set_src(clocks::GpoutSrc::Ref); | 31 | gpout3.set_src(clocks::GpoutSrc::Ref); |
| 32 | info!( | 32 | info!( |
| 33 | "Pin 25 is now outputing CLK_REF/1000, should be toggling at {}", | 33 | "Pin 25 is now outputing CLK_REF/1000, should be toggling at {}", |
| 34 | gpout3.get_freq() | 34 | gpout3.get_freq() |
| 35 | ); | 35 | ); |
| 36 | Timer::after(Duration::from_secs(2)).await; | 36 | Timer::after_secs(2).await; |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
diff --git a/examples/rp/src/bin/i2c_async.rs b/examples/rp/src/bin/i2c_async.rs index 93224bc43..7b53aae72 100644 --- a/examples/rp/src/bin/i2c_async.rs +++ b/examples/rp/src/bin/i2c_async.rs | |||
| @@ -12,7 +12,7 @@ use embassy_executor::Spawner; | |||
| 12 | use embassy_rp::bind_interrupts; | 12 | use embassy_rp::bind_interrupts; |
| 13 | use embassy_rp::i2c::{self, Config, InterruptHandler}; | 13 | use embassy_rp::i2c::{self, Config, InterruptHandler}; |
| 14 | use embassy_rp::peripherals::I2C1; | 14 | use embassy_rp::peripherals::I2C1; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::Timer; |
| 16 | use embedded_hal_async::i2c::I2c; | 16 | use embedded_hal_async::i2c::I2c; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| @@ -106,6 +106,6 @@ async fn main(_spawner: Spawner) { | |||
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | Timer::after(Duration::from_millis(100)).await; | 109 | Timer::after_millis(100).await; |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
diff --git a/examples/rp/src/bin/i2c_blocking.rs b/examples/rp/src/bin/i2c_blocking.rs index 1c8c2039d..9ddb48d69 100644 --- a/examples/rp/src/bin/i2c_blocking.rs +++ b/examples/rp/src/bin/i2c_blocking.rs | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | use defmt::*; | 10 | use defmt::*; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_rp::i2c::{self, Config}; | 12 | use embassy_rp::i2c::{self, Config}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use embedded_hal_1::i2c::I2c; | 14 | use embedded_hal_1::i2c::I2c; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| @@ -70,6 +70,6 @@ async fn main(_spawner: Spawner) { | |||
| 70 | info!("portb = {:02x}", portb[0]); | 70 | info!("portb = {:02x}", portb[0]); |
| 71 | val = !val; | 71 | val = !val; |
| 72 | 72 | ||
| 73 | Timer::after(Duration::from_secs(1)).await; | 73 | Timer::after_secs(1).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
diff --git a/examples/rp/src/bin/i2c_slave.rs b/examples/rp/src/bin/i2c_slave.rs index 7de300fb8..151b083a4 100644 --- a/examples/rp/src/bin/i2c_slave.rs +++ b/examples/rp/src/bin/i2c_slave.rs | |||
| @@ -7,7 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::peripherals::{I2C0, I2C1}; | 8 | use embassy_rp::peripherals::{I2C0, I2C1}; |
| 9 | use embassy_rp::{bind_interrupts, i2c, i2c_slave}; | 9 | use embassy_rp::{bind_interrupts, i2c, i2c_slave}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use embedded_hal_async::i2c::I2c; | 11 | use embedded_hal_async::i2c::I2c; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| @@ -81,7 +81,7 @@ async fn controller_task(mut con: i2c::I2c<'static, I2C0, i2c::Async>) { | |||
| 81 | Err(e) => error!("Error writing {}", e), | 81 | Err(e) => error!("Error writing {}", e), |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | Timer::after(Duration::from_millis(100)).await; | 84 | Timer::after_millis(100).await; |
| 85 | } | 85 | } |
| 86 | match con.read(DEV_ADDR, &mut resp_buff).await { | 86 | match con.read(DEV_ADDR, &mut resp_buff).await { |
| 87 | Ok(_) => info!("read response: {}", resp_buff), | 87 | Ok(_) => info!("read response: {}", resp_buff), |
| @@ -91,7 +91,7 @@ async fn controller_task(mut con: i2c::I2c<'static, I2C0, i2c::Async>) { | |||
| 91 | Ok(_) => info!("write_read response: {}", resp_buff), | 91 | Ok(_) => info!("write_read response: {}", resp_buff), |
| 92 | Err(e) => error!("Error writing {}", e), | 92 | Err(e) => error!("Error writing {}", e), |
| 93 | } | 93 | } |
| 94 | Timer::after(Duration::from_millis(100)).await; | 94 | Timer::after_millis(100).await; |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
diff --git a/examples/rp/src/bin/lora_p2p_receive.rs b/examples/rp/src/bin/lora_p2p_receive.rs index 5891826fd..d5843fdcd 100644 --- a/examples/rp/src/bin/lora_p2p_receive.rs +++ b/examples/rp/src/bin/lora_p2p_receive.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; | 11 | use embassy_lora::iv::GenericSx126xInterfaceVariant; |
| 12 | use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; | 12 | use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; |
| 13 | use embassy_rp::spi::{Config, Spi}; | 13 | use embassy_rp::spi::{Config, Spi}; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -96,7 +96,7 @@ async fn main(_spawner: Spawner) { | |||
| 96 | { | 96 | { |
| 97 | info!("rx successful"); | 97 | info!("rx successful"); |
| 98 | debug_indicator.set_high(); | 98 | debug_indicator.set_high(); |
| 99 | Timer::after(Duration::from_secs(5)).await; | 99 | Timer::after_secs(5).await; |
| 100 | debug_indicator.set_low(); | 100 | debug_indicator.set_low(); |
| 101 | } else { | 101 | } else { |
| 102 | info!("rx unknown packet"); | 102 | info!("rx unknown packet"); |
diff --git a/examples/rp/src/bin/lora_p2p_send_multicore.rs b/examples/rp/src/bin/lora_p2p_send_multicore.rs index e31aa62a2..ccf44987c 100644 --- a/examples/rp/src/bin/lora_p2p_send_multicore.rs +++ b/examples/rp/src/bin/lora_p2p_send_multicore.rs | |||
| @@ -15,7 +15,7 @@ use embassy_rp::peripherals::SPI1; | |||
| 15 | use embassy_rp::spi::{Async, Config, Spi}; | 15 | use embassy_rp::spi::{Async, Config, Spi}; |
| 16 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 16 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 17 | use embassy_sync::channel::Channel; | 17 | use embassy_sync::channel::Channel; |
| 18 | use embassy_time::{Delay, Duration, Timer}; | 18 | use embassy_time::{Delay, Timer}; |
| 19 | use lora_phy::mod_params::*; | 19 | use lora_phy::mod_params::*; |
| 20 | use lora_phy::sx1261_2::SX1261_2; | 20 | use lora_phy::sx1261_2::SX1261_2; |
| 21 | use lora_phy::LoRa; | 21 | use lora_phy::LoRa; |
| @@ -59,7 +59,7 @@ async fn core0_task() { | |||
| 59 | info!("Hello from core 0"); | 59 | info!("Hello from core 0"); |
| 60 | loop { | 60 | loop { |
| 61 | CHANNEL.send([0x01u8, 0x02u8, 0x03u8]).await; | 61 | CHANNEL.send([0x01u8, 0x02u8, 0x03u8]).await; |
| 62 | Timer::after(Duration::from_millis(60 * 1000)).await; | 62 | Timer::after_millis(60 * 1000).await; |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 | ||
diff --git a/examples/rp/src/bin/multicore.rs b/examples/rp/src/bin/multicore.rs index bf017f6a7..43eaf8b0a 100644 --- a/examples/rp/src/bin/multicore.rs +++ b/examples/rp/src/bin/multicore.rs | |||
| @@ -13,7 +13,7 @@ use embassy_rp::multicore::{spawn_core1, Stack}; | |||
| 13 | use embassy_rp::peripherals::PIN_25; | 13 | use embassy_rp::peripherals::PIN_25; |
| 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 15 | use embassy_sync::channel::Channel; | 15 | use embassy_sync::channel::Channel; |
| 16 | use embassy_time::{Duration, Timer}; | 16 | use embassy_time::Timer; |
| 17 | use static_cell::StaticCell; | 17 | use static_cell::StaticCell; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| @@ -46,9 +46,9 @@ async fn core0_task() { | |||
| 46 | info!("Hello from core 0"); | 46 | info!("Hello from core 0"); |
| 47 | loop { | 47 | loop { |
| 48 | CHANNEL.send(LedState::On).await; | 48 | CHANNEL.send(LedState::On).await; |
| 49 | Timer::after(Duration::from_millis(100)).await; | 49 | Timer::after_millis(100).await; |
| 50 | CHANNEL.send(LedState::Off).await; | 50 | CHANNEL.send(LedState::Off).await; |
| 51 | Timer::after(Duration::from_millis(400)).await; | 51 | Timer::after_millis(400).await; |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | 54 | ||
diff --git a/examples/rp/src/bin/multiprio.rs b/examples/rp/src/bin/multiprio.rs index 9ace4cd68..28f621437 100644 --- a/examples/rp/src/bin/multiprio.rs +++ b/examples/rp/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::{info, unwrap}; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_rp::interrupt; | 63 | use embassy_rp::interrupt; |
| 64 | use embassy_rp::interrupt::{InterruptExt, Priority}; | 64 | use embassy_rp::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer, TICK_HZ}; | 65 | use embassy_time::{Instant, Timer, TICK_HZ}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | info!(" [high] tick!"); | 72 | info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(673740)).await; | 73 | Timer::after_ticks(673740).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() * 1000 / TICK_HZ; | 87 | let ms = end.duration_since(start).as_ticks() * 1000 / TICK_HZ; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(53421)).await; | 90 | Timer::after_ticks(53421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() * 1000 / TICK_HZ; | 104 | let ms = end.duration_since(start).as_ticks() * 1000 / TICK_HZ; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(82983)).await; | 107 | Timer::after_ticks(82983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index d80c5c24b..5e5a6f9a3 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -15,7 +15,7 @@ use embassy_rp::pio::{ | |||
| 15 | }; | 15 | }; |
| 16 | use embassy_rp::pwm::{self, Pwm}; | 16 | use embassy_rp::pwm::{self, Pwm}; |
| 17 | use embassy_rp::{bind_interrupts, into_ref, Peripheral, PeripheralRef}; | 17 | use embassy_rp::{bind_interrupts, into_ref, Peripheral, PeripheralRef}; |
| 18 | use embassy_time::{Duration, Instant, Timer}; | 18 | use embassy_time::{Instant, Timer}; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | bind_interrupts!(pub struct Irqs { | 21 | bind_interrupts!(pub struct Irqs { |
| @@ -66,7 +66,7 @@ async fn main(_spawner: Spawner) { | |||
| 66 | let mut buf = Buf([0; 16], 0); | 66 | let mut buf = Buf([0; 16], 0); |
| 67 | write!(buf, "up {}s", Instant::now().as_micros() as f32 / 1e6).unwrap(); | 67 | write!(buf, "up {}s", Instant::now().as_micros() as f32 / 1e6).unwrap(); |
| 68 | hd.add_line(&buf.0[0..buf.1]).await; | 68 | hd.add_line(&buf.0[0..buf.1]).await; |
| 69 | Timer::after(Duration::from_secs(1)).await; | 69 | Timer::after_secs(1).await; |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | 72 | ||
diff --git a/examples/rp/src/bin/pio_ws2812.rs b/examples/rp/src/bin/pio_ws2812.rs index 5c0c60246..7b3259538 100644 --- a/examples/rp/src/bin/pio_ws2812.rs +++ b/examples/rp/src/bin/pio_ws2812.rs | |||
| @@ -13,7 +13,7 @@ use embassy_rp::pio::{ | |||
| 13 | Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 13 | Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 14 | }; | 14 | }; |
| 15 | use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; | 15 | use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; |
| 16 | use embassy_time::{Duration, Timer}; | 16 | use embassy_time::Timer; |
| 17 | use fixed::types::U24F8; | 17 | use fixed::types::U24F8; |
| 18 | use fixed_macro::fixed; | 18 | use fixed_macro::fixed; |
| 19 | use smart_leds::RGB8; | 19 | use smart_leds::RGB8; |
| @@ -153,7 +153,7 @@ async fn main(_spawner: Spawner) { | |||
| 153 | } | 153 | } |
| 154 | ws2812.write(&data).await; | 154 | ws2812.write(&data).await; |
| 155 | 155 | ||
| 156 | Timer::after(Duration::from_millis(10)).await; | 156 | Timer::after_millis(10).await; |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| 159 | } | 159 | } |
diff --git a/examples/rp/src/bin/pwm.rs b/examples/rp/src/bin/pwm.rs index 9d919287c..a99e88003 100644 --- a/examples/rp/src/bin/pwm.rs +++ b/examples/rp/src/bin/pwm.rs | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::pwm::{Config, Pwm}; | 11 | use embassy_rp::pwm::{Config, Pwm}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | 23 | ||
| 24 | loop { | 24 | loop { |
| 25 | info!("current LED duty cycle: {}/32768", c.compare_b); | 25 | info!("current LED duty cycle: {}/32768", c.compare_b); |
| 26 | Timer::after(Duration::from_secs(1)).await; | 26 | Timer::after_secs(1).await; |
| 27 | c.compare_b = c.compare_b.rotate_left(4); | 27 | c.compare_b = c.compare_b.rotate_left(4); |
| 28 | pwm.set_config(&c); | 28 | pwm.set_config(&c); |
| 29 | } | 29 | } |
diff --git a/examples/rp/src/bin/rtc.rs b/examples/rp/src/bin/rtc.rs index 15aa8243f..667876db5 100644 --- a/examples/rp/src/bin/rtc.rs +++ b/examples/rp/src/bin/rtc.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::rtc::{DateTime, DayOfWeek, Rtc}; | 9 | use embassy_rp::rtc::{DateTime, DayOfWeek, Rtc}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -31,7 +31,7 @@ async fn main(_spawner: Spawner) { | |||
| 31 | rtc.set_datetime(now).unwrap(); | 31 | rtc.set_datetime(now).unwrap(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | Timer::after(Duration::from_millis(20000)).await; | 34 | Timer::after_millis(20000).await; |
| 35 | 35 | ||
| 36 | if let Ok(dt) = rtc.now() { | 36 | if let Ok(dt) = rtc.now() { |
| 37 | info!( | 37 | info!( |
| @@ -41,6 +41,6 @@ async fn main(_spawner: Spawner) { | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | info!("Reboot."); | 43 | info!("Reboot."); |
| 44 | Timer::after(Duration::from_millis(200)).await; | 44 | Timer::after_millis(200).await; |
| 45 | cortex_m::peripheral::SCB::sys_reset(); | 45 | cortex_m::peripheral::SCB::sys_reset(); |
| 46 | } | 46 | } |
diff --git a/examples/rp/src/bin/spi_async.rs b/examples/rp/src/bin/spi_async.rs index 328074e8b..f5a2d334e 100644 --- a/examples/rp/src/bin/spi_async.rs +++ b/examples/rp/src/bin/spi_async.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_rp::spi::{Config, Spi}; | 10 | use embassy_rp::spi::{Config, Spi}; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -27,6 +27,6 @@ async fn main(_spawner: Spawner) { | |||
| 27 | let mut rx_buf = [0_u8; 6]; | 27 | let mut rx_buf = [0_u8; 6]; |
| 28 | spi.transfer(&mut rx_buf, &tx_buf).await.unwrap(); | 28 | spi.transfer(&mut rx_buf, &tx_buf).await.unwrap(); |
| 29 | info!("{:?}", rx_buf); | 29 | info!("{:?}", rx_buf); |
| 30 | Timer::after(Duration::from_secs(1)).await; | 30 | Timer::after_secs(1).await; |
| 31 | } | 31 | } |
| 32 | } | 32 | } |
diff --git a/examples/rp/src/bin/uart_buffered_split.rs b/examples/rp/src/bin/uart_buffered_split.rs index d3e67c8ed..14e8810a4 100644 --- a/examples/rp/src/bin/uart_buffered_split.rs +++ b/examples/rp/src/bin/uart_buffered_split.rs | |||
| @@ -13,7 +13,7 @@ use embassy_executor::Spawner; | |||
| 13 | use embassy_rp::bind_interrupts; | 13 | use embassy_rp::bind_interrupts; |
| 14 | use embassy_rp::peripherals::UART0; | 14 | use embassy_rp::peripherals::UART0; |
| 15 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; | 15 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; |
| 16 | use embassy_time::{Duration, Timer}; | 16 | use embassy_time::Timer; |
| 17 | use embedded_io_async::{Read, Write}; | 17 | use embedded_io_async::{Read, Write}; |
| 18 | use static_cell::make_static; | 18 | use static_cell::make_static; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -42,7 +42,7 @@ async fn main(spawner: Spawner) { | |||
| 42 | ]; | 42 | ]; |
| 43 | info!("TX {:?}", data); | 43 | info!("TX {:?}", data); |
| 44 | tx.write_all(&data).await.unwrap(); | 44 | tx.write_all(&data).await.unwrap(); |
| 45 | Timer::after(Duration::from_secs(1)).await; | 45 | Timer::after_secs(1).await; |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | 48 | ||
diff --git a/examples/rp/src/bin/uart_unidir.rs b/examples/rp/src/bin/uart_unidir.rs index c1515a911..42c8b432e 100644 --- a/examples/rp/src/bin/uart_unidir.rs +++ b/examples/rp/src/bin/uart_unidir.rs | |||
| @@ -14,7 +14,7 @@ use embassy_executor::Spawner; | |||
| 14 | use embassy_rp::bind_interrupts; | 14 | use embassy_rp::bind_interrupts; |
| 15 | use embassy_rp::peripherals::UART1; | 15 | use embassy_rp::peripherals::UART1; |
| 16 | use embassy_rp::uart::{Async, Config, InterruptHandler, UartRx, UartTx}; | 16 | use embassy_rp::uart::{Async, Config, InterruptHandler, UartRx, UartTx}; |
| 17 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::Timer; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| @@ -35,7 +35,7 @@ async fn main(spawner: Spawner) { | |||
| 35 | let data = [1u8, 2, 3, 4, 5, 6, 7, 8]; | 35 | let data = [1u8, 2, 3, 4, 5, 6, 7, 8]; |
| 36 | info!("TX {:?}", data); | 36 | info!("TX {:?}", data); |
| 37 | uart_tx.write(&data).await.unwrap(); | 37 | uart_tx.write(&data).await.unwrap(); |
| 38 | Timer::after(Duration::from_secs(1)).await; | 38 | Timer::after_secs(1).await; |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | 41 | ||
diff --git a/examples/rp/src/bin/usb_logger.rs b/examples/rp/src/bin/usb_logger.rs index 9c5e6897d..791f15e56 100644 --- a/examples/rp/src/bin/usb_logger.rs +++ b/examples/rp/src/bin/usb_logger.rs | |||
| @@ -10,7 +10,7 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_rp::bind_interrupts; | 10 | use embassy_rp::bind_interrupts; |
| 11 | use embassy_rp::peripherals::USB; | 11 | use embassy_rp::peripherals::USB; |
| 12 | use embassy_rp::usb::{Driver, InterruptHandler}; | 12 | use embassy_rp::usb::{Driver, InterruptHandler}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
| @@ -32,6 +32,6 @@ async fn main(spawner: Spawner) { | |||
| 32 | loop { | 32 | loop { |
| 33 | counter += 1; | 33 | counter += 1; |
| 34 | log::info!("Tick {}", counter); | 34 | log::info!("Tick {}", counter); |
| 35 | Timer::after(Duration::from_secs(1)).await; | 35 | Timer::after_secs(1).await; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
diff --git a/examples/rp/src/bin/watchdog.rs b/examples/rp/src/bin/watchdog.rs index fe5eaf926..b6af518af 100644 --- a/examples/rp/src/bin/watchdog.rs +++ b/examples/rp/src/bin/watchdog.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | 24 | ||
| 25 | // Set the LED high for 2 seconds so we know when we're about to start the watchdog | 25 | // Set the LED high for 2 seconds so we know when we're about to start the watchdog |
| 26 | led.set_high(); | 26 | led.set_high(); |
| 27 | Timer::after(Duration::from_secs(2)).await; | 27 | Timer::after_secs(2).await; |
| 28 | 28 | ||
| 29 | // Set to watchdog to reset if it's not fed within 1.05 seconds, and start it | 29 | // Set to watchdog to reset if it's not fed within 1.05 seconds, and start it |
| 30 | watchdog.start(Duration::from_millis(1_050)); | 30 | watchdog.start(Duration::from_millis(1_050)); |
| @@ -33,9 +33,9 @@ async fn main(_spawner: Spawner) { | |||
| 33 | // Blink once a second for 5 seconds, feed the watchdog timer once a second to avoid a reset | 33 | // Blink once a second for 5 seconds, feed the watchdog timer once a second to avoid a reset |
| 34 | for _ in 1..=5 { | 34 | for _ in 1..=5 { |
| 35 | led.set_low(); | 35 | led.set_low(); |
| 36 | Timer::after(Duration::from_millis(500)).await; | 36 | Timer::after_millis(500).await; |
| 37 | led.set_high(); | 37 | led.set_high(); |
| 38 | Timer::after(Duration::from_millis(500)).await; | 38 | Timer::after_millis(500).await; |
| 39 | info!("Feeding watchdog"); | 39 | info!("Feeding watchdog"); |
| 40 | watchdog.feed(); | 40 | watchdog.feed(); |
| 41 | } | 41 | } |
| @@ -45,8 +45,8 @@ async fn main(_spawner: Spawner) { | |||
| 45 | // The processor should reset in 1.05 seconds. | 45 | // The processor should reset in 1.05 seconds. |
| 46 | loop { | 46 | loop { |
| 47 | led.set_low(); | 47 | led.set_low(); |
| 48 | Timer::after(Duration::from_millis(100)).await; | 48 | Timer::after_millis(100).await; |
| 49 | led.set_high(); | 49 | led.set_high(); |
| 50 | Timer::after(Duration::from_millis(100)).await; | 50 | Timer::after_millis(100).await; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 64cf95171..c00fff216 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -105,7 +105,7 @@ async fn main(spawner: Spawner) { | |||
| 105 | // Wait for DHCP, not necessary when using static IP | 105 | // Wait for DHCP, not necessary when using static IP |
| 106 | info!("waiting for DHCP..."); | 106 | info!("waiting for DHCP..."); |
| 107 | while !stack.is_config_up() { | 107 | while !stack.is_config_up() { |
| 108 | Timer::after(Duration::from_millis(100)).await; | 108 | Timer::after_millis(100).await; |
| 109 | } | 109 | } |
| 110 | info!("DHCP is now up!"); | 110 | info!("DHCP is now up!"); |
| 111 | 111 | ||
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs index 199e4c9ec..79fa375cd 100644 --- a/examples/std/src/bin/tcp_accept.rs +++ b/examples/std/src/bin/tcp_accept.rs | |||
| @@ -100,7 +100,7 @@ async fn main_task(spawner: Spawner) { | |||
| 100 | return; | 100 | return; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | Timer::after(Duration::from_millis(500)).await; | 103 | Timer::after_millis(500).await; |
| 104 | } | 104 | } |
| 105 | info!("Closing the connection"); | 105 | info!("Closing the connection"); |
| 106 | socket.abort(); | 106 | socket.abort(); |
diff --git a/examples/std/src/bin/tick.rs b/examples/std/src/bin/tick.rs index b9de9d873..a3f99067e 100644 --- a/examples/std/src/bin/tick.rs +++ b/examples/std/src/bin/tick.rs | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
| 2 | 2 | ||
| 3 | use embassy_executor::Spawner; | 3 | use embassy_executor::Spawner; |
| 4 | use embassy_time::{Duration, Timer}; | 4 | use embassy_time::Timer; |
| 5 | use log::*; | 5 | use log::*; |
| 6 | 6 | ||
| 7 | #[embassy_executor::task] | 7 | #[embassy_executor::task] |
| 8 | async fn run() { | 8 | async fn run() { |
| 9 | loop { | 9 | loop { |
| 10 | info!("tick"); | 10 | info!("tick"); |
| 11 | Timer::after(Duration::from_secs(1)).await; | 11 | Timer::after_secs(1).await; |
| 12 | } | 12 | } |
| 13 | } | 13 | } |
| 14 | 14 | ||
diff --git a/examples/stm32c0/src/bin/blinky.rs b/examples/stm32c0/src/bin/blinky.rs index 8a65b0692..cbeb0dee1 100644 --- a/examples/stm32c0/src/bin/blinky.rs +++ b/examples/stm32c0/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f0/src/bin/adc.rs b/examples/stm32f0/src/bin/adc.rs index 1564ecfc0..96f234402 100644 --- a/examples/stm32f0/src/bin/adc.rs +++ b/examples/stm32f0/src/bin/adc.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::peripherals::ADC; | 8 | use embassy_stm32::peripherals::ADC; |
| 9 | use embassy_stm32::{adc, bind_interrupts}; | 9 | use embassy_stm32::{adc, bind_interrupts}; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | bind_interrupts!(struct Irqs { | 13 | bind_interrupts!(struct Irqs { |
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | loop { | 36 | loop { |
| 37 | let v = adc.read(&mut pin).await; | 37 | let v = adc.read(&mut pin).await; |
| 38 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); | 38 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); |
| 39 | Timer::after(Duration::from_millis(100)).await; | 39 | Timer::after_millis(100).await; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
diff --git a/examples/stm32f0/src/bin/blinky.rs b/examples/stm32f0/src/bin/blinky.rs index 9f923399c..899394546 100644 --- a/examples/stm32f0/src/bin/blinky.rs +++ b/examples/stm32f0/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | // main is itself an async function. | 11 | // main is itself an async function. |
| @@ -19,10 +19,10 @@ async fn main(_spawner: Spawner) { | |||
| 19 | loop { | 19 | loop { |
| 20 | info!("high"); | 20 | info!("high"); |
| 21 | led.set_high(); | 21 | led.set_high(); |
| 22 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after_millis(300).await; |
| 23 | 23 | ||
| 24 | info!("low"); | 24 | info!("low"); |
| 25 | led.set_low(); | 25 | led.set_low(); |
| 26 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after_millis(300).await; |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
diff --git a/examples/stm32f0/src/bin/button_controlled_blink.rs b/examples/stm32f0/src/bin/button_controlled_blink.rs index f362c53f5..306df1752 100644 --- a/examples/stm32f0/src/bin/button_controlled_blink.rs +++ b/examples/stm32f0/src/bin/button_controlled_blink.rs | |||
| @@ -10,7 +10,7 @@ use defmt::info; | |||
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 12 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; | 12 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); | 16 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); |
| @@ -24,7 +24,7 @@ async fn led_task(led: AnyPin) { | |||
| 24 | loop { | 24 | loop { |
| 25 | let del = BLINK_MS.load(Ordering::Relaxed); | 25 | let del = BLINK_MS.load(Ordering::Relaxed); |
| 26 | info!("Value of del is {}", del); | 26 | info!("Value of del is {}", del); |
| 27 | Timer::after(Duration::from_millis(del.into())).await; | 27 | Timer::after_millis(del.into()).await; |
| 28 | info!("LED toggling"); | 28 | info!("LED toggling"); |
| 29 | led.toggle(); | 29 | led.toggle(); |
| 30 | } | 30 | } |
diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index db78233ea..0f98d9865 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs | |||
| @@ -4,14 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::Timer; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner) -> ! { | 11 | async fn main(_spawner: Spawner) -> ! { |
| 12 | let _p = embassy_stm32::init(Default::default()); | 12 | let _p = embassy_stm32::init(Default::default()); |
| 13 | loop { | 13 | loop { |
| 14 | Timer::after(Duration::from_secs(1)).await; | 14 | Timer::after_secs(1).await; |
| 15 | info!("Hello"); | 15 | info!("Hello"); |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
diff --git a/examples/stm32f0/src/bin/multiprio.rs b/examples/stm32f0/src/bin/multiprio.rs index 988ffeef1..870c7c45b 100644 --- a/examples/stm32f0/src/bin/multiprio.rs +++ b/examples/stm32f0/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::*; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Instant, Timer}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | // info!(" [high] tick!"); | 72 | // info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(27374)).await; | 73 | Timer::after_ticks(27374).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() / 33; | 87 | let ms = end.duration_since(start).as_ticks() / 33; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(23421)).await; | 90 | Timer::after_ticks(23421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() / 33; | 104 | let ms = end.duration_since(start).as_ticks() / 33; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(32983)).await; | 107 | Timer::after_ticks(32983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/stm32f0/src/bin/wdg.rs b/examples/stm32f0/src/bin/wdg.rs index a44b17528..b51dee8ee 100644 --- a/examples/stm32f0/src/bin/wdg.rs +++ b/examples/stm32f0/src/bin/wdg.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::wdg::IndependentWatchdog; | 7 | use embassy_stm32::wdg::IndependentWatchdog; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) { | |||
| 19 | wdg.unleash(); | 19 | wdg.unleash(); |
| 20 | 20 | ||
| 21 | loop { | 21 | loop { |
| 22 | Timer::after(Duration::from_secs(1)).await; | 22 | Timer::after_secs(1).await; |
| 23 | wdg.pet(); | 23 | wdg.pet(); |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index 30947c3c2..1edac3d83 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 8 | use embassy_stm32::peripherals::ADC1; | 8 | use embassy_stm32::peripherals::ADC1; |
| 9 | use embassy_stm32::{adc, bind_interrupts}; | 9 | use embassy_stm32::{adc, bind_interrupts}; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | bind_interrupts!(struct Irqs { | 13 | bind_interrupts!(struct Irqs { |
| @@ -35,6 +35,6 @@ async fn main(_spawner: Spawner) { | |||
| 35 | loop { | 35 | loop { |
| 36 | let v = adc.read(&mut pin).await; | 36 | let v = adc.read(&mut pin).await; |
| 37 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); | 37 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); |
| 38 | Timer::after(Duration::from_millis(100)).await; | 38 | Timer::after_millis(100).await; |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index b9b0ac238..3425b0536 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 180b6aabd..e63bcaae0 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -17,6 +17,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 17 | 17 | ||
| 18 | loop { | 18 | loop { |
| 19 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 20 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after_secs(1).await; |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index 663099ff7..60eb5d0e4 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::gpio::{Level, Output, Speed}; | |||
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb::{Driver, Instance}; | 10 | use embassy_stm32::usb::{Driver, Instance}; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 14 | use embassy_usb::driver::EndpointError; | 14 | use embassy_usb::driver::EndpointError; |
| 15 | use embassy_usb::Builder; | 15 | use embassy_usb::Builder; |
| @@ -35,7 +35,7 @@ async fn main(_spawner: Spawner) { | |||
| 35 | // This forced reset is needed only for development, without it host | 35 | // This forced reset is needed only for development, without it host |
| 36 | // will not reset your device when you upload new firmware. | 36 | // will not reset your device when you upload new firmware. |
| 37 | let _dp = Output::new(&mut p.PA12, Level::Low, Speed::Low); | 37 | let _dp = Output::new(&mut p.PA12, Level::Low, Speed::Low); |
| 38 | Timer::after(Duration::from_millis(10)).await; | 38 | Timer::after_millis(10).await; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | // Create the driver, from the HAL. | 41 | // Create the driver, from the HAL. |
diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index d8c89a519..f6d7a0005 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(1000)).await; | 21 | Timer::after_millis(1000).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(1000)).await; | 25 | Timer::after_millis(1000).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 62aaa9800..56591b527 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::rcc::{ | |||
| 11 | }; | 11 | }; |
| 12 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 13 | use embassy_stm32::Config; | 13 | use embassy_stm32::Config; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::Timer; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| @@ -46,7 +46,7 @@ async fn main(_spawner: Spawner) { | |||
| 46 | let _p = embassy_stm32::init(config); | 46 | let _p = embassy_stm32::init(config); |
| 47 | 47 | ||
| 48 | loop { | 48 | loop { |
| 49 | Timer::after(Duration::from_millis(1000)).await; | 49 | Timer::after_millis(1000).await; |
| 50 | info!("1s elapsed"); | 50 | info!("1s elapsed"); |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 185785ceb..e71031b30 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(1000)).await; | 21 | Timer::after_millis(1000).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(1000)).await; | 25 | Timer::after_millis(1000).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 8e97e85eb..9df6d680d 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs | |||
| @@ -65,11 +65,11 @@ impl<'a> Leds<'a> { | |||
| 65 | for led in &mut self.leds { | 65 | for led in &mut self.leds { |
| 66 | led.set_high(); | 66 | led.set_high(); |
| 67 | } | 67 | } |
| 68 | Timer::after(Duration::from_millis(500)).await; | 68 | Timer::after_millis(500).await; |
| 69 | for led in &mut self.leds { | 69 | for led in &mut self.leds { |
| 70 | led.set_low(); | 70 | led.set_low(); |
| 71 | } | 71 | } |
| 72 | Timer::after(Duration::from_millis(200)).await; | 72 | Timer::after_millis(200).await; |
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | 75 | ||
diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index 65773210d..b3285f3c1 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -18,6 +18,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 18 | 18 | ||
| 19 | loop { | 19 | loop { |
| 20 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 21 | Timer::after(Duration::from_secs(1)).await; | 21 | Timer::after_secs(1).await; |
| 22 | } | 22 | } |
| 23 | } | 23 | } |
diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 80bf59deb..74f3bb1c5 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::*; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Instant, Timer}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | info!(" [high] tick!"); | 72 | info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(27374)).await; | 73 | Timer::after_ticks(27374).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() / 33; | 87 | let ms = end.duration_since(start).as_ticks() / 33; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(23421)).await; | 90 | Timer::after_ticks(23421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() / 33; | 104 | let ms = end.duration_since(start).as_ticks() / 33; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(32983)).await; | 107 | Timer::after_ticks(32983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index f15f333b7..a9537c77b 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::gpio::{Level, Output, Speed}; | |||
| 9 | use embassy_stm32::time::mhz; | 9 | use embassy_stm32::time::mhz; |
| 10 | use embassy_stm32::usb::{Driver, Instance}; | 10 | use embassy_stm32::usb::{Driver, Instance}; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 14 | use embassy_usb::driver::EndpointError; | 14 | use embassy_usb::driver::EndpointError; |
| 15 | use embassy_usb::Builder; | 15 | use embassy_usb::Builder; |
| @@ -33,7 +33,7 @@ async fn main(_spawner: Spawner) { | |||
| 33 | 33 | ||
| 34 | // Needed for nucleo-stm32f303ze | 34 | // Needed for nucleo-stm32f303ze |
| 35 | let mut dp_pullup = Output::new(p.PG6, Level::Low, Speed::Medium); | 35 | let mut dp_pullup = Output::new(p.PG6, Level::Low, Speed::Medium); |
| 36 | Timer::after(Duration::from_millis(10)).await; | 36 | Timer::after_millis(10).await; |
| 37 | dp_pullup.set_high(); | 37 | dp_pullup.set_high(); |
| 38 | 38 | ||
| 39 | // Create the driver, from the HAL. | 39 | // Create the driver, from the HAL. |
diff --git a/examples/stm32f334/src/bin/adc.rs b/examples/stm32f334/src/bin/adc.rs index a9286c44c..f259135d2 100644 --- a/examples/stm32f334/src/bin/adc.rs +++ b/examples/stm32f334/src/bin/adc.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::peripherals::ADC1; | |||
| 9 | use embassy_stm32::rcc::{AdcClockSource, Adcpres}; | 9 | use embassy_stm32::rcc::{AdcClockSource, Adcpres}; |
| 10 | use embassy_stm32::time::mhz; | 10 | use embassy_stm32::time::mhz; |
| 11 | use embassy_stm32::{adc, bind_interrupts, Config}; | 11 | use embassy_stm32::{adc, bind_interrupts, Config}; |
| 12 | use embassy_time::{Delay, Duration, Timer}; | 12 | use embassy_time::{Delay, Timer}; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -51,6 +51,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 51 | let pin_mv = (pin as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; | 51 | let pin_mv = (pin as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; |
| 52 | info!("computed pin mv: {}", pin_mv); | 52 | info!("computed pin mv: {}", pin_mv); |
| 53 | 53 | ||
| 54 | Timer::after(Duration::from_millis(500)).await; | 54 | Timer::after_millis(500).await; |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
diff --git a/examples/stm32f334/src/bin/button.rs b/examples/stm32f334/src/bin/button.rs index 599c0f27d..501fb080c 100644 --- a/examples/stm32f334/src/bin/button.rs +++ b/examples/stm32f334/src/bin/button.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -17,10 +17,10 @@ async fn main(_spawner: Spawner) { | |||
| 17 | let mut out1 = Output::new(p.PA8, Level::Low, Speed::High); | 17 | let mut out1 = Output::new(p.PA8, Level::Low, Speed::High); |
| 18 | 18 | ||
| 19 | out1.set_high(); | 19 | out1.set_high(); |
| 20 | Timer::after(Duration::from_millis(500)).await; | 20 | Timer::after_millis(500).await; |
| 21 | out1.set_low(); | 21 | out1.set_low(); |
| 22 | 22 | ||
| 23 | Timer::after(Duration::from_millis(500)).await; | 23 | Timer::after_millis(500).await; |
| 24 | info!("end program"); | 24 | info!("end program"); |
| 25 | 25 | ||
| 26 | cortex_m::asm::bkpt(); | 26 | cortex_m::asm::bkpt(); |
diff --git a/examples/stm32f334/src/bin/hello.rs b/examples/stm32f334/src/bin/hello.rs index 65773210d..b3285f3c1 100644 --- a/examples/stm32f334/src/bin/hello.rs +++ b/examples/stm32f334/src/bin/hello.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -18,6 +18,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 18 | 18 | ||
| 19 | loop { | 19 | loop { |
| 20 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 21 | Timer::after(Duration::from_secs(1)).await; | 21 | Timer::after_secs(1).await; |
| 22 | } | 22 | } |
| 23 | } | 23 | } |
diff --git a/examples/stm32f334/src/bin/opamp.rs b/examples/stm32f334/src/bin/opamp.rs index fb5a85bcb..128001bf2 100644 --- a/examples/stm32f334/src/bin/opamp.rs +++ b/examples/stm32f334/src/bin/opamp.rs | |||
| @@ -10,7 +10,7 @@ use embassy_stm32::peripherals::ADC2; | |||
| 10 | use embassy_stm32::rcc::{AdcClockSource, Adcpres}; | 10 | use embassy_stm32::rcc::{AdcClockSource, Adcpres}; |
| 11 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 12 | use embassy_stm32::{adc, bind_interrupts, Config}; | 12 | use embassy_stm32::{adc, bind_interrupts, Config}; |
| 13 | use embassy_time::{Delay, Duration, Timer}; | 13 | use embassy_time::{Delay, Timer}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
| @@ -54,6 +54,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 54 | let pin_mv = (buffer as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; | 54 | let pin_mv = (buffer as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; |
| 55 | info!("computed pin mv: {}", pin_mv); | 55 | info!("computed pin mv: {}", pin_mv); |
| 56 | 56 | ||
| 57 | Timer::after(Duration::from_millis(500)).await; | 57 | Timer::after_millis(500).await; |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
diff --git a/examples/stm32f334/src/bin/pwm.rs b/examples/stm32f334/src/bin/pwm.rs index aebc421b3..8040c3f18 100644 --- a/examples/stm32f334/src/bin/pwm.rs +++ b/examples/stm32f334/src/bin/pwm.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::hrtim::*; | |||
| 8 | use embassy_stm32::rcc::HrtimClockSource; | 8 | use embassy_stm32::rcc::HrtimClockSource; |
| 9 | use embassy_stm32::time::{khz, mhz}; | 9 | use embassy_stm32::time::{khz, mhz}; |
| 10 | use embassy_stm32::Config; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -48,7 +48,7 @@ async fn main(_spawner: Spawner) { | |||
| 48 | // .setr(0) | 48 | // .setr(0) |
| 49 | // .modify(|w| w.set_sst(Activeeffect::SETACTIVE)); | 49 | // .modify(|w| w.set_sst(Activeeffect::SETACTIVE)); |
| 50 | // | 50 | // |
| 51 | // Timer::after(Duration::from_millis(500)).await; | 51 | // Timer::after_millis(500).await; |
| 52 | // | 52 | // |
| 53 | // embassy_stm32::pac::HRTIM1 | 53 | // embassy_stm32::pac::HRTIM1 |
| 54 | // .tim(0) | 54 | // .tim(0) |
| @@ -65,7 +65,7 @@ async fn main(_spawner: Spawner) { | |||
| 65 | 65 | ||
| 66 | buck_converter.start(); | 66 | buck_converter.start(); |
| 67 | 67 | ||
| 68 | Timer::after(Duration::from_millis(500)).await; | 68 | Timer::after_millis(500).await; |
| 69 | 69 | ||
| 70 | info!("end program"); | 70 | info!("end program"); |
| 71 | 71 | ||
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index dd10385c4..f19328727 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs | |||
| @@ -6,7 +6,7 @@ use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::adc::{Adc, Temperature, VrefInt}; | 8 | use embassy_stm32::adc::{Adc, Temperature, VrefInt}; |
| 9 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -63,6 +63,6 @@ async fn main(_spawner: Spawner) { | |||
| 63 | let v = adc.read(&mut vrefint); | 63 | let v = adc.read(&mut vrefint); |
| 64 | info!("VrefInt: {}", v); | 64 | info!("VrefInt: {}", v); |
| 65 | 65 | ||
| 66 | Timer::after(Duration::from_millis(100)).await; | 66 | Timer::after_millis(100).await; |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index b27bee4ce..4bfc5a50d 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index 6a1d4b088..ddf8596ae 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::peripherals::ETH; | |||
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::Timer; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use static_cell::make_static; | 17 | use static_cell::make_static; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -99,7 +99,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 99 | let r = socket.connect(remote_endpoint).await; | 99 | let r = socket.connect(remote_endpoint).await; |
| 100 | if let Err(e) = r { | 100 | if let Err(e) = r { |
| 101 | info!("connect error: {:?}", e); | 101 | info!("connect error: {:?}", e); |
| 102 | Timer::after(Duration::from_secs(1)).await; | 102 | Timer::after_secs(1).await; |
| 103 | continue; | 103 | continue; |
| 104 | } | 104 | } |
| 105 | info!("connected!"); | 105 | info!("connected!"); |
| @@ -110,7 +110,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 110 | info!("write error: {:?}", e); | 110 | info!("write error: {:?}", e); |
| 111 | break; | 111 | break; |
| 112 | } | 112 | } |
| 113 | Timer::after(Duration::from_secs(1)).await; | 113 | Timer::after_secs(1).await; |
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs index 6c9689d9c..f0a65a725 100644 --- a/examples/stm32f4/src/bin/flash_async.rs +++ b/examples/stm32f4/src/bin/flash_async.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::bind_interrupts; | 7 | use embassy_stm32::bind_interrupts; |
| 8 | use embassy_stm32::flash::{Flash, InterruptHandler}; | 8 | use embassy_stm32::flash::{Flash, InterruptHandler}; |
| 9 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed}; | 9 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | bind_interrupts!(struct Irqs { | 13 | bind_interrupts!(struct Irqs { |
| @@ -35,11 +35,11 @@ async fn blinky(p: AnyPin) { | |||
| 35 | loop { | 35 | loop { |
| 36 | info!("high"); | 36 | info!("high"); |
| 37 | led.set_high(); | 37 | led.set_high(); |
| 38 | Timer::after(Duration::from_millis(300)).await; | 38 | Timer::after_millis(300).await; |
| 39 | 39 | ||
| 40 | info!("low"); | 40 | info!("low"); |
| 41 | led.set_low(); | 41 | led.set_low(); |
| 42 | Timer::after(Duration::from_millis(300)).await; | 42 | Timer::after_millis(300).await; |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index c409703f5..27ee83aa5 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -17,6 +17,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 17 | 17 | ||
| 18 | loop { | 18 | loop { |
| 19 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 20 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after_secs(1).await; |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs index 5144a78c6..3315e7652 100644 --- a/examples/stm32f4/src/bin/mco.rs +++ b/examples/stm32f4/src/bin/mco.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler}; | 8 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -21,10 +21,10 @@ async fn main(_spawner: Spawner) { | |||
| 21 | loop { | 21 | loop { |
| 22 | info!("high"); | 22 | info!("high"); |
| 23 | led.set_high(); | 23 | led.set_high(); |
| 24 | Timer::after(Duration::from_millis(300)).await; | 24 | Timer::after_millis(300).await; |
| 25 | 25 | ||
| 26 | info!("low"); | 26 | info!("low"); |
| 27 | led.set_low(); | 27 | led.set_low(); |
| 28 | Timer::after(Duration::from_millis(300)).await; | 28 | Timer::after_millis(300).await; |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 80bf59deb..74f3bb1c5 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -62,7 +62,7 @@ use defmt::*; | |||
| 62 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 63 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 65 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Instant, Timer}; |
| 66 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 67 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| 68 | 68 | ||
| @@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 70 | async fn run_high() { | 70 | async fn run_high() { |
| 71 | loop { | 71 | loop { |
| 72 | info!(" [high] tick!"); | 72 | info!(" [high] tick!"); |
| 73 | Timer::after(Duration::from_ticks(27374)).await; | 73 | Timer::after_ticks(27374).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -87,7 +87,7 @@ async fn run_med() { | |||
| 87 | let ms = end.duration_since(start).as_ticks() / 33; | 87 | let ms = end.duration_since(start).as_ticks() / 33; |
| 88 | info!(" [med] done in {} ms", ms); | 88 | info!(" [med] done in {} ms", ms); |
| 89 | 89 | ||
| 90 | Timer::after(Duration::from_ticks(23421)).await; | 90 | Timer::after_ticks(23421).await; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| @@ -104,7 +104,7 @@ async fn run_low() { | |||
| 104 | let ms = end.duration_since(start).as_ticks() / 33; | 104 | let ms = end.duration_since(start).as_ticks() / 33; |
| 105 | info!("[low] done in {} ms", ms); | 105 | info!("[low] done in {} ms", ms); |
| 106 | 106 | ||
| 107 | Timer::after(Duration::from_ticks(32983)).await; | 107 | Timer::after_ticks(32983).await; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 1013a844e..538427e89 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::gpio::OutputType; | |||
| 8 | use embassy_stm32::time::khz; | 8 | use embassy_stm32::time::khz; |
| 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 10 | use embassy_stm32::timer::Channel; | 10 | use embassy_stm32::timer::Channel; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -26,12 +26,12 @@ async fn main(_spawner: Spawner) { | |||
| 26 | 26 | ||
| 27 | loop { | 27 | loop { |
| 28 | pwm.set_duty(Channel::Ch1, 0); | 28 | pwm.set_duty(Channel::Ch1, 0); |
| 29 | Timer::after(Duration::from_millis(300)).await; | 29 | Timer::after_millis(300).await; |
| 30 | pwm.set_duty(Channel::Ch1, max / 4); | 30 | pwm.set_duty(Channel::Ch1, max / 4); |
| 31 | Timer::after(Duration::from_millis(300)).await; | 31 | Timer::after_millis(300).await; |
| 32 | pwm.set_duty(Channel::Ch1, max / 2); | 32 | pwm.set_duty(Channel::Ch1, max / 2); |
| 33 | Timer::after(Duration::from_millis(300)).await; | 33 | Timer::after_millis(300).await; |
| 34 | pwm.set_duty(Channel::Ch1, max - 1); | 34 | pwm.set_duty(Channel::Ch1, max - 1); |
| 35 | Timer::after(Duration::from_millis(300)).await; | 35 | Timer::after_millis(300).await; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs index 83a3c7537..a8211f6e0 100644 --- a/examples/stm32f4/src/bin/pwm_complementary.rs +++ b/examples/stm32f4/src/bin/pwm_complementary.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::time::khz; | |||
| 9 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 9 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 10 | use embassy_stm32::timer::simple_pwm::PwmPin; | 10 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 11 | use embassy_stm32::timer::Channel; | 11 | use embassy_stm32::timer::Channel; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -42,12 +42,12 @@ async fn main(_spawner: Spawner) { | |||
| 42 | 42 | ||
| 43 | loop { | 43 | loop { |
| 44 | pwm.set_duty(Channel::Ch1, 0); | 44 | pwm.set_duty(Channel::Ch1, 0); |
| 45 | Timer::after(Duration::from_millis(300)).await; | 45 | Timer::after_millis(300).await; |
| 46 | pwm.set_duty(Channel::Ch1, max / 4); | 46 | pwm.set_duty(Channel::Ch1, max / 4); |
| 47 | Timer::after(Duration::from_millis(300)).await; | 47 | Timer::after_millis(300).await; |
| 48 | pwm.set_duty(Channel::Ch1, max / 2); | 48 | pwm.set_duty(Channel::Ch1, max / 2); |
| 49 | Timer::after(Duration::from_millis(300)).await; | 49 | Timer::after_millis(300).await; |
| 50 | pwm.set_duty(Channel::Ch1, max - 1); | 50 | pwm.set_duty(Channel::Ch1, max - 1); |
| 51 | Timer::after(Duration::from_millis(300)).await; | 51 | Timer::after_millis(300).await; |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs index e95ad5779..44b4303c0 100644 --- a/examples/stm32f4/src/bin/rtc.rs +++ b/examples/stm32f4/src/bin/rtc.rs | |||
| @@ -7,7 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -31,6 +31,6 @@ async fn main(_spawner: Spawner) { | |||
| 31 | 31 | ||
| 32 | info!("{}", now.timestamp()); | 32 | info!("{}", now.timestamp()); |
| 33 | 33 | ||
| 34 | Timer::after(Duration::from_millis(1000)).await; | 34 | Timer::after_millis(1000).await; |
| 35 | } | 35 | } |
| 36 | } | 36 | } |
diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index e5d122af7..0443b61c5 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::wdg::IndependentWatchdog; | 8 | use embassy_stm32::wdg::IndependentWatchdog; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -24,11 +24,11 @@ async fn main(_spawner: Spawner) { | |||
| 24 | loop { | 24 | loop { |
| 25 | info!("high"); | 25 | info!("high"); |
| 26 | led.set_high(); | 26 | led.set_high(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 27 | Timer::after_millis(300).await; |
| 28 | 28 | ||
| 29 | info!("low"); | 29 | info!("low"); |
| 30 | led.set_low(); | 30 | led.set_low(); |
| 31 | Timer::after(Duration::from_millis(300)).await; | 31 | Timer::after_millis(300).await; |
| 32 | 32 | ||
| 33 | // Pet watchdog for 5 iterations and then stop. | 33 | // Pet watchdog for 5 iterations and then stop. |
| 34 | // MCU should restart in 1 second after the last pet. | 34 | // MCU should restart in 1 second after the last pet. |
diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index bc4ed2892..48c59eaf0 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 8 | use embassy_time::{Delay, Duration, Timer}; | 8 | use embassy_time::{Delay, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -29,6 +29,6 @@ async fn main(_spawner: Spawner) { | |||
| 29 | loop { | 29 | loop { |
| 30 | let v = adc.read(&mut pin); | 30 | let v = adc.read(&mut pin); |
| 31 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); | 31 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); |
| 32 | Timer::after(Duration::from_millis(100)).await; | 32 | Timer::after_millis(100).await; |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index b27bee4ce..4bfc5a50d 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32f7/src/bin/can.rs b/examples/stm32f7/src/bin/can.rs index e9650f23a..78b21ceaa 100644 --- a/examples/stm32f7/src/bin/can.rs +++ b/examples/stm32f7/src/bin/can.rs | |||
| @@ -26,7 +26,7 @@ pub async fn send_can_message(tx: &'static mut CanTx<'static, 'static, CAN3>) { | |||
| 26 | loop { | 26 | loop { |
| 27 | let frame = Frame::new_data(unwrap!(StandardId::new(0 as _)), [0]); | 27 | let frame = Frame::new_data(unwrap!(StandardId::new(0 as _)), [0]); |
| 28 | tx.write(&frame).await; | 28 | tx.write(&frame).await; |
| 29 | embassy_time::Timer::after(embassy_time::Duration::from_secs(1)).await; | 29 | embassy_time::Timer::after_secs(1).await; |
| 30 | } | 30 | } |
| 31 | } | 31 | } |
| 32 | 32 | ||
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 7c9ee1590..d50473b9d 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::peripherals::ETH; | |||
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::Timer; |
| 16 | use embedded_io_async::Write; | 16 | use embedded_io_async::Write; |
| 17 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::make_static; | 18 | use static_cell::make_static; |
| @@ -100,7 +100,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 100 | let r = socket.connect(remote_endpoint).await; | 100 | let r = socket.connect(remote_endpoint).await; |
| 101 | if let Err(e) = r { | 101 | if let Err(e) = r { |
| 102 | info!("connect error: {:?}", e); | 102 | info!("connect error: {:?}", e); |
| 103 | Timer::after(Duration::from_secs(1)).await; | 103 | Timer::after_secs(1).await; |
| 104 | continue; | 104 | continue; |
| 105 | } | 105 | } |
| 106 | info!("connected!"); | 106 | info!("connected!"); |
| @@ -111,7 +111,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 111 | info!("write error: {:?}", e); | 111 | info!("write error: {:?}", e); |
| 112 | break; | 112 | break; |
| 113 | } | 113 | } |
| 114 | Timer::after(Duration::from_secs(1)).await; | 114 | Timer::after_secs(1).await; |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 35d3059be..06a94f1c8 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) { | |||
| 16 | const ADDR: u32 = 0x8_0000; // This is the offset into the third region, the absolute address is 4x32K + 128K + 0x8_0000. | 16 | const ADDR: u32 = 0x8_0000; // This is the offset into the third region, the absolute address is 4x32K + 128K + 0x8_0000. |
| 17 | 17 | ||
| 18 | // wait a bit before accessing the flash | 18 | // wait a bit before accessing the flash |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after_millis(300).await; |
| 20 | 20 | ||
| 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region3; | 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank1_region3; |
| 22 | 22 | ||
diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index c409703f5..27ee83aa5 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs | |||
| @@ -6,7 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -17,6 +17,6 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 17 | 17 | ||
| 18 | loop { | 18 | loop { |
| 19 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 20 | Timer::after(Duration::from_secs(1)).await; | 20 | Timer::after_secs(1).await; |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index b27bee4ce..4bfc5a50d 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32g0/src/bin/spi_neopixel.rs b/examples/stm32g0/src/bin/spi_neopixel.rs index ee7aaf33f..214462d0e 100644 --- a/examples/stm32g0/src/bin/spi_neopixel.rs +++ b/examples/stm32g0/src/bin/spi_neopixel.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::dma::word::U5; | |||
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::spi::{Config, Spi}; | 9 | use embassy_stm32::spi::{Config, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | const NR_PIXELS: usize = 15; | 14 | const NR_PIXELS: usize = 15; |
| @@ -96,8 +96,8 @@ async fn main(_spawner: Spawner) { | |||
| 96 | cnt += 1; | 96 | cnt += 1; |
| 97 | // start sending the neopixel bit patters over spi to the neopixel string | 97 | // start sending the neopixel bit patters over spi to the neopixel string |
| 98 | spi.write(&neopixels.bitbuffer).await.ok(); | 98 | spi.write(&neopixels.bitbuffer).await.ok(); |
| 99 | Timer::after(Duration::from_millis(500)).await; | 99 | Timer::after_millis(500).await; |
| 100 | } | 100 | } |
| 101 | Timer::after(Duration::from_millis(1000)).await; | 101 | Timer::after_millis(1000).await; |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs index 30a112b7e..9daf4e4cb 100644 --- a/examples/stm32g4/src/bin/adc.rs +++ b/examples/stm32g4/src/bin/adc.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; |
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | loop { | 36 | loop { |
| 37 | let measured = adc.read(&mut p.PA7); | 37 | let measured = adc.read(&mut p.PA7); |
| 38 | info!("measured: {}", measured); | 38 | info!("measured: {}", measured); |
| 39 | Timer::after(Duration::from_millis(500)).await; | 39 | Timer::after_millis(500).await; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index 8a65b0692..cbeb0dee1 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs index f8159cb53..43242647f 100644 --- a/examples/stm32g4/src/bin/pll.rs +++ b/examples/stm32g4/src/bin/pll.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) { | |||
| 29 | info!("Hello World!"); | 29 | info!("Hello World!"); |
| 30 | 30 | ||
| 31 | loop { | 31 | loop { |
| 32 | Timer::after(Duration::from_millis(1000)).await; | 32 | Timer::after_millis(1000).await; |
| 33 | info!("1s elapsed"); | 33 | info!("1s elapsed"); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 01e9cb476..eed0b6ad7 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::gpio::OutputType; | |||
| 8 | use embassy_stm32::time::khz; | 8 | use embassy_stm32::time::khz; |
| 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 10 | use embassy_stm32::timer::Channel; | 10 | use embassy_stm32::timer::Channel; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -26,12 +26,12 @@ async fn main(_spawner: Spawner) { | |||
| 26 | 26 | ||
| 27 | loop { | 27 | loop { |
| 28 | pwm.set_duty(Channel::Ch1, 0); | 28 | pwm.set_duty(Channel::Ch1, 0); |
| 29 | Timer::after(Duration::from_millis(300)).await; | 29 | Timer::after_millis(300).await; |
| 30 | pwm.set_duty(Channel::Ch1, max / 4); | 30 | pwm.set_duty(Channel::Ch1, max / 4); |
| 31 | Timer::after(Duration::from_millis(300)).await; | 31 | Timer::after_millis(300).await; |
| 32 | pwm.set_duty(Channel::Ch1, max / 2); | 32 | pwm.set_duty(Channel::Ch1, max / 2); |
| 33 | Timer::after(Duration::from_millis(300)).await; | 33 | Timer::after_millis(300).await; |
| 34 | pwm.set_duty(Channel::Ch1, max - 1); | 34 | pwm.set_duty(Channel::Ch1, max - 1); |
| 35 | Timer::after(Duration::from_millis(300)).await; | 35 | Timer::after_millis(300).await; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
diff --git a/examples/stm32h5/src/bin/blinky.rs b/examples/stm32h5/src/bin/blinky.rs index f9bf90d2e..1394f03fa 100644 --- a/examples/stm32h5/src/bin/blinky.rs +++ b/examples/stm32h5/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after_millis(500).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index 2535c6a68..6e40f0ac0 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -15,7 +15,7 @@ use embassy_stm32::rcc::{ | |||
| 15 | use embassy_stm32::rng::Rng; | 15 | use embassy_stm32::rng::Rng; |
| 16 | use embassy_stm32::time::Hertz; | 16 | use embassy_stm32::time::Hertz; |
| 17 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 17 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 18 | use embassy_time::{Duration, Timer}; | 18 | use embassy_time::Timer; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
| 20 | use rand_core::RngCore; | 20 | use rand_core::RngCore; |
| 21 | use static_cell::make_static; | 21 | use static_cell::make_static; |
| @@ -121,7 +121,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 121 | let r = socket.connect(remote_endpoint).await; | 121 | let r = socket.connect(remote_endpoint).await; |
| 122 | if let Err(e) = r { | 122 | if let Err(e) = r { |
| 123 | info!("connect error: {:?}", e); | 123 | info!("connect error: {:?}", e); |
| 124 | Timer::after(Duration::from_secs(3)).await; | 124 | Timer::after_secs(3).await; |
| 125 | continue; | 125 | continue; |
| 126 | } | 126 | } |
| 127 | info!("connected!"); | 127 | info!("connected!"); |
| @@ -131,7 +131,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 131 | info!("write error: {:?}", e); | 131 | info!("write error: {:?}", e); |
| 132 | break; | 132 | break; |
| 133 | } | 133 | } |
| 134 | Timer::after(Duration::from_secs(1)).await; | 134 | Timer::after_secs(1).await; |
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 7859b86db..4a358a35f 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -55,6 +55,6 @@ async fn main(_spawner: Spawner) { | |||
| 55 | info!("vrefint: {}", vrefint); | 55 | info!("vrefint: {}", vrefint); |
| 56 | let measured = adc.read(&mut p.PC0); | 56 | let measured = adc.read(&mut p.PC0); |
| 57 | info!("measured: {}", measured); | 57 | info!("measured: {}", measured); |
| 58 | Timer::after(Duration::from_millis(500)).await; | 58 | Timer::after_millis(500).await; |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 12f08c0fd..a9cab1ff4 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after_millis(500).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 40ef16cfc..8195430b2 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::i2c::I2c; | |||
| 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; | 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; |
| 10 | use embassy_stm32::time::khz; | 10 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; | 11 | use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use ov7725::*; | 13 | use ov7725::*; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| @@ -86,11 +86,11 @@ async fn main(_spawner: Spawner) { | |||
| 86 | loop { | 86 | loop { |
| 87 | defmt::info!("high"); | 87 | defmt::info!("high"); |
| 88 | led.set_high(); | 88 | led.set_high(); |
| 89 | Timer::after(Duration::from_millis(500)).await; | 89 | Timer::after_millis(500).await; |
| 90 | 90 | ||
| 91 | defmt::info!("low"); | 91 | defmt::info!("low"); |
| 92 | led.set_low(); | 92 | led.set_low(); |
| 93 | Timer::after(Duration::from_millis(500)).await; | 93 | Timer::after_millis(500).await; |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -99,7 +99,7 @@ mod ov7725 { | |||
| 99 | 99 | ||
| 100 | use defmt::Format; | 100 | use defmt::Format; |
| 101 | use embassy_stm32::rcc::{Mco, McoInstance}; | 101 | use embassy_stm32::rcc::{Mco, McoInstance}; |
| 102 | use embassy_time::{Duration, Timer}; | 102 | use embassy_time::Timer; |
| 103 | use embedded_hal_async::i2c::I2c; | 103 | use embedded_hal_async::i2c::I2c; |
| 104 | 104 | ||
| 105 | #[repr(u8)] | 105 | #[repr(u8)] |
| @@ -210,9 +210,9 @@ mod ov7725 { | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | pub async fn init(&mut self) -> Result<(), Error<Bus::Error>> { | 212 | pub async fn init(&mut self) -> Result<(), Error<Bus::Error>> { |
| 213 | Timer::after(Duration::from_millis(500)).await; | 213 | Timer::after_millis(500).await; |
| 214 | self.reset_regs().await?; | 214 | self.reset_regs().await?; |
| 215 | Timer::after(Duration::from_millis(500)).await; | 215 | Timer::after_millis(500).await; |
| 216 | self.set_pixformat().await?; | 216 | self.set_pixformat().await?; |
| 217 | self.set_resolution().await?; | 217 | self.set_resolution().await?; |
| 218 | Ok(()) | 218 | Ok(()) |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 6fbf43442..81d9c7347 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::eth::{Ethernet, PacketQueue}; | |||
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use rand_core::RngCore; | 16 | use rand_core::RngCore; |
| 17 | use static_cell::make_static; | 17 | use static_cell::make_static; |
| @@ -118,7 +118,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 118 | let r = socket.connect(remote_endpoint).await; | 118 | let r = socket.connect(remote_endpoint).await; |
| 119 | if let Err(e) = r { | 119 | if let Err(e) = r { |
| 120 | info!("connect error: {:?}", e); | 120 | info!("connect error: {:?}", e); |
| 121 | Timer::after(Duration::from_secs(1)).await; | 121 | Timer::after_secs(1).await; |
| 122 | continue; | 122 | continue; |
| 123 | } | 123 | } |
| 124 | info!("connected!"); | 124 | info!("connected!"); |
| @@ -128,7 +128,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 128 | info!("write error: {:?}", e); | 128 | info!("write error: {:?}", e); |
| 129 | break; | 129 | break; |
| 130 | } | 130 | } |
| 131 | Timer::after(Duration::from_secs(1)).await; | 131 | Timer::after_secs(1).await; |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 09d27cdbd..338137069 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::eth::{Ethernet, PacketQueue}; | |||
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | 16 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; |
| 17 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| @@ -115,7 +115,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 115 | let r = client.connect(addr).await; | 115 | let r = client.connect(addr).await; |
| 116 | if let Err(e) = r { | 116 | if let Err(e) = r { |
| 117 | info!("connect error: {:?}", e); | 117 | info!("connect error: {:?}", e); |
| 118 | Timer::after(Duration::from_secs(1)).await; | 118 | Timer::after_secs(1).await; |
| 119 | continue; | 119 | continue; |
| 120 | } | 120 | } |
| 121 | let mut connection = r.unwrap(); | 121 | let mut connection = r.unwrap(); |
| @@ -126,7 +126,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 126 | info!("write error: {:?}", e); | 126 | info!("write error: {:?}", e); |
| 127 | break; | 127 | break; |
| 128 | } | 128 | } |
| 129 | Timer::after(Duration::from_secs(1)).await; | 129 | Timer::after_secs(1).await; |
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | } | 132 | } |
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index f66df770b..89c0c8a66 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::flash::Flash; | 7 | use embassy_stm32::flash::Flash; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) { | |||
| 16 | const ADDR: u32 = 0; // This is the offset into bank 2, the absolute address is 0x8_0000 | 16 | const ADDR: u32 = 0; // This is the offset into bank 2, the absolute address is 0x8_0000 |
| 17 | 17 | ||
| 18 | // wait a bit before accessing the flash | 18 | // wait a bit before accessing the flash |
| 19 | Timer::after(Duration::from_millis(300)).await; | 19 | Timer::after_millis(300).await; |
| 20 | 20 | ||
| 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank2_region; | 21 | let mut f = Flash::new_blocking(p.FLASH).into_blocking_regions().bank2_region; |
| 22 | 22 | ||
diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 7ae87b02c..cffd47093 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::fmc::Fmc; | 7 | use embassy_stm32::fmc::Fmc; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -212,6 +212,6 @@ async fn main(_spawner: Spawner) { | |||
| 212 | info!("Assertions succeeded."); | 212 | info!("Assertions succeeded."); |
| 213 | 213 | ||
| 214 | loop { | 214 | loop { |
| 215 | Timer::after(Duration::from_millis(1000)).await; | 215 | Timer::after_millis(1000).await; |
| 216 | } | 216 | } |
| 217 | } | 217 | } |
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 5841efb24..0355ac073 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::gpio::Speed; | |||
| 9 | use embassy_stm32::time::{khz, Hertz}; | 9 | use embassy_stm32::time::{khz, Hertz}; |
| 10 | use embassy_stm32::timer::*; | 10 | use embassy_stm32::timer::*; |
| 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; | 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -49,13 +49,13 @@ async fn main(_spawner: Spawner) { | |||
| 49 | 49 | ||
| 50 | loop { | 50 | loop { |
| 51 | pwm.set_duty(Channel::Ch1, 0); | 51 | pwm.set_duty(Channel::Ch1, 0); |
| 52 | Timer::after(Duration::from_millis(300)).await; | 52 | Timer::after_millis(300).await; |
| 53 | pwm.set_duty(Channel::Ch1, max / 4); | 53 | pwm.set_duty(Channel::Ch1, max / 4); |
| 54 | Timer::after(Duration::from_millis(300)).await; | 54 | Timer::after_millis(300).await; |
| 55 | pwm.set_duty(Channel::Ch1, max / 2); | 55 | pwm.set_duty(Channel::Ch1, max / 2); |
| 56 | Timer::after(Duration::from_millis(300)).await; | 56 | Timer::after_millis(300).await; |
| 57 | pwm.set_duty(Channel::Ch1, max - 1); | 57 | pwm.set_duty(Channel::Ch1, max - 1); |
| 58 | Timer::after(Duration::from_millis(300)).await; | 58 | Timer::after_millis(300).await; |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { | 61 | pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index de89aee2f..c023f4584 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; | 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -21,10 +21,10 @@ async fn main(_spawner: Spawner) { | |||
| 21 | loop { | 21 | loop { |
| 22 | info!("high"); | 22 | info!("high"); |
| 23 | led.set_high(); | 23 | led.set_high(); |
| 24 | Timer::after(Duration::from_millis(500)).await; | 24 | Timer::after_millis(500).await; |
| 25 | 25 | ||
| 26 | info!("low"); | 26 | info!("low"); |
| 27 | led.set_low(); | 27 | led.set_low(); |
| 28 | Timer::after(Duration::from_millis(500)).await; | 28 | Timer::after_millis(500).await; |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 37e4c92cc..3bf373c7e 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::time::khz; | |||
| 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 10 | use embassy_stm32::timer::Channel; | 10 | use embassy_stm32::timer::Channel; |
| 11 | use embassy_stm32::Config; | 11 | use embassy_stm32::Config; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -48,12 +48,12 @@ async fn main(_spawner: Spawner) { | |||
| 48 | 48 | ||
| 49 | loop { | 49 | loop { |
| 50 | pwm.set_duty(Channel::Ch1, 0); | 50 | pwm.set_duty(Channel::Ch1, 0); |
| 51 | Timer::after(Duration::from_millis(300)).await; | 51 | Timer::after_millis(300).await; |
| 52 | pwm.set_duty(Channel::Ch1, max / 4); | 52 | pwm.set_duty(Channel::Ch1, max / 4); |
| 53 | Timer::after(Duration::from_millis(300)).await; | 53 | Timer::after_millis(300).await; |
| 54 | pwm.set_duty(Channel::Ch1, max / 2); | 54 | pwm.set_duty(Channel::Ch1, max / 2); |
| 55 | Timer::after(Duration::from_millis(300)).await; | 55 | Timer::after_millis(300).await; |
| 56 | pwm.set_duty(Channel::Ch1, max - 1); | 56 | pwm.set_duty(Channel::Ch1, max - 1); |
| 57 | Timer::after(Duration::from_millis(300)).await; | 57 | Timer::after_millis(300).await; |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
diff --git a/examples/stm32h7/src/bin/rtc.rs b/examples/stm32h7/src/bin/rtc.rs index f2a19af81..78cea9c89 100644 --- a/examples/stm32h7/src/bin/rtc.rs +++ b/examples/stm32h7/src/bin/rtc.rs | |||
| @@ -8,7 +8,7 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_stm32::rcc::LsConfig; | 8 | use embassy_stm32::rcc::LsConfig; |
| 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 10 | use embassy_stm32::Config; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) { | |||
| 30 | rtc.set_datetime(now.into()).expect("datetime not set"); | 30 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 31 | 31 | ||
| 32 | // In reality the delay would be much longer | 32 | // In reality the delay would be much longer |
| 33 | Timer::after(Duration::from_millis(20000)).await; | 33 | Timer::after_millis(20000).await; |
| 34 | 34 | ||
| 35 | let then: NaiveDateTime = rtc.now().unwrap().into(); | 35 | let then: NaiveDateTime = rtc.now().unwrap().into(); |
| 36 | info!("Got RTC! {:?}", then.timestamp()); | 36 | info!("Got RTC! {:?}", then.timestamp()); |
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index 6d7c168d5..b5f583289 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs | |||
| @@ -6,7 +6,7 @@ use defmt::{info, unwrap}; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 8 | use embassy_sync::signal::Signal; | 8 | use embassy_sync::signal::Signal; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | static SIGNAL: Signal<CriticalSectionRawMutex, u32> = Signal::new(); | 12 | static SIGNAL: Signal<CriticalSectionRawMutex, u32> = Signal::new(); |
| @@ -16,7 +16,7 @@ async fn my_sending_task() { | |||
| 16 | let mut counter: u32 = 0; | 16 | let mut counter: u32 = 0; |
| 17 | 17 | ||
| 18 | loop { | 18 | loop { |
| 19 | Timer::after(Duration::from_secs(1)).await; | 19 | Timer::after_secs(1).await; |
| 20 | 20 | ||
| 21 | SIGNAL.signal(counter); | 21 | SIGNAL.signal(counter); |
| 22 | 22 | ||
diff --git a/examples/stm32h7/src/bin/wdg.rs b/examples/stm32h7/src/bin/wdg.rs index 9181dfd67..76fd9dfc0 100644 --- a/examples/stm32h7/src/bin/wdg.rs +++ b/examples/stm32h7/src/bin/wdg.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::wdg::IndependentWatchdog; | 7 | use embassy_stm32::wdg::IndependentWatchdog; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) { | |||
| 18 | wdg.unleash(); | 18 | wdg.unleash(); |
| 19 | 19 | ||
| 20 | loop { | 20 | loop { |
| 21 | Timer::after(Duration::from_secs(1)).await; | 21 | Timer::after_secs(1).await; |
| 22 | wdg.pet(); | 22 | wdg.pet(); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 07fad07c6..ea40bfc48 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs index 900848fd8..987cdba01 100644 --- a/examples/stm32l0/src/bin/lora_cad.rs +++ b/examples/stm32l0/src/bin/lora_cad.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::exti::{Channel, ExtiInput}; | |||
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; |
| 13 | use embassy_stm32::spi; | 13 | use embassy_stm32::spi; |
| 14 | use embassy_stm32::time::khz; | 14 | use embassy_stm32::time::khz; |
| 15 | use embassy_time::{Delay, Duration, Timer}; | 15 | use embassy_time::{Delay, Timer}; |
| 16 | use lora_phy::mod_params::*; | 16 | use lora_phy::mod_params::*; |
| 17 | use lora_phy::sx1276_7_8_9::SX1276_7_8_9; | 17 | use lora_phy::sx1276_7_8_9::SX1276_7_8_9; |
| 18 | use lora_phy::LoRa; | 18 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); | 55 | let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mdltn_params = { | 61 | let mdltn_params = { |
| @@ -89,7 +89,7 @@ async fn main(_spawner: Spawner) { | |||
| 89 | info!("cad successful without activity detected") | 89 | info!("cad successful without activity detected") |
| 90 | } | 90 | } |
| 91 | debug_indicator.set_high(); | 91 | debug_indicator.set_high(); |
| 92 | Timer::after(Duration::from_secs(5)).await; | 92 | Timer::after_secs(5).await; |
| 93 | debug_indicator.set_low(); | 93 | debug_indicator.set_low(); |
| 94 | } | 94 | } |
| 95 | Err(err) => info!("cad unsuccessful = {}", err), | 95 | Err(err) => info!("cad unsuccessful = {}", err), |
diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs index edd14bb81..06e2744a4 100644 --- a/examples/stm32l0/src/bin/lora_p2p_receive.rs +++ b/examples/stm32l0/src/bin/lora_p2p_receive.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::exti::{Channel, ExtiInput}; | |||
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; |
| 13 | use embassy_stm32::spi; | 13 | use embassy_stm32::spi; |
| 14 | use embassy_stm32::time::khz; | 14 | use embassy_stm32::time::khz; |
| 15 | use embassy_time::{Delay, Duration, Timer}; | 15 | use embassy_time::{Delay, Timer}; |
| 16 | use lora_phy::mod_params::*; | 16 | use lora_phy::mod_params::*; |
| 17 | use lora_phy::sx1276_7_8_9::SX1276_7_8_9; | 17 | use lora_phy::sx1276_7_8_9::SX1276_7_8_9; |
| 18 | use lora_phy::LoRa; | 18 | use lora_phy::LoRa; |
| @@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) { | |||
| 55 | let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); | 55 | let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); |
| 56 | 56 | ||
| 57 | start_indicator.set_high(); | 57 | start_indicator.set_high(); |
| 58 | Timer::after(Duration::from_secs(5)).await; | 58 | Timer::after_secs(5).await; |
| 59 | start_indicator.set_low(); | 59 | start_indicator.set_low(); |
| 60 | 60 | ||
| 61 | let mut receiving_buffer = [00u8; 100]; | 61 | let mut receiving_buffer = [00u8; 100]; |
| @@ -107,7 +107,7 @@ async fn main(_spawner: Spawner) { | |||
| 107 | { | 107 | { |
| 108 | info!("rx successful"); | 108 | info!("rx successful"); |
| 109 | debug_indicator.set_high(); | 109 | debug_indicator.set_high(); |
| 110 | Timer::after(Duration::from_secs(5)).await; | 110 | Timer::after_secs(5).await; |
| 111 | debug_indicator.set_low(); | 111 | debug_indicator.set_low(); |
| 112 | } else { | 112 | } else { |
| 113 | info!("rx unknown packet"); | 113 | info!("rx unknown packet"); |
diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index edc17304a..29c7e0dc7 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs | |||
| @@ -7,21 +7,21 @@ use cortex_m_rt::entry; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::raw::TaskStorage; | 8 | use embassy_executor::raw::TaskStorage; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | async fn run1() { | 14 | async fn run1() { |
| 15 | loop { | 15 | loop { |
| 16 | info!("BIG INFREQUENT TICK"); | 16 | info!("BIG INFREQUENT TICK"); |
| 17 | Timer::after(Duration::from_ticks(64000)).await; | 17 | Timer::after_ticks(64000).await; |
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | async fn run2() { | 21 | async fn run2() { |
| 22 | loop { | 22 | loop { |
| 23 | info!("tick"); | 23 | info!("tick"); |
| 24 | Timer::after(Duration::from_ticks(13000)).await; | 24 | Timer::after_ticks(13000).await; |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 8a345d235..06f732eb7 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(1000)).await; | 21 | Timer::after_millis(1000).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(1000)).await; | 25 | Timer::after_millis(1000).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 033292fff..6202fe2f7 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -17,8 +17,8 @@ async fn main(_spawner: Spawner) { | |||
| 17 | 17 | ||
| 18 | loop { | 18 | loop { |
| 19 | led.set_high(); | 19 | led.set_high(); |
| 20 | Timer::after(Duration::from_millis(300)).await; | 20 | Timer::after_millis(300).await; |
| 21 | led.set_low(); | 21 | led.set_low(); |
| 22 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after_millis(300).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
diff --git a/examples/stm32l4/src/bin/mco.rs b/examples/stm32l4/src/bin/mco.rs index 8d35af781..2833bb636 100644 --- a/examples/stm32l4/src/bin/mco.rs +++ b/examples/stm32l4/src/bin/mco.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::rcc::{Mco, McoPrescaler, McoSource}; | 8 | use embassy_stm32::rcc::{Mco, McoPrescaler, McoSource}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -20,8 +20,8 @@ async fn main(_spawner: Spawner) { | |||
| 20 | 20 | ||
| 21 | loop { | 21 | loop { |
| 22 | led.set_high(); | 22 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 23 | Timer::after_millis(300).await; |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs index 33efc76b3..f5d46e95f 100644 --- a/examples/stm32l4/src/bin/rtc.rs +++ b/examples/stm32l4/src/bin/rtc.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::rcc::{ClockSrc, LsConfig, PLLSource, PllMul, PllPreDiv, PllRD | |||
| 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::Config; | 11 | use embassy_stm32::Config; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -39,7 +39,7 @@ async fn main(_spawner: Spawner) { | |||
| 39 | rtc.set_datetime(now.into()).expect("datetime not set"); | 39 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 40 | 40 | ||
| 41 | // In reality the delay would be much longer | 41 | // In reality the delay would be much longer |
| 42 | Timer::after(Duration::from_millis(20000)).await; | 42 | Timer::after_millis(20000).await; |
| 43 | 43 | ||
| 44 | let then: NaiveDateTime = rtc.now().unwrap().into(); | 44 | let then: NaiveDateTime = rtc.now().unwrap().into(); |
| 45 | info!("Got RTC! {:?}", then.timestamp()); | 45 | info!("Got RTC! {:?}", then.timestamp()); |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 7193d1f1f..e2ac22d09 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -306,7 +306,7 @@ async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, periphera | |||
| 306 | 306 | ||
| 307 | loop { | 307 | loop { |
| 308 | led.set_low(); | 308 | led.set_low(); |
| 309 | match select(temp_sens.read_temp(), Timer::after(Duration::from_millis(500))).await { | 309 | match select(temp_sens.read_temp(), Timer::after_millis(500)).await { |
| 310 | Either::First(i2c_ret) => match i2c_ret { | 310 | Either::First(i2c_ret) => match i2c_ret { |
| 311 | Ok(value) => { | 311 | Ok(value) => { |
| 312 | led.set_high(); | 312 | led.set_high(); |
| @@ -424,7 +424,7 @@ where | |||
| 424 | // Start: One shot | 424 | // Start: One shot |
| 425 | let cfg = 0b01 << 5; | 425 | let cfg = 0b01 << 5; |
| 426 | self.write_cfg(cfg).await?; | 426 | self.write_cfg(cfg).await?; |
| 427 | Timer::after(Duration::from_millis(250)).await; | 427 | Timer::after_millis(250).await; |
| 428 | self.bus | 428 | self.bus |
| 429 | .write_read(self.addr, &[Registers::Temp_MSB as u8], &mut buffer) | 429 | .write_read(self.addr, &[Registers::Temp_MSB as u8], &mut buffer) |
| 430 | .await | 430 | .await |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index db6a9c76f..0d06c94a2 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs | |||
| @@ -8,7 +8,7 @@ use embassy_futures::join::join; | |||
| 8 | use embassy_stm32::rcc::*; | 8 | use embassy_stm32::rcc::*; |
| 9 | use embassy_stm32::usb::Driver; | 9 | use embassy_stm32::usb::Driver; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 10 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 12 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 13 | use embassy_usb::control::OutResponse; | 13 | use embassy_usb::control::OutResponse; |
| 14 | use embassy_usb::Builder; | 14 | use embassy_usb::Builder; |
| @@ -76,7 +76,7 @@ async fn main(_spawner: Spawner) { | |||
| 76 | let hid_fut = async { | 76 | let hid_fut = async { |
| 77 | let mut y: i8 = 5; | 77 | let mut y: i8 = 5; |
| 78 | loop { | 78 | loop { |
| 79 | Timer::after(Duration::from_millis(500)).await; | 79 | Timer::after_millis(500).await; |
| 80 | 80 | ||
| 81 | y = -y; | 81 | y = -y; |
| 82 | let report = MouseReport { | 82 | let report = MouseReport { |
diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 976fb0b9a..4b44cb12b 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 18 | loop { | 18 | loop { |
| 19 | defmt::info!("on!"); | 19 | defmt::info!("on!"); |
| 20 | led.set_low(); | 20 | led.set_low(); |
| 21 | Timer::after(Duration::from_millis(200)).await; | 21 | Timer::after_millis(200).await; |
| 22 | 22 | ||
| 23 | defmt::info!("off!"); | 23 | defmt::info!("off!"); |
| 24 | led.set_high(); | 24 | led.set_high(); |
| 25 | Timer::after(Duration::from_millis(200)).await; | 25 | Timer::after_millis(200).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index f9bf90d2e..1394f03fa 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after_millis(500).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs index 2f53f5df8..9d0e0070c 100644 --- a/examples/stm32wb/src/bin/tl_mbox.rs +++ b/examples/stm32wb/src/bin/tl_mbox.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::bind_interrupts; | |||
| 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 9 | use embassy_stm32::rcc::WPAN_DEFAULT; | 9 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 10 | use embassy_stm32_wpan::TlMbox; | 10 | use embassy_stm32_wpan::TlMbox; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs{ | 14 | bind_interrupts!(struct Irqs{ |
| @@ -71,7 +71,7 @@ async fn main(_spawner: Spawner) { | |||
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | Timer::after(Duration::from_millis(50)).await; | 74 | Timer::after_millis(50).await; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | info!("Test OK"); | 77 | info!("Test OK"); |
diff --git a/examples/stm32wba/src/bin/blinky.rs b/examples/stm32wba/src/bin/blinky.rs index 530746296..6b9635e66 100644 --- a/examples/stm32wba/src/bin/blinky.rs +++ b/examples/stm32wba/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after_millis(500).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 6af5099ce..5bd5745f0 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(500)).await; | 21 | Timer::after_millis(500).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after_millis(500).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs index 19b0d8531..be33f39c1 100644 --- a/examples/stm32wl/src/bin/lora_p2p_receive.rs +++ b/examples/stm32wl/src/bin/lora_p2p_receive.rs | |||
| @@ -11,7 +11,7 @@ use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; | |||
| 11 | use embassy_stm32::bind_interrupts; | 11 | use embassy_stm32::bind_interrupts; |
| 12 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; |
| 13 | use embassy_stm32::spi::Spi; | 13 | use embassy_stm32::spi::Spi; |
| 14 | use embassy_time::{Delay, Duration, Timer}; | 14 | use embassy_time::{Delay, Timer}; |
| 15 | use lora_phy::mod_params::*; | 15 | use lora_phy::mod_params::*; |
| 16 | use lora_phy::sx1261_2::SX1261_2; | 16 | use lora_phy::sx1261_2::SX1261_2; |
| 17 | use lora_phy::LoRa; | 17 | use lora_phy::LoRa; |
| @@ -51,7 +51,7 @@ async fn main(_spawner: Spawner) { | |||
| 51 | let mut start_indicator = Output::new(p.PB15, Level::Low, Speed::Low); | 51 | let mut start_indicator = Output::new(p.PB15, Level::Low, Speed::Low); |
| 52 | 52 | ||
| 53 | start_indicator.set_high(); | 53 | start_indicator.set_high(); |
| 54 | Timer::after(Duration::from_secs(5)).await; | 54 | Timer::after_secs(5).await; |
| 55 | start_indicator.set_low(); | 55 | start_indicator.set_low(); |
| 56 | 56 | ||
| 57 | let mut receiving_buffer = [00u8; 100]; | 57 | let mut receiving_buffer = [00u8; 100]; |
| @@ -103,7 +103,7 @@ async fn main(_spawner: Spawner) { | |||
| 103 | { | 103 | { |
| 104 | info!("rx successful"); | 104 | info!("rx successful"); |
| 105 | debug_indicator.set_high(); | 105 | debug_indicator.set_high(); |
| 106 | Timer::after(Duration::from_secs(5)).await; | 106 | Timer::after_secs(5).await; |
| 107 | debug_indicator.set_low(); | 107 | debug_indicator.set_low(); |
| 108 | } else { | 108 | } else { |
| 109 | info!("rx unknown packet"); | 109 | info!("rx unknown packet"); |
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs index a6bb28013..9ebb05f22 100644 --- a/examples/stm32wl/src/bin/rtc.rs +++ b/examples/stm32wl/src/bin/rtc.rs | |||
| @@ -8,7 +8,7 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_stm32::rcc::{ClockSrc, LsConfig}; | 8 | use embassy_stm32::rcc::{ClockSrc, LsConfig}; |
| 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 10 | use embassy_stm32::Config; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | rtc.set_datetime(now.into()).expect("datetime not set"); | 32 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 33 | 33 | ||
| 34 | // In reality the delay would be much longer | 34 | // In reality the delay would be much longer |
| 35 | Timer::after(Duration::from_millis(20000)).await; | 35 | Timer::after_millis(20000).await; |
| 36 | 36 | ||
| 37 | let then: NaiveDateTime = rtc.now().unwrap().into(); | 37 | let then: NaiveDateTime = rtc.now().unwrap().into(); |
| 38 | info!("Got RTC! {:?}", then.timestamp()); | 38 | info!("Got RTC! {:?}", then.timestamp()); |
diff --git a/examples/wasm/src/lib.rs b/examples/wasm/src/lib.rs index edfe8bafc..1141096fb 100644 --- a/examples/wasm/src/lib.rs +++ b/examples/wasm/src/lib.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![feature(type_alias_impl_trait)] | 1 | #![feature(type_alias_impl_trait)] |
| 2 | 2 | ||
| 3 | use embassy_executor::Spawner; | 3 | use embassy_executor::Spawner; |
| 4 | use embassy_time::{Duration, Timer}; | 4 | use embassy_time::Timer; |
| 5 | 5 | ||
| 6 | #[embassy_executor::task] | 6 | #[embassy_executor::task] |
| 7 | async fn ticker() { | 7 | async fn ticker() { |
| @@ -19,7 +19,7 @@ async fn ticker() { | |||
| 19 | log::info!("tick {}", counter); | 19 | log::info!("tick {}", counter); |
| 20 | counter += 1; | 20 | counter += 1; |
| 21 | 21 | ||
| 22 | Timer::after(Duration::from_secs(1)).await; | 22 | Timer::after_secs(1).await; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 | ||
diff --git a/tests/nrf/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs index 8abeae6d4..65b9d76d1 100644 --- a/tests/nrf/src/bin/buffered_uart_spam.rs +++ b/tests/nrf/src/bin/buffered_uart_spam.rs | |||
| @@ -13,7 +13,7 @@ use embassy_nrf::gpio::{Level, Output, OutputDrive}; | |||
| 13 | use embassy_nrf::ppi::{Event, Ppi, Task}; | 13 | use embassy_nrf::ppi::{Event, Ppi, Task}; |
| 14 | use embassy_nrf::uarte::Uarte; | 14 | use embassy_nrf::uarte::Uarte; |
| 15 | use embassy_nrf::{bind_interrupts, pac, peripherals, uarte}; | 15 | use embassy_nrf::{bind_interrupts, pac, peripherals, uarte}; |
| 16 | use embassy_time::{Duration, Timer}; | 16 | use embassy_time::Timer; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| 19 | bind_interrupts!(struct Irqs { | 19 | bind_interrupts!(struct Irqs { |
| @@ -50,7 +50,7 @@ async fn main(_spawner: Spawner) { | |||
| 50 | info!("uarte initialized!"); | 50 | info!("uarte initialized!"); |
| 51 | 51 | ||
| 52 | // uarte needs some quiet time to start rxing properly. | 52 | // uarte needs some quiet time to start rxing properly. |
| 53 | Timer::after(Duration::from_millis(10)).await; | 53 | Timer::after_millis(10).await; |
| 54 | 54 | ||
| 55 | // Tx spam in a loop. | 55 | // Tx spam in a loop. |
| 56 | const NSPAM: usize = 17; | 56 | const NSPAM: usize = 17; |
diff --git a/tests/nrf/src/bin/timer.rs b/tests/nrf/src/bin/timer.rs index c00f35fd1..5723acb01 100644 --- a/tests/nrf/src/bin/timer.rs +++ b/tests/nrf/src/bin/timer.rs | |||
| @@ -5,7 +5,7 @@ teleprobe_meta::target!(b"nrf52840-dk"); | |||
| 5 | 5 | ||
| 6 | use defmt::{assert, info}; | 6 | use defmt::{assert, info}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_time::{Duration, Instant, Timer}; | 8 | use embassy_time::{Instant, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let start = Instant::now(); | 16 | let start = Instant::now(); |
| 17 | Timer::after(Duration::from_millis(100)).await; | 17 | Timer::after_millis(100).await; |
| 18 | let end = Instant::now(); | 18 | let end = Instant::now(); |
| 19 | let ms = (end - start).as_millis(); | 19 | let ms = (end - start).as_millis(); |
| 20 | info!("slept for {} ms", ms); | 20 | info!("slept for {} ms", ms); |
diff --git a/tests/perf-client/src/lib.rs b/tests/perf-client/src/lib.rs index d709c7bd0..54762379a 100644 --- a/tests/perf-client/src/lib.rs +++ b/tests/perf-client/src/lib.rs | |||
| @@ -16,7 +16,7 @@ pub struct Expected { | |||
| 16 | pub async fn run<D: Driver>(stack: &Stack<D>, expected: Expected) { | 16 | pub async fn run<D: Driver>(stack: &Stack<D>, expected: Expected) { |
| 17 | info!("Waiting for DHCP up..."); | 17 | info!("Waiting for DHCP up..."); |
| 18 | while stack.config_v4().is_none() { | 18 | while stack.config_v4().is_none() { |
| 19 | Timer::after(Duration::from_millis(100)).await; | 19 | Timer::after_millis(100).await; |
| 20 | } | 20 | } |
| 21 | info!("IP addressing up!"); | 21 | info!("IP addressing up!"); |
| 22 | 22 | ||
diff --git a/tests/rp/src/bin/bootsel.rs b/tests/rp/src/bin/bootsel.rs index df1ed8d2e..4678775eb 100644 --- a/tests/rp/src/bin/bootsel.rs +++ b/tests/rp/src/bin/bootsel.rs | |||
| @@ -5,7 +5,7 @@ teleprobe_meta::target!(b"rpi-pico"); | |||
| 5 | 5 | ||
| 6 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -17,7 +17,7 @@ async fn main(_spawner: Spawner) { | |||
| 17 | // defmt RTT header. Reading that header might touch flash memory, which | 17 | // defmt RTT header. Reading that header might touch flash memory, which |
| 18 | // interferes with flash write operations. | 18 | // interferes with flash write operations. |
| 19 | // https://github.com/knurling-rs/defmt/pull/683 | 19 | // https://github.com/knurling-rs/defmt/pull/683 |
| 20 | Timer::after(Duration::from_millis(10)).await; | 20 | Timer::after_millis(10).await; |
| 21 | 21 | ||
| 22 | assert_eq!(p.BOOTSEL.is_pressed(), false); | 22 | assert_eq!(p.BOOTSEL.is_pressed(), false); |
| 23 | 23 | ||
diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs index 75be2bf06..2d85135de 100644 --- a/tests/rp/src/bin/flash.rs +++ b/tests/rp/src/bin/flash.rs | |||
| @@ -6,7 +6,7 @@ teleprobe_meta::target!(b"rpi-pico"); | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; | 8 | use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | const ADDR_OFFSET: u32 = 0x8000; | 12 | const ADDR_OFFSET: u32 = 0x8000; |
| @@ -20,7 +20,7 @@ async fn main(_spawner: Spawner) { | |||
| 20 | // defmt RTT header. Reading that header might touch flash memory, which | 20 | // defmt RTT header. Reading that header might touch flash memory, which |
| 21 | // interferes with flash write operations. | 21 | // interferes with flash write operations. |
| 22 | // https://github.com/knurling-rs/defmt/pull/683 | 22 | // https://github.com/knurling-rs/defmt/pull/683 |
| 23 | Timer::after(Duration::from_millis(10)).await; | 23 | Timer::after_millis(10).await; |
| 24 | 24 | ||
| 25 | let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); | 25 | let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); |
| 26 | 26 | ||
diff --git a/tests/rp/src/bin/float.rs b/tests/rp/src/bin/float.rs index 2874aa910..1e89c10f8 100644 --- a/tests/rp/src/bin/float.rs +++ b/tests/rp/src/bin/float.rs | |||
| @@ -6,7 +6,7 @@ teleprobe_meta::target!(b"rpi-pico"); | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::pac; | 8 | use embassy_rp::pac; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -40,7 +40,7 @@ async fn main(_spawner: Spawner) { | |||
| 40 | rad_d + PI_D, | 40 | rad_d + PI_D, |
| 41 | rad_d % PI_D | 41 | rad_d % PI_D |
| 42 | ); | 42 | ); |
| 43 | Timer::after(Duration::from_millis(10)).await; | 43 | Timer::after_millis(10).await; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | let rom_accesses = pac::BUSCTRL.perfctr(0).read().perfctr(); | 46 | let rom_accesses = pac::BUSCTRL.perfctr(0).read().perfctr(); |
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 60c65b7a0..26582f74b 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs | |||
| @@ -27,7 +27,7 @@ async fn main(_spawner: Spawner) { | |||
| 27 | 27 | ||
| 28 | let set_high_future = async { | 28 | let set_high_future = async { |
| 29 | // Allow time for wait_for_high_future to await wait_for_high(). | 29 | // Allow time for wait_for_high_future to await wait_for_high(). |
| 30 | Timer::after(Duration::from_millis(10)).await; | 30 | Timer::after_millis(10).await; |
| 31 | output.set_high(); | 31 | output.set_high(); |
| 32 | }; | 32 | }; |
| 33 | let wait_for_high_future = async { | 33 | let wait_for_high_future = async { |
| @@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) { | |||
| 47 | assert!(input.is_high(), "input was expected to be high"); | 47 | assert!(input.is_high(), "input was expected to be high"); |
| 48 | 48 | ||
| 49 | let set_low_future = async { | 49 | let set_low_future = async { |
| 50 | Timer::after(Duration::from_millis(10)).await; | 50 | Timer::after_millis(10).await; |
| 51 | output.set_low(); | 51 | output.set_low(); |
| 52 | }; | 52 | }; |
| 53 | let wait_for_low_future = async { | 53 | let wait_for_low_future = async { |
| @@ -67,7 +67,7 @@ async fn main(_spawner: Spawner) { | |||
| 67 | assert!(input.is_low(), "input was expected to be low"); | 67 | assert!(input.is_low(), "input was expected to be low"); |
| 68 | 68 | ||
| 69 | let set_high_future = async { | 69 | let set_high_future = async { |
| 70 | Timer::after(Duration::from_millis(10)).await; | 70 | Timer::after_millis(10).await; |
| 71 | output.set_high(); | 71 | output.set_high(); |
| 72 | }; | 72 | }; |
| 73 | let wait_for_rising_edge_future = async { | 73 | let wait_for_rising_edge_future = async { |
| @@ -87,7 +87,7 @@ async fn main(_spawner: Spawner) { | |||
| 87 | assert!(input.is_high(), "input was expected to be high"); | 87 | assert!(input.is_high(), "input was expected to be high"); |
| 88 | 88 | ||
| 89 | let set_low_future = async { | 89 | let set_low_future = async { |
| 90 | Timer::after(Duration::from_millis(10)).await; | 90 | Timer::after_millis(10).await; |
| 91 | output.set_low(); | 91 | output.set_low(); |
| 92 | }; | 92 | }; |
| 93 | let wait_for_falling_edge_future = async { | 93 | let wait_for_falling_edge_future = async { |
| @@ -107,7 +107,7 @@ async fn main(_spawner: Spawner) { | |||
| 107 | assert!(input.is_high(), "input was expected to be high"); | 107 | assert!(input.is_high(), "input was expected to be high"); |
| 108 | 108 | ||
| 109 | let set_low_future = async { | 109 | let set_low_future = async { |
| 110 | Timer::after(Duration::from_millis(10)).await; | 110 | Timer::after_millis(10).await; |
| 111 | output.set_low(); | 111 | output.set_low(); |
| 112 | }; | 112 | }; |
| 113 | let wait_for_any_edge_future = async { | 113 | let wait_for_any_edge_future = async { |
| @@ -127,7 +127,7 @@ async fn main(_spawner: Spawner) { | |||
| 127 | assert!(input.is_low(), "input was expected to be low"); | 127 | assert!(input.is_low(), "input was expected to be low"); |
| 128 | 128 | ||
| 129 | let set_high_future = async { | 129 | let set_high_future = async { |
| 130 | Timer::after(Duration::from_millis(10)).await; | 130 | Timer::after_millis(10).await; |
| 131 | output.set_high(); | 131 | output.set_high(); |
| 132 | }; | 132 | }; |
| 133 | let wait_for_any_edge_future = async { | 133 | let wait_for_any_edge_future = async { |
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index 8c02b8441..8c9db1158 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs | |||
| @@ -7,7 +7,7 @@ use defmt::{assert, assert_eq, assert_ne, *}; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 8 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 9 | use embassy_rp::pwm::{Config, InputMode, Pwm}; | 9 | use embassy_rp::pwm::{Config, InputMode, Pwm}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -48,13 +48,13 @@ async fn main(_spawner: Spawner) { | |||
| 48 | { | 48 | { |
| 49 | let pin1 = Input::new(&mut p9, Pull::None); | 49 | let pin1 = Input::new(&mut p9, Pull::None); |
| 50 | let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); | 50 | let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); |
| 51 | Timer::after(Duration::from_millis(1)).await; | 51 | Timer::after_millis(1).await; |
| 52 | assert_eq!(pin1.is_low(), invert_a); | 52 | assert_eq!(pin1.is_low(), invert_a); |
| 53 | Timer::after(Duration::from_millis(5)).await; | 53 | Timer::after_millis(5).await; |
| 54 | assert_eq!(pin1.is_high(), invert_a); | 54 | assert_eq!(pin1.is_high(), invert_a); |
| 55 | Timer::after(Duration::from_millis(5)).await; | 55 | Timer::after_millis(5).await; |
| 56 | assert_eq!(pin1.is_low(), invert_a); | 56 | assert_eq!(pin1.is_low(), invert_a); |
| 57 | Timer::after(Duration::from_millis(5)).await; | 57 | Timer::after_millis(5).await; |
| 58 | assert_eq!(pin1.is_high(), invert_a); | 58 | assert_eq!(pin1.is_high(), invert_a); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -62,13 +62,13 @@ async fn main(_spawner: Spawner) { | |||
| 62 | { | 62 | { |
| 63 | let pin2 = Input::new(&mut p11, Pull::None); | 63 | let pin2 = Input::new(&mut p11, Pull::None); |
| 64 | let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); | 64 | let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); |
| 65 | Timer::after(Duration::from_millis(1)).await; | 65 | Timer::after_millis(1).await; |
| 66 | assert_ne!(pin2.is_low(), invert_a); | 66 | assert_ne!(pin2.is_low(), invert_a); |
| 67 | Timer::after(Duration::from_millis(5)).await; | 67 | Timer::after_millis(5).await; |
| 68 | assert_ne!(pin2.is_high(), invert_a); | 68 | assert_ne!(pin2.is_high(), invert_a); |
| 69 | Timer::after(Duration::from_millis(5)).await; | 69 | Timer::after_millis(5).await; |
| 70 | assert_ne!(pin2.is_low(), invert_a); | 70 | assert_ne!(pin2.is_low(), invert_a); |
| 71 | Timer::after(Duration::from_millis(5)).await; | 71 | Timer::after_millis(5).await; |
| 72 | assert_ne!(pin2.is_high(), invert_a); | 72 | assert_ne!(pin2.is_high(), invert_a); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| @@ -77,16 +77,16 @@ async fn main(_spawner: Spawner) { | |||
| 77 | let pin1 = Input::new(&mut p9, Pull::None); | 77 | let pin1 = Input::new(&mut p9, Pull::None); |
| 78 | let pin2 = Input::new(&mut p11, Pull::None); | 78 | let pin2 = Input::new(&mut p11, Pull::None); |
| 79 | let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); | 79 | let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); |
| 80 | Timer::after(Duration::from_millis(1)).await; | 80 | Timer::after_millis(1).await; |
| 81 | assert_eq!(pin1.is_low(), invert_a); | 81 | assert_eq!(pin1.is_low(), invert_a); |
| 82 | assert_ne!(pin2.is_low(), invert_a); | 82 | assert_ne!(pin2.is_low(), invert_a); |
| 83 | Timer::after(Duration::from_millis(5)).await; | 83 | Timer::after_millis(5).await; |
| 84 | assert_eq!(pin1.is_high(), invert_a); | 84 | assert_eq!(pin1.is_high(), invert_a); |
| 85 | assert_ne!(pin2.is_high(), invert_a); | 85 | assert_ne!(pin2.is_high(), invert_a); |
| 86 | Timer::after(Duration::from_millis(5)).await; | 86 | Timer::after_millis(5).await; |
| 87 | assert_eq!(pin1.is_low(), invert_a); | 87 | assert_eq!(pin1.is_low(), invert_a); |
| 88 | assert_ne!(pin2.is_low(), invert_a); | 88 | assert_ne!(pin2.is_low(), invert_a); |
| 89 | Timer::after(Duration::from_millis(5)).await; | 89 | Timer::after_millis(5).await; |
| 90 | assert_eq!(pin1.is_high(), invert_a); | 90 | assert_eq!(pin1.is_high(), invert_a); |
| 91 | assert_ne!(pin2.is_high(), invert_a); | 91 | assert_ne!(pin2.is_high(), invert_a); |
| 92 | } | 92 | } |
| @@ -97,14 +97,14 @@ async fn main(_spawner: Spawner) { | |||
| 97 | let mut pin2 = Output::new(&mut p11, Level::Low); | 97 | let mut pin2 = Output::new(&mut p11, Level::Low); |
| 98 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::Level, cfg.clone()); | 98 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::Level, cfg.clone()); |
| 99 | assert_eq!(pwm.counter(), 0); | 99 | assert_eq!(pwm.counter(), 0); |
| 100 | Timer::after(Duration::from_millis(5)).await; | 100 | Timer::after_millis(5).await; |
| 101 | assert_eq!(pwm.counter(), 0); | 101 | assert_eq!(pwm.counter(), 0); |
| 102 | pin2.set_high(); | 102 | pin2.set_high(); |
| 103 | Timer::after(Duration::from_millis(1)).await; | 103 | Timer::after_millis(1).await; |
| 104 | pin2.set_low(); | 104 | pin2.set_low(); |
| 105 | let ctr = pwm.counter(); | 105 | let ctr = pwm.counter(); |
| 106 | assert!(ctr >= 1000); | 106 | assert!(ctr >= 1000); |
| 107 | Timer::after(Duration::from_millis(1)).await; | 107 | Timer::after_millis(1).await; |
| 108 | assert_eq!(pwm.counter(), ctr); | 108 | assert_eq!(pwm.counter(), ctr); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| @@ -113,13 +113,13 @@ async fn main(_spawner: Spawner) { | |||
| 113 | let mut pin2 = Output::new(&mut p11, Level::Low); | 113 | let mut pin2 = Output::new(&mut p11, Level::Low); |
| 114 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::RisingEdge, cfg.clone()); | 114 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::RisingEdge, cfg.clone()); |
| 115 | assert_eq!(pwm.counter(), 0); | 115 | assert_eq!(pwm.counter(), 0); |
| 116 | Timer::after(Duration::from_millis(5)).await; | 116 | Timer::after_millis(5).await; |
| 117 | assert_eq!(pwm.counter(), 0); | 117 | assert_eq!(pwm.counter(), 0); |
| 118 | pin2.set_high(); | 118 | pin2.set_high(); |
| 119 | Timer::after(Duration::from_millis(1)).await; | 119 | Timer::after_millis(1).await; |
| 120 | pin2.set_low(); | 120 | pin2.set_low(); |
| 121 | assert_eq!(pwm.counter(), 1); | 121 | assert_eq!(pwm.counter(), 1); |
| 122 | Timer::after(Duration::from_millis(1)).await; | 122 | Timer::after_millis(1).await; |
| 123 | assert_eq!(pwm.counter(), 1); | 123 | assert_eq!(pwm.counter(), 1); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| @@ -128,13 +128,13 @@ async fn main(_spawner: Spawner) { | |||
| 128 | let mut pin2 = Output::new(&mut p11, Level::High); | 128 | let mut pin2 = Output::new(&mut p11, Level::High); |
| 129 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::FallingEdge, cfg.clone()); | 129 | let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::FallingEdge, cfg.clone()); |
| 130 | assert_eq!(pwm.counter(), 0); | 130 | assert_eq!(pwm.counter(), 0); |
| 131 | Timer::after(Duration::from_millis(5)).await; | 131 | Timer::after_millis(5).await; |
| 132 | assert_eq!(pwm.counter(), 0); | 132 | assert_eq!(pwm.counter(), 0); |
| 133 | pin2.set_low(); | 133 | pin2.set_low(); |
| 134 | Timer::after(Duration::from_millis(1)).await; | 134 | Timer::after_millis(1).await; |
| 135 | pin2.set_high(); | 135 | pin2.set_high(); |
| 136 | assert_eq!(pwm.counter(), 1); | 136 | assert_eq!(pwm.counter(), 1); |
| 137 | Timer::after(Duration::from_millis(1)).await; | 137 | Timer::after_millis(1).await; |
| 138 | assert_eq!(pwm.counter(), 1); | 138 | assert_eq!(pwm.counter(), 1); |
| 139 | } | 139 | } |
| 140 | 140 | ||
diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs index 00f3e1949..8d351a3a7 100644 --- a/tests/rp/src/bin/uart.rs +++ b/tests/rp/src/bin/uart.rs | |||
| @@ -7,7 +7,7 @@ use defmt::{assert_eq, *}; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::gpio::{Level, Output}; | 8 | use embassy_rp::gpio::{Level, Output}; |
| 9 | use embassy_rp::uart::{Blocking, Config, Error, Instance, Parity, Uart, UartRx}; | 9 | use embassy_rp::uart::{Blocking, Config, Error, Instance, Parity, Uart, UartRx}; |
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | fn read<const N: usize>(uart: &mut Uart<'_, impl Instance, Blocking>) -> Result<[u8; N], Error> { | 13 | fn read<const N: usize>(uart: &mut Uart<'_, impl Instance, Blocking>) -> Result<[u8; N], Error> { |
| @@ -24,14 +24,14 @@ fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Blocking>) -> Resu | |||
| 24 | 24 | ||
| 25 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 25 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { |
| 26 | pin.set_low(); | 26 | pin.set_low(); |
| 27 | Timer::after(Duration::from_millis(1)).await; | 27 | Timer::after_millis(1).await; |
| 28 | for i in 0..8 { | 28 | for i in 0..8 { |
| 29 | if v & (1 << i) == 0 { | 29 | if v & (1 << i) == 0 { |
| 30 | pin.set_low(); | 30 | pin.set_low(); |
| 31 | } else { | 31 | } else { |
| 32 | pin.set_high(); | 32 | pin.set_high(); |
| 33 | } | 33 | } |
| 34 | Timer::after(Duration::from_millis(1)).await; | 34 | Timer::after_millis(1).await; |
| 35 | } | 35 | } |
| 36 | if let Some(b) = parity { | 36 | if let Some(b) = parity { |
| 37 | if b { | 37 | if b { |
| @@ -39,10 +39,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O | |||
| 39 | } else { | 39 | } else { |
| 40 | pin.set_low(); | 40 | pin.set_low(); |
| 41 | } | 41 | } |
| 42 | Timer::after(Duration::from_millis(1)).await; | 42 | Timer::after_millis(1).await; |
| 43 | } | 43 | } |
| 44 | pin.set_high(); | 44 | pin.set_high(); |
| 45 | Timer::after(Duration::from_millis(1)).await; | 45 | Timer::after_millis(1).await; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | #[embassy_executor::main] | 48 | #[embassy_executor::main] |
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index 6ab7de29e..6a9c910ff 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs | |||
| @@ -9,7 +9,7 @@ use embassy_rp::bind_interrupts; | |||
| 9 | use embassy_rp::gpio::{Level, Output}; | 9 | use embassy_rp::gpio::{Level, Output}; |
| 10 | use embassy_rp::peripherals::UART0; | 10 | use embassy_rp::peripherals::UART0; |
| 11 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config, Error, Instance, Parity}; | 11 | use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config, Error, Instance, Parity}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use embedded_io_async::{Read, ReadExactError, Write}; | 13 | use embedded_io_async::{Read, ReadExactError, Write}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| @@ -39,14 +39,14 @@ async fn read1<const N: usize>(uart: &mut BufferedUartRx<'_, impl Instance>) -> | |||
| 39 | 39 | ||
| 40 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 40 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { |
| 41 | pin.set_low(); | 41 | pin.set_low(); |
| 42 | Timer::after(Duration::from_millis(1)).await; | 42 | Timer::after_millis(1).await; |
| 43 | for i in 0..8 { | 43 | for i in 0..8 { |
| 44 | if v & (1 << i) == 0 { | 44 | if v & (1 << i) == 0 { |
| 45 | pin.set_low(); | 45 | pin.set_low(); |
| 46 | } else { | 46 | } else { |
| 47 | pin.set_high(); | 47 | pin.set_high(); |
| 48 | } | 48 | } |
| 49 | Timer::after(Duration::from_millis(1)).await; | 49 | Timer::after_millis(1).await; |
| 50 | } | 50 | } |
| 51 | if let Some(b) = parity { | 51 | if let Some(b) = parity { |
| 52 | if b { | 52 | if b { |
| @@ -54,10 +54,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O | |||
| 54 | } else { | 54 | } else { |
| 55 | pin.set_low(); | 55 | pin.set_low(); |
| 56 | } | 56 | } |
| 57 | Timer::after(Duration::from_millis(1)).await; | 57 | Timer::after_millis(1).await; |
| 58 | } | 58 | } |
| 59 | pin.set_high(); | 59 | pin.set_high(); |
| 60 | Timer::after(Duration::from_millis(1)).await; | 60 | Timer::after_millis(1).await; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | #[embassy_executor::main] | 63 | #[embassy_executor::main] |
diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs index cd4af1ef2..e79fcde60 100644 --- a/tests/rp/src/bin/uart_dma.rs +++ b/tests/rp/src/bin/uart_dma.rs | |||
| @@ -9,7 +9,7 @@ use embassy_rp::bind_interrupts; | |||
| 9 | use embassy_rp::gpio::{Level, Output}; | 9 | use embassy_rp::gpio::{Level, Output}; |
| 10 | use embassy_rp::peripherals::UART0; | 10 | use embassy_rp::peripherals::UART0; |
| 11 | use embassy_rp::uart::{Async, Config, Error, Instance, InterruptHandler, Parity, Uart, UartRx}; | 11 | use embassy_rp::uart::{Async, Config, Error, Instance, InterruptHandler, Parity, Uart, UartRx}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -30,14 +30,14 @@ async fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Async>) -> R | |||
| 30 | 30 | ||
| 31 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 31 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { |
| 32 | pin.set_low(); | 32 | pin.set_low(); |
| 33 | Timer::after(Duration::from_millis(1)).await; | 33 | Timer::after_millis(1).await; |
| 34 | for i in 0..8 { | 34 | for i in 0..8 { |
| 35 | if v & (1 << i) == 0 { | 35 | if v & (1 << i) == 0 { |
| 36 | pin.set_low(); | 36 | pin.set_low(); |
| 37 | } else { | 37 | } else { |
| 38 | pin.set_high(); | 38 | pin.set_high(); |
| 39 | } | 39 | } |
| 40 | Timer::after(Duration::from_millis(1)).await; | 40 | Timer::after_millis(1).await; |
| 41 | } | 41 | } |
| 42 | if let Some(b) = parity { | 42 | if let Some(b) = parity { |
| 43 | if b { | 43 | if b { |
| @@ -45,10 +45,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O | |||
| 45 | } else { | 45 | } else { |
| 46 | pin.set_low(); | 46 | pin.set_low(); |
| 47 | } | 47 | } |
| 48 | Timer::after(Duration::from_millis(1)).await; | 48 | Timer::after_millis(1).await; |
| 49 | } | 49 | } |
| 50 | pin.set_high(); | 50 | pin.set_high(); |
| 51 | Timer::after(Duration::from_millis(1)).await; | 51 | Timer::after_millis(1).await; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | #[embassy_executor::main] | 54 | #[embassy_executor::main] |
| @@ -105,7 +105,7 @@ async fn main(_spawner: Spawner) { | |||
| 105 | // new data is accepted, latest overrunning byte first | 105 | // new data is accepted, latest overrunning byte first |
| 106 | assert_eq!(read(&mut uart).await, Ok([3])); | 106 | assert_eq!(read(&mut uart).await, Ok([3])); |
| 107 | uart.blocking_write(&[8, 9]).unwrap(); | 107 | uart.blocking_write(&[8, 9]).unwrap(); |
| 108 | Timer::after(Duration::from_millis(1)).await; | 108 | Timer::after_millis(1).await; |
| 109 | assert_eq!(read(&mut uart).await, Ok([8, 9])); | 109 | assert_eq!(read(&mut uart).await, Ok([8, 9])); |
| 110 | } | 110 | } |
| 111 | 111 | ||
diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index fb7a84b1b..10e3c3e81 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs | |||
| @@ -12,7 +12,7 @@ use embassy_executor::Spawner; | |||
| 12 | use embassy_stm32::adc::Adc; | 12 | use embassy_stm32::adc::Adc; |
| 13 | use embassy_stm32::dac::{DacCh1, DacChannel, Value}; | 13 | use embassy_stm32::dac::{DacCh1, DacChannel, Value}; |
| 14 | use embassy_stm32::dma::NoDma; | 14 | use embassy_stm32::dma::NoDma; |
| 15 | use embassy_time::{Delay, Duration, Timer}; | 15 | use embassy_time::{Delay, Timer}; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| @@ -38,7 +38,7 @@ async fn main(_spawner: Spawner) { | |||
| 38 | 38 | ||
| 39 | unwrap!(dac.set(Value::Bit8(0))); | 39 | unwrap!(dac.set(Value::Bit8(0))); |
| 40 | // Now wait a little to obtain a stable value | 40 | // Now wait a little to obtain a stable value |
| 41 | Timer::after(Duration::from_millis(30)).await; | 41 | Timer::after_millis(30).await; |
| 42 | let offset = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); | 42 | let offset = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); |
| 43 | 43 | ||
| 44 | for v in 0..=255 { | 44 | for v in 0..=255 { |
| @@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) { | |||
| 47 | unwrap!(dac.set(Value::Bit8(dac_output_val))); | 47 | unwrap!(dac.set(Value::Bit8(dac_output_val))); |
| 48 | 48 | ||
| 49 | // Now wait a little to obtain a stable value | 49 | // Now wait a little to obtain a stable value |
| 50 | Timer::after(Duration::from_millis(30)).await; | 50 | Timer::after_millis(30).await; |
| 51 | 51 | ||
| 52 | // Need to steal the peripherals here because PA4 is obviously in use already | 52 | // Need to steal the peripherals here because PA4 is obviously in use already |
| 53 | let measured = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); | 53 | let measured = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); |
diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index 46fdbfaeb..64f1122a6 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs | |||
| @@ -12,7 +12,7 @@ use defmt::assert; | |||
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_stm32::rcc::LsConfig; | 13 | use embassy_stm32::rcc::LsConfig; |
| 14 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 14 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::Timer; |
| 16 | 16 | ||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| @@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | rtc.set_datetime(now.into()).expect("datetime not set"); | 32 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 33 | 33 | ||
| 34 | info!("Waiting 5 seconds"); | 34 | info!("Waiting 5 seconds"); |
| 35 | Timer::after(Duration::from_millis(5000)).await; | 35 | Timer::after_millis(5000).await; |
| 36 | 36 | ||
| 37 | let then: NaiveDateTime = rtc.now().unwrap().into(); | 37 | let then: NaiveDateTime = rtc.now().unwrap().into(); |
| 38 | let seconds = (then - now).num_seconds(); | 38 | let seconds = (then - now).num_seconds(); |
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 929869bc9..f38924c90 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs | |||
| @@ -14,7 +14,7 @@ use embassy_stm32::low_power::{stop_with_rtc, Executor}; | |||
| 14 | use embassy_stm32::rcc::LsConfig; | 14 | use embassy_stm32::rcc::LsConfig; |
| 15 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 15 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 16 | use embassy_stm32::Config; | 16 | use embassy_stm32::Config; |
| 17 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::Timer; |
| 18 | use static_cell::make_static; | 18 | use static_cell::make_static; |
| 19 | 19 | ||
| 20 | #[entry] | 20 | #[entry] |
| @@ -28,7 +28,7 @@ fn main() -> ! { | |||
| 28 | async fn task_1() { | 28 | async fn task_1() { |
| 29 | for _ in 0..9 { | 29 | for _ in 0..9 { |
| 30 | info!("task 1: waiting for 500ms..."); | 30 | info!("task 1: waiting for 500ms..."); |
| 31 | Timer::after(Duration::from_millis(500)).await; | 31 | Timer::after_millis(500).await; |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -36,7 +36,7 @@ async fn task_1() { | |||
| 36 | async fn task_2() { | 36 | async fn task_2() { |
| 37 | for _ in 0..5 { | 37 | for _ in 0..5 { |
| 38 | info!("task 2: waiting for 1000ms..."); | 38 | info!("task 2: waiting for 1000ms..."); |
| 39 | Timer::after(Duration::from_millis(1000)).await; | 39 | Timer::after_millis(1000).await; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | info!("Test OK"); | 42 | info!("Test OK"); |
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index f8b453cda..4efeb0a49 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs | |||
| @@ -7,7 +7,7 @@ mod common; | |||
| 7 | use common::*; | 7 | use common::*; |
| 8 | use defmt::assert; | 8 | use defmt::assert; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_time::{Duration, Instant, Timer}; | 10 | use embassy_time::{Instant, Timer}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
| 17 | let start = Instant::now(); | 17 | let start = Instant::now(); |
| 18 | Timer::after(Duration::from_millis(100)).await; | 18 | Timer::after_millis(100).await; |
| 19 | let end = Instant::now(); | 19 | let end = Instant::now(); |
| 20 | let ms = (end - start).as_millis(); | 20 | let ms = (end - start).as_millis(); |
| 21 | info!("slept for {} ms", ms); | 21 | info!("slept for {} ms", ms); |
diff --git a/tests/stm32/src/bin/usart_rx_ringbuffered.rs b/tests/stm32/src/bin/usart_rx_ringbuffered.rs index 1ee7e596d..7e15f64b6 100644 --- a/tests/stm32/src/bin/usart_rx_ringbuffered.rs +++ b/tests/stm32/src/bin/usart_rx_ringbuffered.rs | |||
| @@ -10,7 +10,7 @@ use common::*; | |||
| 10 | use defmt::{assert_eq, panic}; | 10 | use defmt::{assert_eq, panic}; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_stm32::usart::{Config, DataBits, Parity, RingBufferedUartRx, StopBits, Uart, UartTx}; | 12 | use embassy_stm32::usart::{Config, DataBits, Parity, RingBufferedUartRx, StopBits, Uart, UartTx}; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::Timer; |
| 14 | use rand_chacha::ChaCha8Rng; | 14 | use rand_chacha::ChaCha8Rng; |
| 15 | use rand_core::{RngCore, SeedableRng}; | 15 | use rand_core::{RngCore, SeedableRng}; |
| 16 | 16 | ||
| @@ -54,7 +54,7 @@ async fn main(spawner: Spawner) { | |||
| 54 | #[embassy_executor::task] | 54 | #[embassy_executor::task] |
| 55 | async fn transmit_task(mut tx: UartTx<'static, peris::UART, peris::UART_TX_DMA>) { | 55 | async fn transmit_task(mut tx: UartTx<'static, peris::UART, peris::UART_TX_DMA>) { |
| 56 | // workaround https://github.com/embassy-rs/embassy/issues/1426 | 56 | // workaround https://github.com/embassy-rs/embassy/issues/1426 |
| 57 | Timer::after(Duration::from_millis(100) as _).await; | 57 | Timer::after_millis(100).await; |
| 58 | 58 | ||
| 59 | let mut rng = ChaCha8Rng::seed_from_u64(1337); | 59 | let mut rng = ChaCha8Rng::seed_from_u64(1337); |
| 60 | 60 | ||
| @@ -70,7 +70,7 @@ async fn transmit_task(mut tx: UartTx<'static, peris::UART, peris::UART_TX_DMA>) | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | tx.write(&buf[..len]).await.unwrap(); | 72 | tx.write(&buf[..len]).await.unwrap(); |
| 73 | Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await; | 73 | Timer::after_micros((rng.next_u32() % 1000) as _).await; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -98,7 +98,7 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, peris::UART, peris::UA | |||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | if received < max_len { | 100 | if received < max_len { |
| 101 | Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await; | 101 | Timer::after_micros((rng.next_u32() % 1000) as _).await; |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | i += received; | 104 | i += received; |
