diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/nrf/src/bin/buffered_uart_spam.rs | 4 | ||||
| -rw-r--r-- | tests/nrf/src/bin/timer.rs | 4 | ||||
| -rw-r--r-- | tests/perf-client/src/lib.rs | 2 | ||||
| -rw-r--r-- | tests/rp/src/bin/bootsel.rs | 4 | ||||
| -rw-r--r-- | tests/rp/src/bin/flash.rs | 4 | ||||
| -rw-r--r-- | tests/rp/src/bin/float.rs | 4 | ||||
| -rw-r--r-- | tests/rp/src/bin/gpio_async.rs | 12 | ||||
| -rw-r--r-- | tests/rp/src/bin/pwm.rs | 44 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart.rs | 10 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart_buffered.rs | 10 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart_dma.rs | 12 | ||||
| -rw-r--r-- | tests/stm32/src/bin/dac.rs | 6 | ||||
| -rw-r--r-- | tests/stm32/src/bin/rtc.rs | 4 | ||||
| -rw-r--r-- | tests/stm32/src/bin/stop.rs | 6 | ||||
| -rw-r--r-- | tests/stm32/src/bin/timer.rs | 4 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart_rx_ringbuffered.rs | 8 |
16 files changed, 69 insertions, 69 deletions
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; |
