aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/boot/application/nrf/Cargo.toml2
-rw-r--r--examples/boot/application/nrf/src/bin/b.rs6
-rw-r--r--examples/boot/application/rp/Cargo.toml2
-rw-r--r--examples/boot/application/rp/src/bin/a.rs4
-rw-r--r--examples/boot/application/rp/src/bin/b.rs6
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f3/src/bin/b.rs6
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f7/src/bin/b.rs8
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32h7/src/bin/b.rs8
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l0/src/bin/a.rs4
-rw-r--r--examples/boot/application/stm32l0/src/bin/b.rs6
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs4
-rw-r--r--examples/boot/application/stm32l1/src/bin/b.rs6
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l4/src/bin/b.rs6
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml2
-rw-r--r--examples/boot/application/stm32wl/src/bin/b.rs6
-rw-r--r--examples/nrf-rtos-trace/Cargo.toml2
-rw-r--r--examples/nrf-rtos-trace/src/bin/rtos_trace.rs4
-rw-r--r--examples/nrf52840-rtic/Cargo.toml2
-rw-r--r--examples/nrf52840-rtic/memory.x7
-rw-r--r--examples/nrf52840-rtic/src/bin/blinky.rs6
-rw-r--r--examples/nrf52840/Cargo.toml8
-rw-r--r--examples/nrf52840/memory.x7
-rw-r--r--examples/nrf52840/src/bin/blinky.rs6
-rw-r--r--examples/nrf52840/src/bin/channel.rs6
-rw-r--r--examples/nrf52840/src/bin/channel_sender_receiver.rs6
-rw-r--r--examples/nrf52840/src/bin/executor_fairness_test.rs4
-rw-r--r--examples/nrf52840/src/bin/lora_cad.rs6
-rw-r--r--examples/nrf52840/src/bin/lora_p2p_receive.rs6
-rw-r--r--examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs6
-rw-r--r--examples/nrf52840/src/bin/manually_create_executor.rs6
-rw-r--r--examples/nrf52840/src/bin/multiprio.rs8
-rw-r--r--examples/nrf52840/src/bin/mutex.rs8
-rw-r--r--examples/nrf52840/src/bin/nvmc.rs4
-rw-r--r--examples/nrf52840/src/bin/pdm.rs6
-rw-r--r--examples/nrf52840/src/bin/pubsub.rs8
-rw-r--r--examples/nrf52840/src/bin/pwm.rs4
-rw-r--r--examples/nrf52840/src/bin/pwm_double_sequence.rs4
-rw-r--r--examples/nrf52840/src/bin/pwm_sequence.rs4
-rw-r--r--examples/nrf52840/src/bin/pwm_sequence_ws2812b.rs4
-rw-r--r--examples/nrf52840/src/bin/pwm_servo.rs14
-rw-r--r--examples/nrf52840/src/bin/qspi_lowpower.rs4
-rw-r--r--examples/nrf52840/src/bin/raw_spawn.rs6
-rw-r--r--examples/nrf52840/src/bin/saadc.rs4
-rw-r--r--examples/nrf52840/src/bin/saadc_continuous.rs3
-rw-r--r--examples/nrf52840/src/bin/self_spawn.rs4
-rw-r--r--examples/nrf52840/src/bin/self_spawn_current_executor.rs4
-rw-r--r--examples/nrf52840/src/bin/temp.rs4
-rw-r--r--examples/nrf52840/src/bin/timer.rs6
-rw-r--r--examples/nrf52840/src/bin/twim_lowpower.rs4
-rw-r--r--examples/nrf52840/src/bin/usb_hid_mouse.rs4
-rw-r--r--examples/nrf5340/Cargo.toml6
-rw-r--r--examples/nrf5340/src/bin/blinky.rs6
-rw-r--r--examples/rp/Cargo.toml6
-rw-r--r--examples/rp/src/bin/adc.rs4
-rw-r--r--examples/rp/src/bin/blinky.rs6
-rw-r--r--examples/rp/src/bin/ethernet_w5500_tcp_client.rs2
-rw-r--r--examples/rp/src/bin/flash.rs4
-rw-r--r--examples/rp/src/bin/gpio_async.rs4
-rw-r--r--examples/rp/src/bin/gpout.rs6
-rw-r--r--examples/rp/src/bin/i2c_async.rs4
-rw-r--r--examples/rp/src/bin/i2c_blocking.rs4
-rw-r--r--examples/rp/src/bin/i2c_slave.rs6
-rw-r--r--examples/rp/src/bin/lora_p2p_receive.rs4
-rw-r--r--examples/rp/src/bin/lora_p2p_send_multicore.rs4
-rw-r--r--examples/rp/src/bin/multicore.rs6
-rw-r--r--examples/rp/src/bin/multiprio.rs8
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs4
-rw-r--r--examples/rp/src/bin/pio_ws2812.rs4
-rw-r--r--examples/rp/src/bin/pwm.rs4
-rw-r--r--examples/rp/src/bin/rosc.rs32
-rw-r--r--examples/rp/src/bin/rtc.rs6
-rw-r--r--examples/rp/src/bin/spi_async.rs4
-rw-r--r--examples/rp/src/bin/uart_buffered_split.rs4
-rw-r--r--examples/rp/src/bin/uart_unidir.rs4
-rw-r--r--examples/rp/src/bin/usb_hid_keyboard.rs3
-rw-r--r--examples/rp/src/bin/usb_logger.rs4
-rw-r--r--examples/rp/src/bin/usb_midi.rs110
-rw-r--r--examples/rp/src/bin/watchdog.rs10
-rw-r--r--examples/rp/src/bin/wifi_ap_tcp_server.rs2
-rw-r--r--examples/rp/src/bin/wifi_blinky.rs2
-rw-r--r--examples/rp/src/bin/wifi_scan.rs2
-rw-r--r--examples/rp/src/bin/wifi_tcp_server.rs11
-rw-r--r--examples/std/Cargo.toml8
-rw-r--r--examples/std/src/bin/net_ppp.rs2
-rw-r--r--examples/std/src/bin/tcp_accept.rs2
-rw-r--r--examples/std/src/bin/tick.rs4
-rw-r--r--examples/stm32c0/Cargo.toml2
-rw-r--r--examples/stm32c0/src/bin/blinky.rs6
-rw-r--r--examples/stm32f0/Cargo.toml2
-rw-r--r--examples/stm32f0/src/bin/adc.rs4
-rw-r--r--examples/stm32f0/src/bin/blinky.rs6
-rw-r--r--examples/stm32f0/src/bin/button_controlled_blink.rs4
-rw-r--r--examples/stm32f0/src/bin/hello.rs4
-rw-r--r--examples/stm32f0/src/bin/multiprio.rs8
-rw-r--r--examples/stm32f0/src/bin/wdg.rs4
-rw-r--r--examples/stm32f1/Cargo.toml2
-rw-r--r--examples/stm32f1/src/bin/adc.rs4
-rw-r--r--examples/stm32f1/src/bin/blinky.rs6
-rw-r--r--examples/stm32f1/src/bin/hello.rs4
-rw-r--r--examples/stm32f1/src/bin/usb_serial.rs4
-rw-r--r--examples/stm32f2/Cargo.toml2
-rw-r--r--examples/stm32f2/src/bin/blinky.rs6
-rw-r--r--examples/stm32f2/src/bin/pll.rs10
-rw-r--r--examples/stm32f3/Cargo.toml2
-rw-r--r--examples/stm32f3/src/bin/blinky.rs6
-rw-r--r--examples/stm32f3/src/bin/button_events.rs4
-rw-r--r--examples/stm32f3/src/bin/hello.rs4
-rw-r--r--examples/stm32f3/src/bin/multiprio.rs8
-rw-r--r--examples/stm32f3/src/bin/usb_serial.rs4
-rw-r--r--examples/stm32f334/src/bin/adc.rs8
-rw-r--r--examples/stm32f334/src/bin/button.rs6
-rw-r--r--examples/stm32f334/src/bin/hello.rs4
-rw-r--r--examples/stm32f334/src/bin/opamp.rs59
-rw-r--r--examples/stm32f334/src/bin/pwm.rs6
-rw-r--r--examples/stm32f4/Cargo.toml8
-rw-r--r--examples/stm32f4/src/bin/adc.rs4
-rw-r--r--examples/stm32f4/src/bin/blinky.rs6
-rw-r--r--examples/stm32f4/src/bin/eth.rs31
-rw-r--r--examples/stm32f4/src/bin/flash_async.rs6
-rw-r--r--examples/stm32f4/src/bin/hello.rs8
-rw-r--r--examples/stm32f4/src/bin/i2c.rs9
-rw-r--r--examples/stm32f4/src/bin/mco.rs12
-rw-r--r--examples/stm32f4/src/bin/multiprio.rs8
-rw-r--r--examples/stm32f4/src/bin/pwm.rs10
-rw-r--r--examples/stm32f4/src/bin/pwm_complementary.rs10
-rw-r--r--examples/stm32f4/src/bin/rtc.rs10
-rw-r--r--examples/stm32f4/src/bin/sdmmc.rs23
-rw-r--r--examples/stm32f4/src/bin/usb_ethernet.rs24
-rw-r--r--examples/stm32f4/src/bin/usb_serial.rs24
-rw-r--r--examples/stm32f4/src/bin/wdt.rs6
-rw-r--r--examples/stm32f7/Cargo.toml6
-rw-r--r--examples/stm32f7/src/bin/adc.rs4
-rw-r--r--examples/stm32f7/src/bin/blinky.rs6
-rw-r--r--examples/stm32f7/src/bin/can.rs2
-rw-r--r--examples/stm32f7/src/bin/eth.rs31
-rw-r--r--examples/stm32f7/src/bin/flash.rs4
-rw-r--r--examples/stm32f7/src/bin/hello.rs8
-rw-r--r--examples/stm32f7/src/bin/sdmmc.rs23
-rw-r--r--examples/stm32f7/src/bin/usb_serial.rs25
-rw-r--r--examples/stm32g0/Cargo.toml2
-rw-r--r--examples/stm32g0/src/bin/blinky.rs6
-rw-r--r--examples/stm32g0/src/bin/spi_neopixel.rs6
-rw-r--r--examples/stm32g4/Cargo.toml2
-rw-r--r--examples/stm32g4/src/bin/adc.rs12
-rw-r--r--examples/stm32g4/src/bin/blinky.rs6
-rw-r--r--examples/stm32g4/src/bin/pll.rs10
-rw-r--r--examples/stm32g4/src/bin/pwm.rs10
-rw-r--r--examples/stm32g4/src/bin/usb_serial.rs8
-rw-r--r--examples/stm32h5/Cargo.toml8
-rw-r--r--examples/stm32h5/src/bin/blinky.rs6
-rw-r--r--examples/stm32h5/src/bin/eth.rs21
-rw-r--r--examples/stm32h5/src/bin/i2c.rs9
-rw-r--r--examples/stm32h5/src/bin/usb_serial.rs10
-rw-r--r--examples/stm32h7/Cargo.toml11
-rw-r--r--examples/stm32h7/src/bin/adc.rs18
-rw-r--r--examples/stm32h7/src/bin/blinky.rs6
-rw-r--r--examples/stm32h7/src/bin/camera.rs26
-rw-r--r--examples/stm32h7/src/bin/dac.rs14
-rw-r--r--examples/stm32h7/src/bin/dac_dma.rs18
-rw-r--r--examples/stm32h7/src/bin/eth.rs15
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs19
-rw-r--r--examples/stm32h7/src/bin/flash.rs4
-rw-r--r--examples/stm32h7/src/bin/fmc.rs12
-rw-r--r--examples/stm32h7/src/bin/i2c.rs9
-rw-r--r--examples/stm32h7/src/bin/low_level_timer_api.rs21
-rw-r--r--examples/stm32h7/src/bin/mco.rs10
-rw-r--r--examples/stm32h7/src/bin/pwm.rs16
-rw-r--r--examples/stm32h7/src/bin/rtc.rs37
-rw-r--r--examples/stm32h7/src/bin/sdmmc.rs8
-rw-r--r--examples/stm32h7/src/bin/signal.rs4
-rw-r--r--examples/stm32h7/src/bin/spi.rs8
-rw-r--r--examples/stm32h7/src/bin/spi_dma.rs8
-rw-r--r--examples/stm32h7/src/bin/usb_serial.rs6
-rw-r--r--examples/stm32h7/src/bin/wdg.rs4
-rw-r--r--examples/stm32l0/Cargo.toml6
-rw-r--r--examples/stm32l0/src/bin/blinky.rs6
-rw-r--r--examples/stm32l0/src/bin/lora_cad.rs6
-rw-r--r--examples/stm32l0/src/bin/lora_p2p_receive.rs6
-rw-r--r--examples/stm32l0/src/bin/raw_spawn.rs6
-rw-r--r--examples/stm32l1/Cargo.toml2
-rw-r--r--examples/stm32l1/src/bin/blinky.rs6
-rw-r--r--examples/stm32l4/Cargo.toml8
-rw-r--r--examples/stm32l4/src/bin/adc.rs2
-rw-r--r--examples/stm32l4/src/bin/blinky.rs6
-rw-r--r--examples/stm32l4/src/bin/dac_dma.rs4
-rw-r--r--examples/stm32l4/src/bin/mco.rs10
-rw-r--r--examples/stm32l4/src/bin/rng.rs20
-rw-r--r--examples/stm32l4/src/bin/rtc.rs33
-rw-r--r--examples/stm32l4/src/bin/spe_adin1110_http_server.rs27
-rw-r--r--examples/stm32l4/src/bin/usb_serial.rs11
-rw-r--r--examples/stm32l5/Cargo.toml6
-rw-r--r--examples/stm32l5/src/bin/rng.rs20
-rw-r--r--examples/stm32l5/src/bin/usb_ethernet.rs13
-rw-r--r--examples/stm32l5/src/bin/usb_hid_mouse.rs17
-rw-r--r--examples/stm32l5/src/bin/usb_serial.rs13
-rw-r--r--examples/stm32u5/Cargo.toml2
-rw-r--r--examples/stm32u5/src/bin/blinky.rs6
-rw-r--r--examples/stm32u5/src/bin/usb_serial.rs7
-rw-r--r--examples/stm32wb/Cargo.toml4
-rw-r--r--examples/stm32wb/src/bin/blinky.rs6
-rw-r--r--examples/stm32wb/src/bin/tl_mbox.rs4
-rw-r--r--examples/stm32wba/Cargo.toml4
-rw-r--r--examples/stm32wba/src/bin/blinky.rs6
-rw-r--r--examples/stm32wl/Cargo.toml2
-rw-r--r--examples/stm32wl/src/bin/blinky.rs6
-rw-r--r--examples/stm32wl/src/bin/lora_lorawan.rs3
-rw-r--r--examples/stm32wl/src/bin/lora_p2p_receive.rs8
-rw-r--r--examples/stm32wl/src/bin/lora_p2p_send.rs2
-rw-r--r--examples/stm32wl/src/bin/random.rs10
-rw-r--r--examples/stm32wl/src/bin/rtc.rs14
-rw-r--r--examples/stm32wl/src/bin/uart_async.rs2
-rw-r--r--examples/wasm/Cargo.toml2
-rw-r--r--examples/wasm/src/lib.rs4
219 files changed, 1091 insertions, 695 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index 435a33919..275367ff7 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly"] }
11embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } 11embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] }
12embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = ["nightly"] } 12embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = ["nightly"] }
13embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = ["nightly"] } 13embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = ["nightly"] }
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
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::gpio::{Level, Output, OutputDrive}; 7use embassy_nrf::gpio::{Level, Output, OutputDrive};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use panic_reset as _; 9use 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/Cargo.toml b/examples/boot/application/rp/Cargo.toml
index 01cfc5994..da89f15da 100644
--- a/examples/boot/application/rp/Cargo.toml
+++ b/examples/boot/application/rp/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly"] }
11embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] } 11embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] }
12embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = ["nightly"] } 12embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_rp::gpio; 6use embassy_rp::gpio;
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use gpio::{Level, Output}; 8use gpio::{Level, Output};
9use {defmt_rtt as _, panic_reset as _}; 9use {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/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index a0649cf83..147a5bcf5 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use 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/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index ca1c0c424..3fa136aea 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use panic_reset as _;
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
13async fn main(_spawner: Spawner) { 13async 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/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index e50c8c415..7ca767bde 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use panic_reset as _;
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
13async fn main(_spawner: Spawner) { 13async 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/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index 1f1a0f3cf..3e3cbbd82 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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;
11use embassy_stm32::flash::{Flash, WRITE_SIZE}; 11use embassy_stm32::flash::{Flash, WRITE_SIZE};
12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
13use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
14use embassy_time::{Duration, Timer}; 14use embassy_time::Timer;
15use panic_reset as _; 15use 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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use 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/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 45b12813e..5e77b7d53 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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;
11use embassy_stm32::flash::{Flash, WRITE_SIZE}; 11use embassy_stm32::flash::{Flash, WRITE_SIZE};
12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
13use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
14use embassy_time::{Duration, Timer}; 14use embassy_time::Timer;
15use panic_reset as _; 15use 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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use 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/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index d0d0d0fbe..aa5c5cf9f 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use 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/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index 3265b9f1a..87b8a1161 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } 12embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
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 @@
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use panic_reset as _; 10use 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/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml
index e402e49f4..e5820f26d 100644
--- a/examples/nrf-rtos-trace/Cargo.toml
+++ b/examples/nrf-rtos-trace/Cargo.toml
@@ -18,7 +18,7 @@ log = [
18[dependencies] 18[dependencies]
19embassy-sync = { version = "0.3.0", path = "../../embassy-sync" } 19embassy-sync = { version = "0.3.0", path = "../../embassy-sync" }
20embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } 20embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "rtos-trace-interrupt", "integrated-timers"] }
21embassy-time = { version = "0.1.3", path = "../../embassy-time" } 21embassy-time = { version = "0.1.5", path = "../../embassy-time" }
22embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } 22embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
23 23
24cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 24cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
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;
6use core::task::Poll; 6use core::task::Poll;
7 7
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_time::{Duration, Instant, Timer}; 9use embassy_time::{Instant, Timer};
10#[cfg(feature = "log")] 10#[cfg(feature = "log")]
11use log::*; 11use log::*;
12use panic_probe as _; 12use 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/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml
index c588b807e..a81d43a26 100644
--- a/examples/nrf52840-rtic/Cargo.toml
+++ b/examples/nrf52840-rtic/Cargo.toml
@@ -9,7 +9,7 @@ rtic = { version = "2", features = ["thumbv7-backend"] }
9 9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] }
13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
14 14
15defmt = "0.3" 15defmt = "0.3"
diff --git a/examples/nrf52840-rtic/memory.x b/examples/nrf52840-rtic/memory.x
index 9b04edec0..15b492bce 100644
--- a/examples/nrf52840-rtic/memory.x
+++ b/examples/nrf52840-rtic/memory.x
@@ -1,7 +1,12 @@
1MEMORY 1MEMORY
2{ 2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */ 3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
5 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K 4 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
6 RAM : ORIGIN = 0x20000000, LENGTH = 256K 5 RAM : ORIGIN = 0x20000000, LENGTH = 256K
6
7 /* These values correspond to the NRF52840 with Softdevices S140 7.3.0 */
8 /*
9 FLASH : ORIGIN = 0x00027000, LENGTH = 868K
10 RAM : ORIGIN = 0x20020000, LENGTH = 128K
11 */
7} 12}
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/Cargo.toml b/examples/nrf52840/Cargo.toml
index d45e006c7..753733509 100644
--- a/examples/nrf52840/Cargo.toml
+++ b/examples/nrf52840/Cargo.toml
@@ -31,12 +31,12 @@ nightly = [
31embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 31embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
32embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 32embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
33embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 33embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
34embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 34embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
35embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 35embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
36embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } 36embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true }
37embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt", "msos-descriptor",], optional = true } 37embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt", "msos-descriptor",], optional = true }
38embedded-io = { version = "0.5.0", features = ["defmt-03"] } 38embedded-io = { version = "0.6.0", features = ["defmt-03"] }
39embedded-io-async = { version = "0.5.0", optional = true, features = ["defmt-03"] } 39embedded-io-async = { version = "0.6.0", optional = true, features = ["defmt-03"] }
40embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } 40embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true }
41lora-phy = { version = "2", optional = true } 41lora-phy = { version = "2", optional = true }
42lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } 42lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true }
diff --git a/examples/nrf52840/memory.x b/examples/nrf52840/memory.x
index 9b04edec0..15b492bce 100644
--- a/examples/nrf52840/memory.x
+++ b/examples/nrf52840/memory.x
@@ -1,7 +1,12 @@
1MEMORY 1MEMORY
2{ 2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */ 3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
5 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K 4 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
6 RAM : ORIGIN = 0x20000000, LENGTH = 256K 5 RAM : ORIGIN = 0x20000000, LENGTH = 256K
6
7 /* These values correspond to the NRF52840 with Softdevices S140 7.3.0 */
8 /*
9 FLASH : ORIGIN = 0x00027000, LENGTH = 868K
10 RAM : ORIGIN = 0x20020000, LENGTH = 128K
11 */
7} 12}
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
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Level, Output, OutputDrive}; 6use embassy_nrf::gpio::{Level, Output, OutputDrive};
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {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;
7use embassy_nrf::gpio::{Level, Output, OutputDrive}; 7use embassy_nrf::gpio::{Level, Output, OutputDrive};
8use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; 8use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
9use embassy_sync::channel::Channel; 9use embassy_sync::channel::Channel;
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13enum LedState { 13enum LedState {
@@ -21,9 +21,9 @@ static CHANNEL: Channel<ThreadModeRawMutex, LedState, 1> = Channel::new();
21async fn my_task() { 21async 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;
7use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; 7use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin};
8use embassy_sync::blocking_mutex::raw::NoopRawMutex; 8use embassy_sync::blocking_mutex::raw::NoopRawMutex;
9use embassy_sync::channel::{Channel, Receiver, Sender}; 9use embassy_sync::channel::{Channel, Receiver, Sender};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use static_cell::StaticCell; 11use static_cell::StaticCell;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
@@ -22,9 +22,9 @@ static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new
22async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { 22async 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
8use defmt::{info, unwrap}; 8use defmt::{info, unwrap};
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_time::{Duration, Instant, Timer}; 10use embassy_time::{Instant, Timer};
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13#[embassy_executor::task] 13#[embassy_executor::task]
14async fn run1() { 14async 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;
11use embassy_lora::iv::GenericSx126xInterfaceVariant; 11use embassy_lora::iv::GenericSx126xInterfaceVariant;
12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; 12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull};
13use embassy_nrf::{bind_interrupts, peripherals, spim}; 13use embassy_nrf::{bind_interrupts, peripherals, spim};
14use embassy_time::{Delay, Duration, Timer}; 14use embassy_time::{Delay, Timer};
15use lora_phy::mod_params::*; 15use lora_phy::mod_params::*;
16use lora_phy::sx1261_2::SX1261_2; 16use lora_phy::sx1261_2::SX1261_2;
17use lora_phy::LoRa; 17use 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;
11use embassy_lora::iv::GenericSx126xInterfaceVariant; 11use embassy_lora::iv::GenericSx126xInterfaceVariant;
12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; 12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull};
13use embassy_nrf::{bind_interrupts, peripherals, spim}; 13use embassy_nrf::{bind_interrupts, peripherals, spim};
14use embassy_time::{Delay, Duration, Timer}; 14use embassy_time::{Delay, Timer};
15use lora_phy::mod_params::*; 15use lora_phy::mod_params::*;
16use lora_phy::sx1261_2::SX1261_2; 16use lora_phy::sx1261_2::SX1261_2;
17use lora_phy::LoRa; 17use 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;
11use embassy_lora::iv::GenericSx126xInterfaceVariant; 11use embassy_lora::iv::GenericSx126xInterfaceVariant;
12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; 12use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull};
13use embassy_nrf::{bind_interrupts, peripherals, spim}; 13use embassy_nrf::{bind_interrupts, peripherals, spim};
14use embassy_time::{Delay, Duration, Timer}; 14use embassy_time::{Delay, Timer};
15use lora_phy::mod_params::*; 15use lora_phy::mod_params::*;
16use lora_phy::sx1261_2::SX1261_2; 16use lora_phy::sx1261_2::SX1261_2;
17use lora_phy::LoRa; 17use 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 @@
8use cortex_m_rt::entry; 8use cortex_m_rt::entry;
9use defmt::{info, unwrap}; 9use defmt::{info, unwrap};
10use embassy_executor::Executor; 10use embassy_executor::Executor;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use static_cell::StaticCell; 12use static_cell::StaticCell;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
@@ -16,7 +16,7 @@ use {defmt_rtt as _, panic_probe as _};
16async fn run1() { 16async 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() {
24async fn run2() { 24async 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};
62use embassy_executor::{Executor, InterruptExecutor}; 62use embassy_executor::{Executor, InterruptExecutor};
63use embassy_nrf::interrupt; 63use embassy_nrf::interrupt;
64use embassy_nrf::interrupt::{InterruptExt, Priority}; 64use embassy_nrf::interrupt::{InterruptExt, Priority};
65use embassy_time::{Duration, Instant, Timer}; 65use embassy_time::{Instant, Timer};
66use static_cell::StaticCell; 66use static_cell::StaticCell;
67use {defmt_rtt as _, panic_probe as _}; 67use {defmt_rtt as _, panic_probe as _};
68 68
@@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _};
70async fn run_high() { 70async 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};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; 7use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
8use embassy_sync::mutex::Mutex; 8use embassy_sync::mutex::Mutex;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); 12static 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 @@
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::nvmc::Nvmc; 7use embassy_nrf::nvmc::Nvmc;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; 9use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
10use {defmt_rtt as _, panic_probe as _}; 10use {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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::pdm::{self, Config, Pdm}; 7use embassy_nrf::pdm::{self, Config, Pdm};
8use embassy_nrf::{bind_interrupts, peripherals}; 8use embassy_nrf::{bind_interrupts, peripherals};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use fixed::types::I7F1; 10use fixed::types::I7F1;
11use num_integer::Roots; 11use num_integer::Roots;
12use {defmt_rtt as _, panic_probe as _}; 12use {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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; 7use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
8use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber}; 8use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {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
81async fn slow_logger(mut messages: DynSubscriber<'static, Message>) { 81async 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>) {
98async fn slow_logger_pure(mut messages: DynSubscriber<'static, Message>) { 98async 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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::pwm::{Prescaler, SimplePwm}; 7use embassy_nrf::pwm::{Prescaler, SimplePwm};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
7use embassy_nrf::pwm::{ 7use embassy_nrf::pwm::{
8 Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, 8 Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence,
9}; 9};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; 7use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
7use embassy_nrf::pwm::{ 7use embassy_nrf::pwm::{
8 Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, 8 Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer,
9}; 9};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::pwm::{Prescaler, SimplePwm}; 7use embassy_nrf::pwm::{Prescaler, SimplePwm};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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};
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_nrf::qspi::Frequency; 9use embassy_nrf::qspi::Frequency;
10use embassy_nrf::{bind_interrupts, peripherals, qspi}; 10use embassy_nrf::{bind_interrupts, peripherals, qspi};
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {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;
7use defmt::{info, unwrap}; 7use defmt::{info, unwrap};
8use embassy_executor::raw::TaskStorage; 8use embassy_executor::raw::TaskStorage;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use static_cell::StaticCell; 11use static_cell::StaticCell;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14async fn run1() { 14async 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
21async fn run2() { 21async 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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; 7use embassy_nrf::saadc::{ChannelConfig, Config, Saadc};
8use embassy_nrf::{bind_interrupts, saadc}; 8use embassy_nrf::{bind_interrupts, saadc};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12bind_interrupts!(struct Irqs { 12bind_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;
7use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; 7use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc};
8use embassy_nrf::timer::Frequency; 8use embassy_nrf::timer::Frequency;
9use embassy_nrf::{bind_interrupts, saadc}; 9use embassy_nrf::{bind_interrupts, saadc};
10use embassy_time::Duration;
11use {defmt_rtt as _, panic_probe as _}; 10use {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
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
9 9
10mod config { 10mod 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)]
15async fn my_task(spawner: Spawner, n: u32) { 15async 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
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
9 9
10#[embassy_executor::task(pool_size = 2)] 10#[embassy_executor::task(pool_size = 2)]
11async fn my_task(n: u32) { 11async 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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_nrf::temp::Temp; 7use embassy_nrf::temp::Temp;
8use embassy_nrf::{bind_interrupts, temp}; 8use embassy_nrf::{bind_interrupts, temp};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12bind_interrupts!(struct Irqs { 12bind_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
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
9 9
10#[embassy_executor::task] 10#[embassy_executor::task]
11async fn run1() { 11async 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() {
19async fn run2() { 19async 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::*;
14use embassy_executor::Spawner; 14use embassy_executor::Spawner;
15use embassy_nrf::twim::{self, Twim}; 15use embassy_nrf::twim::{self, Twim};
16use embassy_nrf::{bind_interrupts, peripherals}; 16use embassy_nrf::{bind_interrupts, peripherals};
17use embassy_time::{Duration, Timer}; 17use embassy_time::Timer;
18use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
19 19
20const ADDRESS: u8 = 0x50; 20const 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;
10use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; 10use embassy_nrf::usb::vbus_detect::HardwareVbusDetect;
11use embassy_nrf::usb::Driver; 11use embassy_nrf::usb::Driver;
12use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; 12use embassy_nrf::{bind_interrupts, pac, peripherals, usb};
13use embassy_time::{Duration, Timer}; 13use embassy_time::Timer;
14use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; 14use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State};
15use embassy_usb::control::OutResponse; 15use embassy_usb::control::OutResponse;
16use embassy_usb::{Builder, Config}; 16use 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/Cargo.toml b/examples/nrf5340/Cargo.toml
index 86d969ed5..24972a4fb 100644
--- a/examples/nrf5340/Cargo.toml
+++ b/examples/nrf5340/Cargo.toml
@@ -14,7 +14,7 @@ embassy-executor = { version = "0.3.0", path = "../../embassy-executor", feature
14 "defmt", 14 "defmt",
15 "integrated-timers", 15 "integrated-timers",
16] } 16] }
17embassy-time = { version = "0.1.3", path = "../../embassy-time", features = [ 17embassy-time = { version = "0.1.5", path = "../../embassy-time", features = [
18 "defmt", 18 "defmt",
19 "defmt-timestamp-uptime", 19 "defmt-timestamp-uptime",
20] } 20] }
@@ -27,7 +27,7 @@ embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [
27 "gpiote", 27 "gpiote",
28 "unstable-pac", 28 "unstable-pac",
29] } 29] }
30embassy-net = { version = "0.1.0", path = "../../embassy-net", features = [ 30embassy-net = { version = "0.2.0", path = "../../embassy-net", features = [
31 "nightly", 31 "nightly",
32 "defmt", 32 "defmt",
33 "tcp", 33 "tcp",
@@ -37,7 +37,7 @@ embassy-net = { version = "0.1.0", path = "../../embassy-net", features = [
37embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [ 37embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [
38 "defmt", 38 "defmt",
39] } 39] }
40embedded-io-async = { version = "0.5.0" } 40embedded-io-async = { version = "0.6.0" }
41 41
42defmt = "0.3" 42defmt = "0.3"
43defmt-rtt = "0.4" 43defmt-rtt = "0.4"
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
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Level, Output, OutputDrive}; 6use embassy_nrf::gpio::{Level, Output, OutputDrive};
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {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/Cargo.toml b/examples/rp/Cargo.toml
index 2677e0402..7386eeea7 100644
--- a/examples/rp/Cargo.toml
+++ b/examples/rp/Cargo.toml
@@ -9,10 +9,10 @@ license = "MIT OR Apache-2.0"
9embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } 9embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] }
13embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } 13embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] }
14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } 15embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
16embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } 16embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
18embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } 18embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" }
@@ -45,7 +45,7 @@ usbd-hid = "0.6.1"
45embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } 45embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" }
46embedded-hal-async = "1.0.0-rc.1" 46embedded-hal-async = "1.0.0-rc.1"
47embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] } 47embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] }
48embedded-io-async = { version = "0.5.0", features = ["defmt-03"] } 48embedded-io-async = { version = "0.6.0", features = ["defmt-03"] }
49embedded-storage = { version = "0.3" } 49embedded-storage = { version = "0.3" }
50static_cell = { version = "1.1", features = ["nightly"]} 50static_cell = { version = "1.1", features = ["nightly"]}
51log = "0.4" 51log = "0.4"
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;
10use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler}; 10use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler};
11use embassy_rp::bind_interrupts; 11use embassy_rp::bind_interrupts;
12use embassy_rp::gpio::Pull; 12use embassy_rp::gpio::Pull;
13use embassy_time::{Duration, Timer}; 13use embassy_time::Timer;
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
16bind_interrupts!(struct Irqs { 16bind_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 @@
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::gpio; 11use embassy_rp::gpio;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use gpio::{Level, Output}; 13use gpio::{Level, Output};
14use {defmt_rtt as _, panic_probe as _}; 14use {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::*;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; 9use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE};
10use embassy_rp::peripherals::FLASH; 10use embassy_rp::peripherals::FLASH;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14const ADDR_OFFSET: u32 = 0x100000; 14const 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 @@
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::gpio; 11use embassy_rp::gpio;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use gpio::{Input, Level, Output, Pull}; 13use gpio::{Input, Level, Output, Pull};
14use {defmt_rtt as _, panic_probe as _}; 14use {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 @@
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::clocks; 11use embassy_rp::clocks;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {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;
12use embassy_rp::bind_interrupts; 12use embassy_rp::bind_interrupts;
13use embassy_rp::i2c::{self, Config, InterruptHandler}; 13use embassy_rp::i2c::{self, Config, InterruptHandler};
14use embassy_rp::peripherals::I2C1; 14use embassy_rp::peripherals::I2C1;
15use embassy_time::{Duration, Timer}; 15use embassy_time::Timer;
16use embedded_hal_async::i2c::I2c; 16use embedded_hal_async::i2c::I2c;
17use {defmt_rtt as _, panic_probe as _}; 17use {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 @@
10use defmt::*; 10use defmt::*;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_rp::i2c::{self, Config}; 12use embassy_rp::i2c::{self, Config};
13use embassy_time::{Duration, Timer}; 13use embassy_time::Timer;
14use embedded_hal_1::i2c::I2c; 14use embedded_hal_1::i2c::I2c;
15use {defmt_rtt as _, panic_probe as _}; 15use {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::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::peripherals::{I2C0, I2C1}; 8use embassy_rp::peripherals::{I2C0, I2C1};
9use embassy_rp::{bind_interrupts, i2c, i2c_slave}; 9use embassy_rp::{bind_interrupts, i2c, i2c_slave};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use embedded_hal_async::i2c::I2c; 11use embedded_hal_async::i2c::I2c;
12use {defmt_rtt as _, panic_probe as _}; 12use {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;
11use embassy_lora::iv::GenericSx126xInterfaceVariant; 11use embassy_lora::iv::GenericSx126xInterfaceVariant;
12use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; 12use embassy_rp::gpio::{Input, Level, Output, Pin, Pull};
13use embassy_rp::spi::{Config, Spi}; 13use embassy_rp::spi::{Config, Spi};
14use embassy_time::{Delay, Duration, Timer}; 14use embassy_time::{Delay, Timer};
15use lora_phy::mod_params::*; 15use lora_phy::mod_params::*;
16use lora_phy::sx1261_2::SX1261_2; 16use lora_phy::sx1261_2::SX1261_2;
17use lora_phy::LoRa; 17use 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;
15use embassy_rp::spi::{Async, Config, Spi}; 15use embassy_rp::spi::{Async, Config, Spi};
16use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 16use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
17use embassy_sync::channel::Channel; 17use embassy_sync::channel::Channel;
18use embassy_time::{Delay, Duration, Timer}; 18use embassy_time::{Delay, Timer};
19use lora_phy::mod_params::*; 19use lora_phy::mod_params::*;
20use lora_phy::sx1261_2::SX1261_2; 20use lora_phy::sx1261_2::SX1261_2;
21use lora_phy::LoRa; 21use 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};
13use embassy_rp::peripherals::PIN_25; 13use embassy_rp::peripherals::PIN_25;
14use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 14use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
15use embassy_sync::channel::Channel; 15use embassy_sync::channel::Channel;
16use embassy_time::{Duration, Timer}; 16use embassy_time::Timer;
17use static_cell::StaticCell; 17use static_cell::StaticCell;
18use {defmt_rtt as _, panic_probe as _}; 18use {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};
62use embassy_executor::{Executor, InterruptExecutor}; 62use embassy_executor::{Executor, InterruptExecutor};
63use embassy_rp::interrupt; 63use embassy_rp::interrupt;
64use embassy_rp::interrupt::{InterruptExt, Priority}; 64use embassy_rp::interrupt::{InterruptExt, Priority};
65use embassy_time::{Duration, Instant, Timer, TICK_HZ}; 65use embassy_time::{Instant, Timer, TICK_HZ};
66use static_cell::StaticCell; 66use static_cell::StaticCell;
67use {defmt_rtt as _, panic_probe as _}; 67use {defmt_rtt as _, panic_probe as _};
68 68
@@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _};
70async fn run_high() { 70async 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};
16use embassy_rp::pwm::{self, Pwm}; 16use embassy_rp::pwm::{self, Pwm};
17use embassy_rp::{bind_interrupts, into_ref, Peripheral, PeripheralRef}; 17use embassy_rp::{bind_interrupts, into_ref, Peripheral, PeripheralRef};
18use embassy_time::{Duration, Instant, Timer}; 18use embassy_time::{Instant, Timer};
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
20 20
21bind_interrupts!(pub struct Irqs { 21bind_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};
15use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; 15use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef};
16use embassy_time::{Duration, Timer}; 16use embassy_time::Timer;
17use fixed::types::U24F8; 17use fixed::types::U24F8;
18use fixed_macro::fixed; 18use fixed_macro::fixed;
19use smart_leds::RGB8; 19use 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 @@
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::pwm::{Config, Pwm}; 11use embassy_rp::pwm::{Config, Pwm};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {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/rosc.rs b/examples/rp/src/bin/rosc.rs
new file mode 100644
index 000000000..f841043b6
--- /dev/null
+++ b/examples/rp/src/bin/rosc.rs
@@ -0,0 +1,32 @@
1//! This example test the RP Pico on board LED.
2//!
3//! It does not work with the RP Pico W board. See wifi_blinky.rs.
4
5#![no_std]
6#![no_main]
7#![feature(type_alias_impl_trait)]
8
9use defmt::*;
10use embassy_executor::Spawner;
11use embassy_rp::{clocks, gpio};
12use embassy_time::Timer;
13use gpio::{Level, Output};
14use {defmt_rtt as _, panic_probe as _};
15
16#[embassy_executor::main]
17async fn main(_spawner: Spawner) {
18 let mut config = embassy_rp::config::Config::default();
19 config.clocks = clocks::ClockConfig::rosc();
20 let p = embassy_rp::init(config);
21 let mut led = Output::new(p.PIN_25, Level::Low);
22
23 loop {
24 info!("led on!");
25 led.set_high();
26 Timer::after_secs(1).await;
27
28 info!("led off!");
29 led.set_low();
30 Timer::after_secs(1).await;
31 }
32}
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 @@
7use defmt::*; 7use defmt::*;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_rp::rtc::{DateTime, DayOfWeek, Rtc}; 9use embassy_rp::rtc::{DateTime, DayOfWeek, Rtc};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {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 @@
8use defmt::*; 8use defmt::*;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_rp::spi::{Config, Spi}; 10use embassy_rp::spi::{Config, Spi};
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {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;
13use embassy_rp::bind_interrupts; 13use embassy_rp::bind_interrupts;
14use embassy_rp::peripherals::UART0; 14use embassy_rp::peripherals::UART0;
15use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config}; 15use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config};
16use embassy_time::{Duration, Timer}; 16use embassy_time::Timer;
17use embedded_io_async::{Read, Write}; 17use embedded_io_async::{Read, Write};
18use static_cell::make_static; 18use static_cell::make_static;
19use {defmt_rtt as _, panic_probe as _}; 19use {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;
14use embassy_rp::bind_interrupts; 14use embassy_rp::bind_interrupts;
15use embassy_rp::peripherals::UART1; 15use embassy_rp::peripherals::UART1;
16use embassy_rp::uart::{Async, Config, InterruptHandler, UartRx, UartTx}; 16use embassy_rp::uart::{Async, Config, InterruptHandler, UartRx, UartTx};
17use embassy_time::{Duration, Timer}; 17use embassy_time::Timer;
18use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
19 19
20bind_interrupts!(struct Irqs { 20bind_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_hid_keyboard.rs b/examples/rp/src/bin/usb_hid_keyboard.rs
index 99af1f02f..cc2090d22 100644
--- a/examples/rp/src/bin/usb_hid_keyboard.rs
+++ b/examples/rp/src/bin/usb_hid_keyboard.rs
@@ -78,6 +78,9 @@ async fn main(_spawner: Spawner) {
78 // Set up the signal pin that will be used to trigger the keyboard. 78 // Set up the signal pin that will be used to trigger the keyboard.
79 let mut signal_pin = Input::new(p.PIN_16, Pull::None); 79 let mut signal_pin = Input::new(p.PIN_16, Pull::None);
80 80
81 // Enable the schmitt trigger to slightly debounce.
82 signal_pin.set_schmitt(true);
83
81 let (reader, mut writer) = hid.split(); 84 let (reader, mut writer) = hid.split();
82 85
83 // Do stuff with the class! 86 // Do stuff with the class!
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;
10use embassy_rp::bind_interrupts; 10use embassy_rp::bind_interrupts;
11use embassy_rp::peripherals::USB; 11use embassy_rp::peripherals::USB;
12use embassy_rp::usb::{Driver, InterruptHandler}; 12use embassy_rp::usb::{Driver, InterruptHandler};
13use embassy_time::{Duration, Timer}; 13use embassy_time::Timer;
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
16bind_interrupts!(struct Irqs { 16bind_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/usb_midi.rs b/examples/rp/src/bin/usb_midi.rs
new file mode 100644
index 000000000..f0b03c81b
--- /dev/null
+++ b/examples/rp/src/bin/usb_midi.rs
@@ -0,0 +1,110 @@
1//! This example shows how to use USB (Universal Serial Bus) in the RP2040 chip.
2//!
3//! This creates a USB MIDI device that echoes MIDI messages back to the host.
4
5#![no_std]
6#![no_main]
7#![feature(type_alias_impl_trait)]
8
9use defmt::{info, panic};
10use embassy_executor::Spawner;
11use embassy_futures::join::join;
12use embassy_rp::bind_interrupts;
13use embassy_rp::peripherals::USB;
14use embassy_rp::usb::{Driver, Instance, InterruptHandler};
15use embassy_usb::class::midi::MidiClass;
16use embassy_usb::driver::EndpointError;
17use embassy_usb::{Builder, Config};
18use {defmt_rtt as _, panic_probe as _};
19
20bind_interrupts!(struct Irqs {
21 USBCTRL_IRQ => InterruptHandler<USB>;
22});
23
24#[embassy_executor::main]
25async fn main(_spawner: Spawner) {
26 info!("Hello world!");
27
28 let p = embassy_rp::init(Default::default());
29
30 // Create the driver, from the HAL.
31 let driver = Driver::new(p.USB, Irqs);
32
33 // Create embassy-usb Config
34 let mut config = Config::new(0xc0de, 0xcafe);
35 config.manufacturer = Some("Embassy");
36 config.product = Some("USB-MIDI example");
37 config.serial_number = Some("12345678");
38 config.max_power = 100;
39 config.max_packet_size_0 = 64;
40
41 // Required for windows compatibility.
42 // https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help
43 config.device_class = 0xEF;
44 config.device_sub_class = 0x02;
45 config.device_protocol = 0x01;
46 config.composite_with_iads = true;
47
48 // Create embassy-usb DeviceBuilder using the driver and config.
49 // It needs some buffers for building the descriptors.
50 let mut device_descriptor = [0; 256];
51 let mut config_descriptor = [0; 256];
52 let mut bos_descriptor = [0; 256];
53 let mut control_buf = [0; 64];
54
55 let mut builder = Builder::new(
56 driver,
57 config,
58 &mut device_descriptor,
59 &mut config_descriptor,
60 &mut bos_descriptor,
61 &mut control_buf,
62 );
63
64 // Create classes on the builder.
65 let mut class = MidiClass::new(&mut builder, 1, 1, 64);
66
67 // The `MidiClass` can be split into `Sender` and `Receiver`, to be used in separate tasks.
68 // let (sender, receiver) = class.split();
69
70 // Build the builder.
71 let mut usb = builder.build();
72
73 // Run the USB device.
74 let usb_fut = usb.run();
75
76 // Use the Midi class!
77 let midi_fut = async {
78 loop {
79 class.wait_connection().await;
80 info!("Connected");
81 let _ = midi_echo(&mut class).await;
82 info!("Disconnected");
83 }
84 };
85
86 // Run everything concurrently.
87 // If we had made everything `'static` above instead, we could do this using separate tasks instead.
88 join(usb_fut, midi_fut).await;
89}
90
91struct Disconnected {}
92
93impl From<EndpointError> for Disconnected {
94 fn from(val: EndpointError) -> Self {
95 match val {
96 EndpointError::BufferOverflow => panic!("Buffer overflow"),
97 EndpointError::Disabled => Disconnected {},
98 }
99 }
100}
101
102async fn midi_echo<'d, T: Instance + 'd>(class: &mut MidiClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> {
103 let mut buf = [0; 64];
104 loop {
105 let n = class.read_packet(&mut buf).await?;
106 let data = &buf[..n];
107 info!("data: {:x}", data);
108 class.write_packet(data).await?;
109 }
110}
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_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs
index cd61ad789..98cae53f6 100644
--- a/examples/rp/src/bin/wifi_ap_tcp_server.rs
+++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs
@@ -52,7 +52,7 @@ async fn main(spawner: Spawner) {
52 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`: 52 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
53 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000 53 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
54 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000 54 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
55 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) }; 55 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
56 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) }; 56 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
57 57
58 let pwr = Output::new(p.PIN_23, Level::Low); 58 let pwr = Output::new(p.PIN_23, Level::Low);
diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs
index 33d43788c..14ace74e9 100644
--- a/examples/rp/src/bin/wifi_blinky.rs
+++ b/examples/rp/src/bin/wifi_blinky.rs
@@ -38,7 +38,7 @@ async fn main(spawner: Spawner) {
38 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`: 38 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
39 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000 39 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
40 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000 40 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
41 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) }; 41 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
42 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) }; 42 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
43 43
44 let pwr = Output::new(p.PIN_23, Level::Low); 44 let pwr = Output::new(p.PIN_23, Level::Low);
diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs
index 743fab617..dbbbf6c81 100644
--- a/examples/rp/src/bin/wifi_scan.rs
+++ b/examples/rp/src/bin/wifi_scan.rs
@@ -49,7 +49,7 @@ async fn main(spawner: Spawner) {
49 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`: 49 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
50 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000 50 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
51 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000 51 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
52 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) }; 52 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
53 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) }; 53 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
54 54
55 let pwr = Output::new(p.PIN_23, Level::Low); 55 let pwr = Output::new(p.PIN_23, Level::Low);
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs
index 55fcb4a6a..c00fff216 100644
--- a/examples/rp/src/bin/wifi_tcp_server.rs
+++ b/examples/rp/src/bin/wifi_tcp_server.rs
@@ -18,7 +18,7 @@ use embassy_rp::bind_interrupts;
18use embassy_rp::gpio::{Level, Output}; 18use embassy_rp::gpio::{Level, Output};
19use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; 19use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
20use embassy_rp::pio::{InterruptHandler, Pio}; 20use embassy_rp::pio::{InterruptHandler, Pio};
21use embassy_time::Duration; 21use embassy_time::{Duration, Timer};
22use embedded_io_async::Write; 22use embedded_io_async::Write;
23use static_cell::make_static; 23use static_cell::make_static;
24use {defmt_rtt as _, panic_probe as _}; 24use {defmt_rtt as _, panic_probe as _};
@@ -55,7 +55,7 @@ async fn main(spawner: Spawner) {
55 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`: 55 // at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
56 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000 56 // probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
57 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000 57 // probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
58 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) }; 58 //let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
59 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) }; 59 //let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
60 60
61 let pwr = Output::new(p.PIN_23, Level::Low); 61 let pwr = Output::new(p.PIN_23, Level::Low);
@@ -102,6 +102,13 @@ async fn main(spawner: Spawner) {
102 } 102 }
103 } 103 }
104 104
105 // Wait for DHCP, not necessary when using static IP
106 info!("waiting for DHCP...");
107 while !stack.is_config_up() {
108 Timer::after_millis(100).await;
109 }
110 info!("DHCP is now up!");
111
105 // And now we can use it! 112 // And now we can use it!
106 113
107 let mut rx_buffer = [0; 4096]; 114 let mut rx_buffer = [0; 4096];
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml
index e54f36980..a5f4c8713 100644
--- a/examples/std/Cargo.toml
+++ b/examples/std/Cargo.toml
@@ -7,12 +7,12 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] } 8embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] }
9embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["log", "std", "nightly"] } 10embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "std", "nightly"] }
11embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } 11embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] }
12embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } 12embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" }
13embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} 13embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]}
14embedded-io-async = { version = "0.5.0" } 14embedded-io-async = { version = "0.6.0" }
15embedded-io-adapters = { version = "0.5.0", features = ["futures-03"] } 15embedded-io-adapters = { version = "0.6.0", features = ["futures-03"] }
16critical-section = { version = "1.1", features = ["std"] } 16critical-section = { version = "1.1", features = ["std"] }
17smoltcp = { version = "0.10.0", features = ["dns-max-server-count-4"] } 17smoltcp = { version = "0.10.0", features = ["dns-max-server-count-4"] }
18 18
diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs
index 9cf6e19df..9ea07b29a 100644
--- a/examples/std/src/bin/net_ppp.rs
+++ b/examples/std/src/bin/net_ppp.rs
@@ -8,7 +8,7 @@
8//! nc 192.168.7.10 1234 8//! nc 192.168.7.10 1234
9 9
10#![feature(type_alias_impl_trait)] 10#![feature(type_alias_impl_trait)]
11#![feature(async_fn_in_trait, impl_trait_projections)] 11#![feature(async_fn_in_trait)]
12 12
13#[path = "../serial_port.rs"] 13#[path = "../serial_port.rs"]
14mod serial_port; 14mod serial_port;
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
3use embassy_executor::Spawner; 3use embassy_executor::Spawner;
4use embassy_time::{Duration, Timer}; 4use embassy_time::Timer;
5use log::*; 5use log::*;
6 6
7#[embassy_executor::task] 7#[embassy_executor::task]
8async fn run() { 8async 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/Cargo.toml b/examples/stm32c0/Cargo.toml
index 89ecc4995..b80ccd302 100644
--- a/examples/stm32c0/Cargo.toml
+++ b/examples/stm32c0/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13 13
14defmt = "0.3" 14defmt = "0.3"
15defmt-rtt = "0.4" 15defmt-rtt = "0.4"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/Cargo.toml b/examples/stm32f0/Cargo.toml
index db9a24d73..47a95ec1e 100644
--- a/examples/stm32f0/Cargo.toml
+++ b/examples/stm32f0/Cargo.toml
@@ -16,7 +16,7 @@ defmt-rtt = "0.4"
16panic-probe = "0.3" 16panic-probe = "0.3"
17embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 17embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
18embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 18embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
19embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 19embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
20static_cell = { version = "1.1", features = ["nightly"]} 20static_cell = { version = "1.1", features = ["nightly"]}
21 21
22[profile.release] 22[profile.release]
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;
7use embassy_stm32::adc::{Adc, SampleTime}; 7use embassy_stm32::adc::{Adc, SampleTime};
8use embassy_stm32::peripherals::ADC; 8use embassy_stm32::peripherals::ADC;
9use embassy_stm32::{adc, bind_interrupts}; 9use embassy_stm32::{adc, bind_interrupts};
10use embassy_time::{Delay, Duration, Timer}; 10use embassy_time::{Delay, Timer};
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13bind_interrupts!(struct Irqs { 13bind_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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_stm32::exti::ExtiInput; 11use embassy_stm32::exti::ExtiInput;
12use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; 12use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
13use embassy_time::{Duration, Timer}; 13use embassy_time::Timer;
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
16static BLINK_MS: AtomicU32 = AtomicU32::new(0); 16static 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
5use defmt::info; 5use defmt::info;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_time::{Duration, Timer}; 7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
9 9
10#[embassy_executor::main] 10#[embassy_executor::main]
11async fn main(_spawner: Spawner) -> ! { 11async 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::*;
62use embassy_executor::{Executor, InterruptExecutor}; 62use embassy_executor::{Executor, InterruptExecutor};
63use embassy_stm32::interrupt; 63use embassy_stm32::interrupt;
64use embassy_stm32::interrupt::{InterruptExt, Priority}; 64use embassy_stm32::interrupt::{InterruptExt, Priority};
65use embassy_time::{Duration, Instant, Timer}; 65use embassy_time::{Instant, Timer};
66use static_cell::StaticCell; 66use static_cell::StaticCell;
67use {defmt_rtt as _, panic_probe as _}; 67use {defmt_rtt as _, panic_probe as _};
68 68
@@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _};
70async fn run_high() { 70async 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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::wdg::IndependentWatchdog; 7use embassy_stm32::wdg::IndependentWatchdog;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/Cargo.toml b/examples/stm32f1/Cargo.toml
index b032ba817..34319fbd8 100644
--- a/examples/stm32f1/Cargo.toml
+++ b/examples/stm32f1/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
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;
7use embassy_stm32::adc::Adc; 7use embassy_stm32::adc::Adc;
8use embassy_stm32::peripherals::ADC1; 8use embassy_stm32::peripherals::ADC1;
9use embassy_stm32::{adc, bind_interrupts}; 9use embassy_stm32::{adc, bind_interrupts};
10use embassy_time::{Delay, Duration, Timer}; 10use embassy_time::{Delay, Timer};
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13bind_interrupts!(struct Irqs { 13bind_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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::Hertz; 7use embassy_stm32::time::Hertz;
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {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};
9use embassy_stm32::time::Hertz; 9use embassy_stm32::time::Hertz;
10use embassy_stm32::usb::{Driver, Instance}; 10use embassy_stm32::usb::{Driver, Instance};
11use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; 11use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; 13use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
14use embassy_usb::driver::EndpointError; 14use embassy_usb::driver::EndpointError;
15use embassy_usb::Builder; 15use 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/Cargo.toml b/examples/stm32f2/Cargo.toml
index 1314b6b12..fbf508367 100644
--- a/examples/stm32f2/Cargo.toml
+++ b/examples/stm32f2/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13 13
14defmt = "0.3" 14defmt = "0.3"
15defmt-rtt = "0.4" 15defmt-rtt = "0.4"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 894937614..56591b527 100644
--- a/examples/stm32f2/src/bin/pll.rs
+++ b/examples/stm32f2/src/bin/pll.rs
@@ -7,11 +7,11 @@ use core::convert::TryFrom;
7use defmt::*; 7use defmt::*;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::rcc::{ 9use embassy_stm32::rcc::{
10 APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, 10 APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLLConfig, PLLMul, PLLPDiv, PLLPreDiv, PLLQDiv, PLLSrc,
11}; 11};
12use embassy_stm32::time::Hertz; 12use embassy_stm32::time::Hertz;
13use embassy_stm32::Config; 13use embassy_stm32::Config;
14use embassy_time::{Duration, Timer}; 14use embassy_time::Timer;
15use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
16 16
17#[embassy_executor::main] 17#[embassy_executor::main]
@@ -32,9 +32,9 @@ async fn main(_spawner: Spawner) {
32 // 1 MHz PLL input * 240 = 240 MHz PLL VCO 32 // 1 MHz PLL input * 240 = 240 MHz PLL VCO
33 mul: unwrap!(PLLMul::try_from(240)), 33 mul: unwrap!(PLLMul::try_from(240)),
34 // 240 MHz PLL VCO / 2 = 120 MHz main PLL output 34 // 240 MHz PLL VCO / 2 = 120 MHz main PLL output
35 main_div: PLLMainDiv::Div2, 35 p_div: PLLPDiv::DIV2,
36 // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output 36 // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output
37 pll48_div: unwrap!(PLL48Div::try_from(5)), 37 q_div: PLLQDiv::DIV5,
38 }; 38 };
39 // System clock comes from PLL (= the 120 MHz main PLL output) 39 // System clock comes from PLL (= the 120 MHz main PLL output)
40 config.rcc.mux = ClockSrc::PLL; 40 config.rcc.mux = ClockSrc::PLL;
@@ -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/Cargo.toml b/examples/stm32f3/Cargo.toml
index 534e783de..b3b2b1233 100644
--- a/examples/stm32f3/Cargo.toml
+++ b/examples/stm32f3/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::Hertz; 7use embassy_stm32::time::Hertz;
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {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::*;
62use embassy_executor::{Executor, InterruptExecutor}; 62use embassy_executor::{Executor, InterruptExecutor};
63use embassy_stm32::interrupt; 63use embassy_stm32::interrupt;
64use embassy_stm32::interrupt::{InterruptExt, Priority}; 64use embassy_stm32::interrupt::{InterruptExt, Priority};
65use embassy_time::{Duration, Instant, Timer}; 65use embassy_time::{Instant, Timer};
66use static_cell::StaticCell; 66use static_cell::StaticCell;
67use {defmt_rtt as _, panic_probe as _}; 67use {defmt_rtt as _, panic_probe as _};
68 68
@@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _};
70async fn run_high() { 70async 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};
9use embassy_stm32::time::mhz; 9use embassy_stm32::time::mhz;
10use embassy_stm32::usb::{Driver, Instance}; 10use embassy_stm32::usb::{Driver, Instance};
11use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; 11use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; 13use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
14use embassy_usb::driver::EndpointError; 14use embassy_usb::driver::EndpointError;
15use embassy_usb::Builder; 15use 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 ed246a7db..f259135d2 100644
--- a/examples/stm32f334/src/bin/adc.rs
+++ b/examples/stm32f334/src/bin/adc.rs
@@ -6,10 +6,10 @@ use defmt::info;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::adc::{Adc, SampleTime}; 7use embassy_stm32::adc::{Adc, SampleTime};
8use embassy_stm32::peripherals::ADC1; 8use embassy_stm32::peripherals::ADC1;
9use embassy_stm32::rcc::AdcClockSource; 9use embassy_stm32::rcc::{AdcClockSource, Adcpres};
10use embassy_stm32::time::mhz; 10use embassy_stm32::time::mhz;
11use embassy_stm32::{adc, bind_interrupts, Config}; 11use embassy_stm32::{adc, bind_interrupts, Config};
12use embassy_time::{Delay, Duration, Timer}; 12use embassy_time::{Delay, Timer};
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15bind_interrupts!(struct Irqs { 15bind_interrupts!(struct Irqs {
@@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) -> ! {
23 config.rcc.hclk = Some(mhz(64)); 23 config.rcc.hclk = Some(mhz(64));
24 config.rcc.pclk1 = Some(mhz(32)); 24 config.rcc.pclk1 = Some(mhz(32));
25 config.rcc.pclk2 = Some(mhz(64)); 25 config.rcc.pclk2 = Some(mhz(64));
26 config.rcc.adc = Some(AdcClockSource::PllDiv1); 26 config.rcc.adc = Some(AdcClockSource::Pll(Adcpres::DIV1));
27 27
28 let mut p = embassy_stm32::init(config); 28 let mut p = embassy_stm32::init(config);
29 29
@@ -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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::Hertz; 7use embassy_stm32::time::Hertz;
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {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
new file mode 100644
index 000000000..128001bf2
--- /dev/null
+++ b/examples/stm32f334/src/bin/opamp.rs
@@ -0,0 +1,59 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::info;
6use embassy_executor::Spawner;
7use embassy_stm32::adc::{Adc, SampleTime};
8use embassy_stm32::opamp::{OpAmp, OpAmpGain};
9use embassy_stm32::peripherals::ADC2;
10use embassy_stm32::rcc::{AdcClockSource, Adcpres};
11use embassy_stm32::time::mhz;
12use embassy_stm32::{adc, bind_interrupts, Config};
13use embassy_time::{Delay, Timer};
14use {defmt_rtt as _, panic_probe as _};
15
16bind_interrupts!(struct Irqs {
17 ADC1_2 => adc::InterruptHandler<ADC2>;
18});
19
20#[embassy_executor::main]
21async fn main(_spawner: Spawner) -> ! {
22 let mut config = Config::default();
23 config.rcc.sysclk = Some(mhz(64));
24 config.rcc.hclk = Some(mhz(64));
25 config.rcc.pclk1 = Some(mhz(32));
26 config.rcc.pclk2 = Some(mhz(64));
27 config.rcc.adc = Some(AdcClockSource::Pll(Adcpres::DIV1));
28
29 let mut p = embassy_stm32::init(config);
30
31 info!("create adc...");
32
33 let mut adc = Adc::new(p.ADC2, Irqs, &mut Delay);
34 let mut opamp = OpAmp::new(p.OPAMP2);
35
36 adc.set_sample_time(SampleTime::Cycles601_5);
37
38 info!("enable vrefint...");
39
40 let mut vrefint = adc.enable_vref(&mut Delay);
41 let mut temperature = adc.enable_temperature();
42 let mut buffer = opamp.buffer_for(&mut p.PA7, OpAmpGain::Mul1);
43
44 loop {
45 let vref = adc.read(&mut vrefint).await;
46 info!("read vref: {} (should be {})", vref, vrefint.value());
47
48 let temp = adc.read(&mut temperature).await;
49 info!("read temperature: {}", temp);
50
51 let buffer = adc.read(&mut buffer).await;
52 info!("read buffer: {}", buffer);
53
54 let pin_mv = (buffer as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095;
55 info!("computed pin mv: {}", pin_mv);
56
57 Timer::after_millis(500).await;
58 }
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::*;
8use embassy_stm32::rcc::HrtimClockSource; 8use embassy_stm32::rcc::HrtimClockSource;
9use embassy_stm32::time::{khz, mhz}; 9use embassy_stm32::time::{khz, mhz};
10use embassy_stm32::Config; 10use embassy_stm32::Config;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {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/Cargo.toml b/examples/stm32f4/Cargo.toml
index 4b4fb479b..9b10e9754 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -9,9 +9,9 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } 14embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
15 15
16defmt = "0.3" 16defmt = "0.3"
17defmt-rtt = "0.4" 17defmt-rtt = "0.4"
@@ -19,8 +19,8 @@ defmt-rtt = "0.4"
19cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 19cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
20cortex-m-rt = "0.7.0" 20cortex-m-rt = "0.7.0"
21embedded-hal = "0.2.6" 21embedded-hal = "0.2.6"
22embedded-io = { version = "0.5.0" } 22embedded-io = { version = "0.6.0" }
23embedded-io-async = { version = "0.5.0" } 23embedded-io-async = { version = "0.6.0" }
24panic-probe = { version = "0.3", features = ["print-defmt"] } 24panic-probe = { version = "0.3", features = ["print-defmt"] }
25futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 25futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
26heapless = { version = "0.7.5", default-features = false } 26heapless = { version = "0.7.5", default-features = false }
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;
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::adc::{Adc, Temperature, VrefInt}; 8use embassy_stm32::adc::{Adc, Temperature, VrefInt};
9use embassy_time::{Delay, Duration, Timer}; 9use embassy_time::{Delay, Timer};
10use {defmt_rtt as _, panic_probe as _}; 10use {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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 16bf5d949..1747bbf4b 100644
--- a/examples/stm32f4/src/bin/eth.rs
+++ b/examples/stm32f4/src/bin/eth.rs
@@ -10,9 +10,9 @@ use embassy_stm32::eth::generic_smi::GenericSMI;
10use embassy_stm32::eth::{Ethernet, PacketQueue}; 10use embassy_stm32::eth::{Ethernet, PacketQueue};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::Hertz;
14use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 14use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
15use embassy_time::{Duration, Timer}; 15use embassy_time::Timer;
16use embedded_io_async::Write; 16use embedded_io_async::Write;
17use static_cell::make_static; 17use static_cell::make_static;
18use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
@@ -32,7 +32,25 @@ async fn net_task(stack: &'static Stack<Device>) -> ! {
32#[embassy_executor::main] 32#[embassy_executor::main]
33async fn main(spawner: Spawner) -> ! { 33async fn main(spawner: Spawner) -> ! {
34 let mut config = Config::default(); 34 let mut config = Config::default();
35 config.rcc.sys_ck = Some(mhz(200)); 35 {
36 use embassy_stm32::rcc::*;
37 config.rcc.hse = Some(Hse {
38 freq: Hertz(8_000_000),
39 mode: HseMode::Bypass,
40 });
41 config.rcc.pll_src = PllSource::HSE;
42 config.rcc.pll = Some(Pll {
43 prediv: PllPreDiv::DIV4,
44 mul: PllMul::MUL180,
45 divp: Some(Pllp::DIV2), // 8mhz / 4 * 180 / 2 = 180Mhz.
46 divq: None,
47 divr: None,
48 });
49 config.rcc.ahb_pre = AHBPrescaler::DIV1;
50 config.rcc.apb1_pre = APBPrescaler::DIV4;
51 config.rcc.apb2_pre = APBPrescaler::DIV2;
52 config.rcc.sys = Sysclk::PLL1_P;
53 }
36 let p = embassy_stm32::init(config); 54 let p = embassy_stm32::init(config);
37 55
38 info!("Hello World!"); 56 info!("Hello World!");
@@ -58,9 +76,8 @@ async fn main(spawner: Spawner) -> ! {
58 p.PG13, 76 p.PG13,
59 p.PB13, 77 p.PB13,
60 p.PG11, 78 p.PG11,
61 GenericSMI::new(), 79 GenericSMI::new(0),
62 mac_addr, 80 mac_addr,
63 0,
64 ); 81 );
65 82
66 let config = embassy_net::Config::dhcpv4(Default::default()); 83 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -100,7 +117,7 @@ async fn main(spawner: Spawner) -> ! {
100 let r = socket.connect(remote_endpoint).await; 117 let r = socket.connect(remote_endpoint).await;
101 if let Err(e) = r { 118 if let Err(e) = r {
102 info!("connect error: {:?}", e); 119 info!("connect error: {:?}", e);
103 Timer::after(Duration::from_secs(1)).await; 120 Timer::after_secs(1).await;
104 continue; 121 continue;
105 } 122 }
106 info!("connected!"); 123 info!("connected!");
@@ -111,7 +128,7 @@ async fn main(spawner: Spawner) -> ! {
111 info!("write error: {:?}", e); 128 info!("write error: {:?}", e);
112 break; 129 break;
113 } 130 }
114 Timer::after(Duration::from_secs(1)).await; 131 Timer::after_secs(1).await;
115 } 132 }
116 } 133 }
117} 134}
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;
7use embassy_stm32::bind_interrupts; 7use embassy_stm32::bind_interrupts;
8use embassy_stm32::flash::{Flash, InterruptHandler}; 8use embassy_stm32::flash::{Flash, InterruptHandler};
9use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed}; 9use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Speed};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13bind_interrupts!(struct Irqs { 13bind_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..a2a287110 100644
--- a/examples/stm32f4/src/bin/hello.rs
+++ b/examples/stm32f4/src/bin/hello.rs
@@ -4,19 +4,17 @@
4 4
5use defmt::info; 5use defmt::info;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::Hertz;
8use embassy_stm32::Config; 7use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
11 10
12#[embassy_executor::main] 11#[embassy_executor::main]
13async fn main(_spawner: Spawner) -> ! { 12async fn main(_spawner: Spawner) -> ! {
14 let mut config = Config::default(); 13 let config = Config::default();
15 config.rcc.sys_ck = Some(Hertz(84_000_000));
16 let _p = embassy_stm32::init(config); 14 let _p = embassy_stm32::init(config);
17 15
18 loop { 16 loop {
19 info!("Hello World!"); 17 info!("Hello World!");
20 Timer::after(Duration::from_secs(1)).await; 18 Timer::after_secs(1).await;
21 } 19 }
22} 20}
diff --git a/examples/stm32f4/src/bin/i2c.rs b/examples/stm32f4/src/bin/i2c.rs
index a92957325..032bd97ee 100644
--- a/examples/stm32f4/src/bin/i2c.rs
+++ b/examples/stm32f4/src/bin/i2c.rs
@@ -5,10 +5,9 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::dma::NoDma; 7use embassy_stm32::dma::NoDma;
8use embassy_stm32::i2c::{Error, I2c, TimeoutI2c}; 8use embassy_stm32::i2c::{Error, I2c};
9use embassy_stm32::time::Hertz; 9use embassy_stm32::time::Hertz;
10use embassy_stm32::{bind_interrupts, i2c, peripherals}; 10use embassy_stm32::{bind_interrupts, i2c, peripherals};
11use embassy_time::Duration;
12use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
13 12
14const ADDRESS: u8 = 0x5F; 13const ADDRESS: u8 = 0x5F;
@@ -34,13 +33,9 @@ async fn main(_spawner: Spawner) {
34 Default::default(), 33 Default::default(),
35 ); 34 );
36 35
37 // I2C bus can freeze if SCL line is shorted or due to a broken device that clock stretches for too long.
38 // TimeoutI2c allows recovering from such errors by throwing `Error::Timeout` after a given delay.
39 let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000));
40
41 let mut data = [0u8; 1]; 36 let mut data = [0u8; 1];
42 37
43 match timeout_i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) { 38 match i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) {
44 Ok(()) => info!("Whoami: {}", data[0]), 39 Ok(()) => info!("Whoami: {}", data[0]),
45 Err(Error::Timeout) => error!("Operation timed out"), 40 Err(Error::Timeout) => error!("Operation timed out"),
46 Err(e) => error!("I2c Error: {:?}", e), 41 Err(e) => error!("I2c Error: {:?}", e),
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs
index 2b9ceebc3..3315e7652 100644
--- a/examples/stm32f4/src/bin/mco.rs
+++ b/examples/stm32f4/src/bin/mco.rs
@@ -5,8 +5,8 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoClock}; 8use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -14,17 +14,17 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello World!"); 15 info!("Hello World!");
16 16
17 let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::DIV1); 17 let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV1);
18 let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::Pll, McoClock::DIV4); 18 let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, McoPrescaler::DIV4);
19 let mut led = Output::new(p.PB7, Level::High, Speed::Low); 19 let mut led = Output::new(p.PB7, Level::High, Speed::Low);
20 20
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::*;
62use embassy_executor::{Executor, InterruptExecutor}; 62use embassy_executor::{Executor, InterruptExecutor};
63use embassy_stm32::interrupt; 63use embassy_stm32::interrupt;
64use embassy_stm32::interrupt::{InterruptExt, Priority}; 64use embassy_stm32::interrupt::{InterruptExt, Priority};
65use embassy_time::{Duration, Instant, Timer}; 65use embassy_time::{Instant, Timer};
66use static_cell::StaticCell; 66use static_cell::StaticCell;
67use {defmt_rtt as _, panic_probe as _}; 67use {defmt_rtt as _, panic_probe as _};
68 68
@@ -70,7 +70,7 @@ use {defmt_rtt as _, panic_probe as _};
70async fn run_high() { 70async 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 139b8de70..8e41d0e78 100644
--- a/examples/stm32f4/src/bin/pwm.rs
+++ b/examples/stm32f4/src/bin/pwm.rs
@@ -8,7 +8,7 @@ use embassy_stm32::gpio::OutputType;
8use embassy_stm32::time::khz; 8use embassy_stm32::time::khz;
9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; 9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
10use embassy_stm32::timer::Channel; 10use embassy_stm32::timer::Channel;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {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 dabbbf9ac..d925f26d9 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;
9use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; 9use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin};
10use embassy_stm32::timer::simple_pwm::PwmPin; 10use embassy_stm32::timer::simple_pwm::PwmPin;
11use embassy_stm32::timer::Channel; 11use embassy_stm32::timer::Channel;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15#[embassy_executor::main] 15#[embassy_executor::main]
@@ -43,12 +43,12 @@ async fn main(_spawner: Spawner) {
43 43
44 loop { 44 loop {
45 pwm.set_duty(Channel::Ch1, 0); 45 pwm.set_duty(Channel::Ch1, 0);
46 Timer::after(Duration::from_millis(300)).await; 46 Timer::after_millis(300).await;
47 pwm.set_duty(Channel::Ch1, max / 4); 47 pwm.set_duty(Channel::Ch1, max / 4);
48 Timer::after(Duration::from_millis(300)).await; 48 Timer::after_millis(300).await;
49 pwm.set_duty(Channel::Ch1, max / 2); 49 pwm.set_duty(Channel::Ch1, max / 2);
50 Timer::after(Duration::from_millis(300)).await; 50 Timer::after_millis(300).await;
51 pwm.set_duty(Channel::Ch1, max - 1); 51 pwm.set_duty(Channel::Ch1, max - 1);
52 Timer::after(Duration::from_millis(300)).await; 52 Timer::after_millis(300).await;
53 } 53 }
54} 54}
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs
index e33746008..44b4303c0 100644
--- a/examples/stm32f4/src/bin/rtc.rs
+++ b/examples/stm32f4/src/bin/rtc.rs
@@ -5,16 +5,14 @@
5use chrono::{NaiveDate, NaiveDateTime}; 5use chrono::{NaiveDate, NaiveDateTime};
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig}; 8use embassy_stm32::rtc::{Rtc, RtcConfig};
9use embassy_stm32::Config; 9use embassy_stm32::Config;
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13#[embassy_executor::main] 13#[embassy_executor::main]
14async fn main(_spawner: Spawner) { 14async fn main(_spawner: Spawner) {
15 let mut config = Config::default(); 15 let config = Config::default();
16 config.rcc.lsi = true;
17 config.rcc.rtc = Option::Some(RtcClockSource::LSI);
18 let p = embassy_stm32::init(config); 16 let p = embassy_stm32::init(config);
19 17
20 info!("Hello World!"); 18 info!("Hello World!");
@@ -33,6 +31,6 @@ async fn main(_spawner: Spawner) {
33 31
34 info!("{}", now.timestamp()); 32 info!("{}", now.timestamp());
35 33
36 Timer::after(Duration::from_millis(1000)).await; 34 Timer::after_millis(1000).await;
37 } 35 }
38} 36}
diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs
index 6ec7d0fec..37e42384b 100644
--- a/examples/stm32f4/src/bin/sdmmc.rs
+++ b/examples/stm32f4/src/bin/sdmmc.rs
@@ -5,7 +5,7 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; 7use embassy_stm32::sdmmc::{DataBlock, Sdmmc};
8use embassy_stm32::time::mhz; 8use embassy_stm32::time::{mhz, Hertz};
9use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
@@ -20,8 +20,25 @@ bind_interrupts!(struct Irqs {
20#[embassy_executor::main] 20#[embassy_executor::main]
21async fn main(_spawner: Spawner) { 21async fn main(_spawner: Spawner) {
22 let mut config = Config::default(); 22 let mut config = Config::default();
23 config.rcc.sys_ck = Some(mhz(48)); 23 {
24 config.rcc.pll48 = true; 24 use embassy_stm32::rcc::*;
25 config.rcc.hse = Some(Hse {
26 freq: Hertz(8_000_000),
27 mode: HseMode::Bypass,
28 });
29 config.rcc.pll_src = PllSource::HSE;
30 config.rcc.pll = Some(Pll {
31 prediv: PllPreDiv::DIV4,
32 mul: PllMul::MUL168,
33 divp: Some(Pllp::DIV2), // 8mhz / 4 * 168 / 2 = 168Mhz.
34 divq: Some(Pllq::DIV7), // 8mhz / 4 * 168 / 7 = 48Mhz.
35 divr: None,
36 });
37 config.rcc.ahb_pre = AHBPrescaler::DIV1;
38 config.rcc.apb1_pre = APBPrescaler::DIV4;
39 config.rcc.apb2_pre = APBPrescaler::DIV2;
40 config.rcc.sys = Sysclk::PLL1_P;
41 }
25 let p = embassy_stm32::init(config); 42 let p = embassy_stm32::init(config);
26 info!("Hello World!"); 43 info!("Hello World!");
27 44
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs
index 763e3a9e7..7c0644aeb 100644
--- a/examples/stm32f4/src/bin/usb_ethernet.rs
+++ b/examples/stm32f4/src/bin/usb_ethernet.rs
@@ -7,7 +7,7 @@ use embassy_executor::Spawner;
7use embassy_net::tcp::TcpSocket; 7use embassy_net::tcp::TcpSocket;
8use embassy_net::{Stack, StackResources}; 8use embassy_net::{Stack, StackResources};
9use embassy_stm32::rng::{self, Rng}; 9use embassy_stm32::rng::{self, Rng};
10use embassy_stm32::time::mhz; 10use embassy_stm32::time::Hertz;
11use embassy_stm32::usb_otg::Driver; 11use embassy_stm32::usb_otg::Driver;
12use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; 12use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
13use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; 13use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState};
@@ -46,9 +46,25 @@ async fn main(spawner: Spawner) {
46 info!("Hello World!"); 46 info!("Hello World!");
47 47
48 let mut config = Config::default(); 48 let mut config = Config::default();
49 config.rcc.pll48 = true; 49 {
50 config.rcc.sys_ck = Some(mhz(48)); 50 use embassy_stm32::rcc::*;
51 51 config.rcc.hse = Some(Hse {
52 freq: Hertz(8_000_000),
53 mode: HseMode::Bypass,
54 });
55 config.rcc.pll_src = PllSource::HSE;
56 config.rcc.pll = Some(Pll {
57 prediv: PllPreDiv::DIV4,
58 mul: PllMul::MUL168,
59 divp: Some(Pllp::DIV2), // 8mhz / 4 * 168 / 2 = 168Mhz.
60 divq: Some(Pllq::DIV7), // 8mhz / 4 * 168 / 7 = 48Mhz.
61 divr: None,
62 });
63 config.rcc.ahb_pre = AHBPrescaler::DIV1;
64 config.rcc.apb1_pre = APBPrescaler::DIV4;
65 config.rcc.apb2_pre = APBPrescaler::DIV2;
66 config.rcc.sys = Sysclk::PLL1_P;
67 }
52 let p = embassy_stm32::init(config); 68 let p = embassy_stm32::init(config);
53 69
54 // Create the driver, from the HAL. 70 // Create the driver, from the HAL.
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs
index 4ff6452ef..004ff038d 100644
--- a/examples/stm32f4/src/bin/usb_serial.rs
+++ b/examples/stm32f4/src/bin/usb_serial.rs
@@ -4,7 +4,7 @@
4 4
5use defmt::{panic, *}; 5use defmt::{panic, *};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::mhz; 7use embassy_stm32::time::Hertz;
8use embassy_stm32::usb_otg::{Driver, Instance}; 8use embassy_stm32::usb_otg::{Driver, Instance};
9use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
10use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; 10use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
@@ -22,9 +22,25 @@ async fn main(_spawner: Spawner) {
22 info!("Hello World!"); 22 info!("Hello World!");
23 23
24 let mut config = Config::default(); 24 let mut config = Config::default();
25 config.rcc.pll48 = true; 25 {
26 config.rcc.sys_ck = Some(mhz(48)); 26 use embassy_stm32::rcc::*;
27 27 config.rcc.hse = Some(Hse {
28 freq: Hertz(8_000_000),
29 mode: HseMode::Bypass,
30 });
31 config.rcc.pll_src = PllSource::HSE;
32 config.rcc.pll = Some(Pll {
33 prediv: PllPreDiv::DIV4,
34 mul: PllMul::MUL168,
35 divp: Some(Pllp::DIV2), // 8mhz / 4 * 168 / 2 = 168Mhz.
36 divq: Some(Pllq::DIV7), // 8mhz / 4 * 168 / 7 = 48Mhz.
37 divr: None,
38 });
39 config.rcc.ahb_pre = AHBPrescaler::DIV1;
40 config.rcc.apb1_pre = APBPrescaler::DIV4;
41 config.rcc.apb2_pre = APBPrescaler::DIV2;
42 config.rcc.sys = Sysclk::PLL1_P;
43 }
28 let p = embassy_stm32::init(config); 44 let p = embassy_stm32::init(config);
29 45
30 // Create the driver, from the HAL. 46 // Create the driver, from the HAL.
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::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::wdg::IndependentWatchdog; 8use embassy_stm32::wdg::IndependentWatchdog;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {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/Cargo.toml b/examples/stm32f7/Cargo.toml
index bf8f413d8..5cbaca461 100644
--- a/examples/stm32f7/Cargo.toml
+++ b/examples/stm32f7/Cargo.toml
@@ -9,9 +9,9 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } 13embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] }
14embedded-io-async = { version = "0.5.0" } 14embedded-io-async = { version = "0.6.0" }
15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
16 16
17defmt = "0.3" 17defmt = "0.3"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::adc::Adc; 7use embassy_stm32::adc::Adc;
8use embassy_time::{Delay, Duration, Timer}; 8use embassy_time::{Delay, Timer};
9use {defmt_rtt as _, panic_probe as _}; 9use {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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 93c97c8ee..7c6c419a6 100644
--- a/examples/stm32f7/src/bin/eth.rs
+++ b/examples/stm32f7/src/bin/eth.rs
@@ -10,9 +10,9 @@ use embassy_stm32::eth::generic_smi::GenericSMI;
10use embassy_stm32::eth::{Ethernet, PacketQueue}; 10use embassy_stm32::eth::{Ethernet, PacketQueue};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::Hertz;
14use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 14use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
15use embassy_time::{Duration, Timer}; 15use embassy_time::Timer;
16use embedded_io_async::Write; 16use embedded_io_async::Write;
17use rand_core::RngCore; 17use rand_core::RngCore;
18use static_cell::make_static; 18use static_cell::make_static;
@@ -33,7 +33,25 @@ async fn net_task(stack: &'static Stack<Device>) -> ! {
33#[embassy_executor::main] 33#[embassy_executor::main]
34async fn main(spawner: Spawner) -> ! { 34async fn main(spawner: Spawner) -> ! {
35 let mut config = Config::default(); 35 let mut config = Config::default();
36 config.rcc.sys_ck = Some(mhz(200)); 36 {
37 use embassy_stm32::rcc::*;
38 config.rcc.hse = Some(Hse {
39 freq: Hertz(8_000_000),
40 mode: HseMode::Bypass,
41 });
42 config.rcc.pll_src = PllSource::HSE;
43 config.rcc.pll = Some(Pll {
44 prediv: PllPreDiv::DIV4,
45 mul: PllMul::MUL216,
46 divp: Some(Pllp::DIV2), // 8mhz / 4 * 216 / 2 = 216Mhz
47 divq: None,
48 divr: None,
49 });
50 config.rcc.ahb_pre = AHBPrescaler::DIV1;
51 config.rcc.apb1_pre = APBPrescaler::DIV4;
52 config.rcc.apb2_pre = APBPrescaler::DIV2;
53 config.rcc.sys = Sysclk::PLL1_P;
54 }
37 let p = embassy_stm32::init(config); 55 let p = embassy_stm32::init(config);
38 56
39 info!("Hello World!"); 57 info!("Hello World!");
@@ -59,9 +77,8 @@ async fn main(spawner: Spawner) -> ! {
59 p.PG13, 77 p.PG13,
60 p.PB13, 78 p.PB13,
61 p.PG11, 79 p.PG11,
62 GenericSMI::new(), 80 GenericSMI::new(0),
63 mac_addr, 81 mac_addr,
64 0,
65 ); 82 );
66 83
67 let config = embassy_net::Config::dhcpv4(Default::default()); 84 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -101,7 +118,7 @@ async fn main(spawner: Spawner) -> ! {
101 let r = socket.connect(remote_endpoint).await; 118 let r = socket.connect(remote_endpoint).await;
102 if let Err(e) = r { 119 if let Err(e) = r {
103 info!("connect error: {:?}", e); 120 info!("connect error: {:?}", e);
104 Timer::after(Duration::from_secs(1)).await; 121 Timer::after_secs(1).await;
105 continue; 122 continue;
106 } 123 }
107 info!("connected!"); 124 info!("connected!");
@@ -112,7 +129,7 @@ async fn main(spawner: Spawner) -> ! {
112 info!("write error: {:?}", e); 129 info!("write error: {:?}", e);
113 break; 130 break;
114 } 131 }
115 Timer::after(Duration::from_secs(1)).await; 132 Timer::after_secs(1).await;
116 } 133 }
117 } 134 }
118} 135}
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 @@
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::flash::Flash; 7use embassy_stm32::flash::Flash;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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..a2a287110 100644
--- a/examples/stm32f7/src/bin/hello.rs
+++ b/examples/stm32f7/src/bin/hello.rs
@@ -4,19 +4,17 @@
4 4
5use defmt::info; 5use defmt::info;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::Hertz;
8use embassy_stm32::Config; 7use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
11 10
12#[embassy_executor::main] 11#[embassy_executor::main]
13async fn main(_spawner: Spawner) -> ! { 12async fn main(_spawner: Spawner) -> ! {
14 let mut config = Config::default(); 13 let config = Config::default();
15 config.rcc.sys_ck = Some(Hertz(84_000_000));
16 let _p = embassy_stm32::init(config); 14 let _p = embassy_stm32::init(config);
17 15
18 loop { 16 loop {
19 info!("Hello World!"); 17 info!("Hello World!");
20 Timer::after(Duration::from_secs(1)).await; 18 Timer::after_secs(1).await;
21 } 19 }
22} 20}
diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs
index 9d43892a0..430aa781f 100644
--- a/examples/stm32f7/src/bin/sdmmc.rs
+++ b/examples/stm32f7/src/bin/sdmmc.rs
@@ -5,7 +5,7 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::sdmmc::Sdmmc; 7use embassy_stm32::sdmmc::Sdmmc;
8use embassy_stm32::time::mhz; 8use embassy_stm32::time::{mhz, Hertz};
9use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
@@ -16,8 +16,25 @@ bind_interrupts!(struct Irqs {
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let mut config = Config::default(); 18 let mut config = Config::default();
19 config.rcc.sys_ck = Some(mhz(200)); 19 {
20 config.rcc.pll48 = true; 20 use embassy_stm32::rcc::*;
21 config.rcc.hse = Some(Hse {
22 freq: Hertz(8_000_000),
23 mode: HseMode::Bypass,
24 });
25 config.rcc.pll_src = PllSource::HSE;
26 config.rcc.pll = Some(Pll {
27 prediv: PllPreDiv::DIV4,
28 mul: PllMul::MUL216,
29 divp: Some(Pllp::DIV2), // 8mhz / 4 * 216 / 2 = 216Mhz
30 divq: Some(Pllq::DIV9), // 8mhz / 4 * 216 / 9 = 48Mhz
31 divr: None,
32 });
33 config.rcc.ahb_pre = AHBPrescaler::DIV1;
34 config.rcc.apb1_pre = APBPrescaler::DIV4;
35 config.rcc.apb2_pre = APBPrescaler::DIV2;
36 config.rcc.sys = Sysclk::PLL1_P;
37 }
21 let p = embassy_stm32::init(config); 38 let p = embassy_stm32::init(config);
22 39
23 info!("Hello World!"); 40 info!("Hello World!");
diff --git a/examples/stm32f7/src/bin/usb_serial.rs b/examples/stm32f7/src/bin/usb_serial.rs
index a2c76178b..2f832c234 100644
--- a/examples/stm32f7/src/bin/usb_serial.rs
+++ b/examples/stm32f7/src/bin/usb_serial.rs
@@ -4,7 +4,7 @@
4 4
5use defmt::{panic, *}; 5use defmt::{panic, *};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::time::mhz; 7use embassy_stm32::time::Hertz;
8use embassy_stm32::usb_otg::{Driver, Instance}; 8use embassy_stm32::usb_otg::{Driver, Instance};
9use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
10use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; 10use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
@@ -22,10 +22,25 @@ async fn main(_spawner: Spawner) {
22 info!("Hello World!"); 22 info!("Hello World!");
23 23
24 let mut config = Config::default(); 24 let mut config = Config::default();
25 config.rcc.hse = Some(mhz(8)); 25 {
26 config.rcc.pll48 = true; 26 use embassy_stm32::rcc::*;
27 config.rcc.sys_ck = Some(mhz(200)); 27 config.rcc.hse = Some(Hse {
28 28 freq: Hertz(8_000_000),
29 mode: HseMode::Bypass,
30 });
31 config.rcc.pll_src = PllSource::HSE;
32 config.rcc.pll = Some(Pll {
33 prediv: PllPreDiv::DIV4,
34 mul: PllMul::MUL216,
35 divp: Some(Pllp::DIV2), // 8mhz / 4 * 216 / 2 = 216Mhz
36 divq: Some(Pllq::DIV9), // 8mhz / 4 * 216 / 9 = 48Mhz
37 divr: None,
38 });
39 config.rcc.ahb_pre = AHBPrescaler::DIV1;
40 config.rcc.apb1_pre = APBPrescaler::DIV4;
41 config.rcc.apb2_pre = APBPrescaler::DIV2;
42 config.rcc.sys = Sysclk::PLL1_P;
43 }
29 let p = embassy_stm32::init(config); 44 let p = embassy_stm32::init(config);
30 45
31 // Create the driver, from the HAL. 46 // Create the driver, from the HAL.
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml
index b4b423d58..d0b7d85f8 100644
--- a/examples/stm32g0/Cargo.toml
+++ b/examples/stm32g0/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13 13
14defmt = "0.3" 14defmt = "0.3"
15defmt-rtt = "0.4" 15defmt-rtt = "0.4"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
8use embassy_stm32::dma::NoDma; 8use embassy_stm32::dma::NoDma;
9use embassy_stm32::spi::{Config, Spi}; 9use embassy_stm32::spi::{Config, Spi};
10use embassy_stm32::time::Hertz; 10use embassy_stm32::time::Hertz;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14const NR_PIXELS: usize = 15; 14const 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/Cargo.toml b/examples/stm32g4/Cargo.toml
index 59da06283..908c6d19d 100644
--- a/examples/stm32g4/Cargo.toml
+++ b/examples/stm32g4/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15usbd-hid = "0.6.0" 15usbd-hid = "0.6.0"
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs
index a792748bc..db7f6ecb5 100644
--- a/examples/stm32g4/src/bin/adc.rs
+++ b/examples/stm32g4/src/bin/adc.rs
@@ -7,7 +7,7 @@ use embassy_executor::Spawner;
7use embassy_stm32::adc::{Adc, SampleTime}; 7use embassy_stm32::adc::{Adc, SampleTime};
8use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; 8use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc};
9use embassy_stm32::Config; 9use embassy_stm32::Config;
10use embassy_time::{Delay, Duration, Timer}; 10use embassy_time::{Delay, Timer};
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13#[embassy_executor::main] 13#[embassy_executor::main]
@@ -16,15 +16,15 @@ async fn main(_spawner: Spawner) {
16 16
17 config.rcc.pll = Some(Pll { 17 config.rcc.pll = Some(Pll {
18 source: PllSrc::HSI16, 18 source: PllSrc::HSI16,
19 prediv_m: PllM::Div4, 19 prediv_m: PllM::DIV4,
20 mul_n: PllN::Mul85, 20 mul_n: PllN::MUL85,
21 div_p: None, 21 div_p: None,
22 div_q: None, 22 div_q: None,
23 // Main system clock at 170 MHz 23 // Main system clock at 170 MHz
24 div_r: Some(PllR::Div2), 24 div_r: Some(PllR::DIV2),
25 }); 25 });
26 26
27 config.rcc.adc12_clock_source = AdcClockSource::SysClk; 27 config.rcc.adc12_clock_source = AdcClockSource::SYS;
28 config.rcc.mux = ClockSrc::PLL; 28 config.rcc.mux = ClockSrc::PLL;
29 29
30 let mut p = embassy_stm32::init(config); 30 let mut p = embassy_stm32::init(config);
@@ -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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 ef7d4800c..43242647f 100644
--- a/examples/stm32g4/src/bin/pll.rs
+++ b/examples/stm32g4/src/bin/pll.rs
@@ -6,7 +6,7 @@ use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; 7use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc};
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -15,12 +15,12 @@ async fn main(_spawner: Spawner) {
15 15
16 config.rcc.pll = Some(Pll { 16 config.rcc.pll = Some(Pll {
17 source: PllSrc::HSI16, 17 source: PllSrc::HSI16,
18 prediv_m: PllM::Div4, 18 prediv_m: PllM::DIV4,
19 mul_n: PllN::Mul85, 19 mul_n: PllN::MUL85,
20 div_p: None, 20 div_p: None,
21 div_q: None, 21 div_q: None,
22 // Main system clock at 170 MHz 22 // Main system clock at 170 MHz
23 div_r: Some(PllR::Div2), 23 div_r: Some(PllR::DIV2),
24 }); 24 });
25 25
26 config.rcc.mux = ClockSrc::PLL; 26 config.rcc.mux = ClockSrc::PLL;
@@ -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 c62b11d13..a84394005 100644
--- a/examples/stm32g4/src/bin/pwm.rs
+++ b/examples/stm32g4/src/bin/pwm.rs
@@ -8,7 +8,7 @@ use embassy_stm32::gpio::OutputType;
8use embassy_stm32::time::khz; 8use embassy_stm32::time::khz;
9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; 9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
10use embassy_stm32::timer::Channel; 10use embassy_stm32::timer::Channel;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {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/stm32g4/src/bin/usb_serial.rs b/examples/stm32g4/src/bin/usb_serial.rs
index 77cfa67d3..9099b609a 100644
--- a/examples/stm32g4/src/bin/usb_serial.rs
+++ b/examples/stm32g4/src/bin/usb_serial.rs
@@ -25,16 +25,16 @@ async fn main(_spawner: Spawner) {
25 // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE. 25 // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE.
26 const USE_HSI48: bool = true; 26 const USE_HSI48: bool = true;
27 27
28 let pllq_div = if USE_HSI48 { None } else { Some(PllQ::Div6) }; 28 let pllq_div = if USE_HSI48 { None } else { Some(PllQ::DIV6) };
29 29
30 config.rcc.pll = Some(Pll { 30 config.rcc.pll = Some(Pll {
31 source: PllSrc::HSE(Hertz(8_000_000)), 31 source: PllSrc::HSE(Hertz(8_000_000)),
32 prediv_m: PllM::Div2, 32 prediv_m: PllM::DIV2,
33 mul_n: PllN::Mul72, 33 mul_n: PllN::MUL72,
34 div_p: None, 34 div_p: None,
35 div_q: pllq_div, 35 div_q: pllq_div,
36 // Main system clock at 144 MHz 36 // Main system clock at 144 MHz
37 div_r: Some(PllR::Div2), 37 div_r: Some(PllR::DIV2),
38 }); 38 });
39 39
40 config.rcc.mux = ClockSrc::PLL; 40 config.rcc.mux = ClockSrc::PLL;
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml
index 42a426185..f5980d87a 100644
--- a/examples/stm32h5/Cargo.toml
+++ b/examples/stm32h5/Cargo.toml
@@ -9,9 +9,9 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
13embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } 13embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] }
14embedded-io-async = { version = "0.5.0" } 14embedded-io-async = { version = "0.6.0" }
15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
16 16
17defmt = "0.3" 17defmt = "0.3"
@@ -22,7 +22,7 @@ cortex-m-rt = "0.7.0"
22embedded-hal = "0.2.6" 22embedded-hal = "0.2.6"
23embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } 23embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" }
24embedded-hal-async = { version = "=1.0.0-rc.1" } 24embedded-hal-async = { version = "=1.0.0-rc.1" }
25embedded-nal-async = { version = "0.5.0" } 25embedded-nal-async = { version = "0.6.0" }
26panic-probe = { version = "0.3", features = ["print-defmt"] } 26panic-probe = { version = "0.3", features = ["print-defmt"] }
27futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 27futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
28heapless = { version = "0.7.5", default-features = false } 28heapless = { version = "0.7.5", default-features = false }
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 4e92d0647..6e40f0ac0 100644
--- a/examples/stm32h5/src/bin/eth.rs
+++ b/examples/stm32h5/src/bin/eth.rs
@@ -9,11 +9,13 @@ use embassy_net::{Ipv4Address, Stack, StackResources};
9use embassy_stm32::eth::generic_smi::GenericSMI; 9use embassy_stm32::eth::generic_smi::GenericSMI;
10use embassy_stm32::eth::{Ethernet, PacketQueue}; 10use embassy_stm32::eth::{Ethernet, PacketQueue};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rcc::{AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllSource, Sysclk, VoltageScale}; 12use embassy_stm32::rcc::{
13 AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale,
14};
13use embassy_stm32::rng::Rng; 15use embassy_stm32::rng::Rng;
14use embassy_stm32::time::Hertz; 16use embassy_stm32::time::Hertz;
15use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 17use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
16use embassy_time::{Duration, Timer}; 18use embassy_time::Timer;
17use embedded_io_async::Write; 19use embedded_io_async::Write;
18use rand_core::RngCore; 20use rand_core::RngCore;
19use static_cell::make_static; 21use static_cell::make_static;
@@ -42,10 +44,10 @@ async fn main(spawner: Spawner) -> ! {
42 }); 44 });
43 config.rcc.pll1 = Some(Pll { 45 config.rcc.pll1 = Some(Pll {
44 source: PllSource::Hse, 46 source: PllSource::Hse,
45 prediv: 2, 47 prediv: PllPreDiv::DIV2,
46 mul: 125, 48 mul: PllMul::MUL125,
47 divp: Some(2), 49 divp: Some(PllDiv::DIV2),
48 divq: Some(2), 50 divq: Some(PllDiv::DIV2),
49 divr: None, 51 divr: None,
50 }); 52 });
51 config.rcc.ahb_pre = AHBPrescaler::DIV1; 53 config.rcc.ahb_pre = AHBPrescaler::DIV1;
@@ -78,9 +80,8 @@ async fn main(spawner: Spawner) -> ! {
78 p.PG13, 80 p.PG13,
79 p.PB15, 81 p.PB15,
80 p.PG11, 82 p.PG11,
81 GenericSMI::new(), 83 GenericSMI::new(0),
82 mac_addr, 84 mac_addr,
83 0,
84 ); 85 );
85 86
86 let config = embassy_net::Config::dhcpv4(Default::default()); 87 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -120,7 +121,7 @@ async fn main(spawner: Spawner) -> ! {
120 let r = socket.connect(remote_endpoint).await; 121 let r = socket.connect(remote_endpoint).await;
121 if let Err(e) = r { 122 if let Err(e) = r {
122 info!("connect error: {:?}", e); 123 info!("connect error: {:?}", e);
123 Timer::after(Duration::from_secs(3)).await; 124 Timer::after_secs(3).await;
124 continue; 125 continue;
125 } 126 }
126 info!("connected!"); 127 info!("connected!");
@@ -130,7 +131,7 @@ async fn main(spawner: Spawner) -> ! {
130 info!("write error: {:?}", e); 131 info!("write error: {:?}", e);
131 break; 132 break;
132 } 133 }
133 Timer::after(Duration::from_secs(1)).await; 134 Timer::after_secs(1).await;
134 } 135 }
135 } 136 }
136} 137}
diff --git a/examples/stm32h5/src/bin/i2c.rs b/examples/stm32h5/src/bin/i2c.rs
index 8b6fe71ae..8b1662f39 100644
--- a/examples/stm32h5/src/bin/i2c.rs
+++ b/examples/stm32h5/src/bin/i2c.rs
@@ -4,10 +4,9 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::i2c::{Error, I2c, TimeoutI2c}; 7use embassy_stm32::i2c::{Error, I2c};
8use embassy_stm32::time::Hertz; 8use embassy_stm32::time::Hertz;
9use embassy_stm32::{bind_interrupts, i2c, peripherals}; 9use embassy_stm32::{bind_interrupts, i2c, peripherals};
10use embassy_time::Duration;
11use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
12 11
13const ADDRESS: u8 = 0x5F; 12const ADDRESS: u8 = 0x5F;
@@ -33,13 +32,9 @@ async fn main(_spawner: Spawner) {
33 Default::default(), 32 Default::default(),
34 ); 33 );
35 34
36 // I2C bus can freeze if SCL line is shorted or due to a broken device that clock stretches for too long.
37 // TimeoutI2c allows recovering from such errors by throwing `Error::Timeout` after a given delay.
38 let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000));
39
40 let mut data = [0u8; 1]; 35 let mut data = [0u8; 1];
41 36
42 match timeout_i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) { 37 match i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) {
43 Ok(()) => info!("Whoami: {}", data[0]), 38 Ok(()) => info!("Whoami: {}", data[0]),
44 Err(Error::Timeout) => error!("Operation timed out"), 39 Err(Error::Timeout) => error!("Operation timed out"),
45 Err(e) => error!("I2c Error: {:?}", e), 40 Err(e) => error!("I2c Error: {:?}", e),
diff --git a/examples/stm32h5/src/bin/usb_serial.rs b/examples/stm32h5/src/bin/usb_serial.rs
index cbe540a06..3b3c38e17 100644
--- a/examples/stm32h5/src/bin/usb_serial.rs
+++ b/examples/stm32h5/src/bin/usb_serial.rs
@@ -4,7 +4,9 @@
4 4
5use defmt::{panic, *}; 5use defmt::{panic, *};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::rcc::{AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllSource, Sysclk, VoltageScale}; 7use embassy_stm32::rcc::{
8 AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale,
9};
8use embassy_stm32::time::Hertz; 10use embassy_stm32::time::Hertz;
9use embassy_stm32::usb::{Driver, Instance}; 11use embassy_stm32::usb::{Driver, Instance};
10use embassy_stm32::{bind_interrupts, pac, peripherals, usb, Config}; 12use embassy_stm32::{bind_interrupts, pac, peripherals, usb, Config};
@@ -29,9 +31,9 @@ async fn main(_spawner: Spawner) {
29 }); 31 });
30 config.rcc.pll1 = Some(Pll { 32 config.rcc.pll1 = Some(Pll {
31 source: PllSource::Hse, 33 source: PllSource::Hse,
32 prediv: 2, 34 prediv: PllPreDiv::DIV2,
33 mul: 125, 35 mul: PllMul::MUL125,
34 divp: Some(2), // 250mhz 36 divp: Some(PllDiv::DIV2), // 250mhz
35 divq: None, 37 divq: None,
36 divr: None, 38 divr: None,
37 }); 39 });
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index c1d49963c..0855bdfc7 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -6,12 +6,12 @@ license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8# Change stm32h743bi to your chip name, if necessary. 8# Change stm32h743bi to your chip name, if necessary.
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "unstable-traits"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "unstable-traits", "chrono"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
13embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } 13embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] }
14embedded-io-async = { version = "0.5.0" } 14embedded-io-async = { version = "0.6.0" }
15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
16 16
17defmt = "0.3" 17defmt = "0.3"
@@ -22,7 +22,7 @@ cortex-m-rt = "0.7.0"
22embedded-hal = "0.2.6" 22embedded-hal = "0.2.6"
23embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } 23embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" }
24embedded-hal-async = { version = "=1.0.0-rc.1" } 24embedded-hal-async = { version = "=1.0.0-rc.1" }
25embedded-nal-async = { version = "0.5.0" } 25embedded-nal-async = { version = "0.6.0" }
26panic-probe = { version = "0.3", features = ["print-defmt"] } 26panic-probe = { version = "0.3", features = ["print-defmt"] }
27futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 27futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
28heapless = { version = "0.7.5", default-features = false } 28heapless = { version = "0.7.5", default-features = false }
@@ -32,6 +32,7 @@ micromath = "2.0.0"
32stm32-fmc = "0.3.0" 32stm32-fmc = "0.3.0"
33embedded-storage = "0.3.0" 33embedded-storage = "0.3.0"
34static_cell = { version = "1.1", features = ["nightly"]} 34static_cell = { version = "1.1", features = ["nightly"]}
35chrono = { version = "^0.4", default-features = false }
35 36
36# cargo build/run 37# cargo build/run
37[profile.dev] 38[profile.dev]
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs
index 77922d4bc..4a358a35f 100644
--- a/examples/stm32h7/src/bin/adc.rs
+++ b/examples/stm32h7/src/bin/adc.rs
@@ -6,7 +6,7 @@ use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::adc::{Adc, SampleTime}; 7use embassy_stm32::adc::{Adc, SampleTime};
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Delay, Duration, Timer}; 9use embassy_time::{Delay, Timer};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -18,16 +18,16 @@ async fn main(_spawner: Spawner) {
18 config.rcc.csi = true; 18 config.rcc.csi = true;
19 config.rcc.pll_src = PllSource::Hsi; 19 config.rcc.pll_src = PllSource::Hsi;
20 config.rcc.pll1 = Some(Pll { 20 config.rcc.pll1 = Some(Pll {
21 prediv: 4, 21 prediv: PllPreDiv::DIV4,
22 mul: 50, 22 mul: PllMul::MUL50,
23 divp: Some(2), 23 divp: Some(PllDiv::DIV2),
24 divq: Some(8), // SPI1 cksel defaults to pll1_q 24 divq: Some(PllDiv::DIV8), // SPI1 cksel defaults to pll1_q
25 divr: None, 25 divr: None,
26 }); 26 });
27 config.rcc.pll2 = Some(Pll { 27 config.rcc.pll2 = Some(Pll {
28 prediv: 4, 28 prediv: PllPreDiv::DIV4,
29 mul: 50, 29 mul: PllMul::MUL50,
30 divp: Some(8), // 100mhz 30 divp: Some(PllDiv::DIV8), // 100mhz
31 divq: None, 31 divq: None,
32 divr: None, 32 divr: None,
33 }); 33 });
@@ -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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 de8ddc292..8195430b2 100644
--- a/examples/stm32h7/src/bin/camera.rs
+++ b/examples/stm32h7/src/bin/camera.rs
@@ -6,10 +6,10 @@ use embassy_executor::Spawner;
6use embassy_stm32::dcmi::{self, *}; 6use embassy_stm32::dcmi::{self, *};
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::i2c::I2c; 8use embassy_stm32::i2c::I2c;
9use embassy_stm32::rcc::{Mco, Mco1Source}; 9use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler};
10use embassy_stm32::time::khz; 10use embassy_stm32::time::khz;
11use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; 11use embassy_stm32::{bind_interrupts, i2c, peripherals, Config};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use ov7725::*; 13use ov7725::*;
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
@@ -32,10 +32,10 @@ async fn main(_spawner: Spawner) {
32 config.rcc.csi = true; 32 config.rcc.csi = true;
33 config.rcc.pll_src = PllSource::Hsi; 33 config.rcc.pll_src = PllSource::Hsi;
34 config.rcc.pll1 = Some(Pll { 34 config.rcc.pll1 = Some(Pll {
35 prediv: 4, 35 prediv: PllPreDiv::DIV4,
36 mul: 50, 36 mul: PllMul::MUL50,
37 divp: Some(2), 37 divp: Some(PllDiv::DIV2),
38 divq: Some(8), // 100mhz 38 divq: Some(PllDiv::DIV8), // 100mhz
39 divr: None, 39 divr: None,
40 }); 40 });
41 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 41 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
@@ -49,7 +49,7 @@ async fn main(_spawner: Spawner) {
49 let p = embassy_stm32::init(config); 49 let p = embassy_stm32::init(config);
50 50
51 defmt::info!("Hello World!"); 51 defmt::info!("Hello World!");
52 let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, 3); 52 let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV3);
53 53
54 let mut led = Output::new(p.PE3, Level::High, Speed::Low); 54 let mut led = Output::new(p.PE3, Level::High, Speed::Low);
55 let cam_i2c = I2c::new( 55 let cam_i2c = I2c::new(
@@ -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)]
@@ -184,7 +184,7 @@ mod ov7725 {
184 184
185 const CAM_ADDR: u8 = 0x21; 185 const CAM_ADDR: u8 = 0x21;
186 186
187 #[derive(Format)] 187 #[derive(Format, PartialEq, Eq)]
188 pub enum Error<I2cError: Format> { 188 pub enum Error<I2cError: Format> {
189 I2c(I2cError), 189 I2c(I2cError),
190 } 190 }
@@ -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/dac.rs b/examples/stm32h7/src/bin/dac.rs
index 93df7a319..821221897 100644
--- a/examples/stm32h7/src/bin/dac.rs
+++ b/examples/stm32h7/src/bin/dac.rs
@@ -20,16 +20,16 @@ fn main() -> ! {
20 config.rcc.csi = true; 20 config.rcc.csi = true;
21 config.rcc.pll_src = PllSource::Hsi; 21 config.rcc.pll_src = PllSource::Hsi;
22 config.rcc.pll1 = Some(Pll { 22 config.rcc.pll1 = Some(Pll {
23 prediv: 4, 23 prediv: PllPreDiv::DIV4,
24 mul: 50, 24 mul: PllMul::MUL50,
25 divp: Some(2), 25 divp: Some(PllDiv::DIV2),
26 divq: Some(8), // SPI1 cksel defaults to pll1_q 26 divq: Some(PllDiv::DIV8), // 100mhz
27 divr: None, 27 divr: None,
28 }); 28 });
29 config.rcc.pll2 = Some(Pll { 29 config.rcc.pll2 = Some(Pll {
30 prediv: 4, 30 prediv: PllPreDiv::DIV4,
31 mul: 50, 31 mul: PllMul::MUL50,
32 divp: Some(8), // 100mhz 32 divp: Some(PllDiv::DIV8), // 100mhz
33 divq: None, 33 divq: None,
34 divr: None, 34 divr: None,
35 }); 35 });
diff --git a/examples/stm32h7/src/bin/dac_dma.rs b/examples/stm32h7/src/bin/dac_dma.rs
index 8c921abca..334986a05 100644
--- a/examples/stm32h7/src/bin/dac_dma.rs
+++ b/examples/stm32h7/src/bin/dac_dma.rs
@@ -28,16 +28,16 @@ async fn main(spawner: Spawner) {
28 config.rcc.csi = true; 28 config.rcc.csi = true;
29 config.rcc.pll_src = PllSource::Hsi; 29 config.rcc.pll_src = PllSource::Hsi;
30 config.rcc.pll1 = Some(Pll { 30 config.rcc.pll1 = Some(Pll {
31 prediv: 4, 31 prediv: PllPreDiv::DIV4,
32 mul: 50, 32 mul: PllMul::MUL50,
33 divp: Some(2), 33 divp: Some(PllDiv::DIV2),
34 divq: Some(8), // SPI1 cksel defaults to pll1_q 34 divq: Some(PllDiv::DIV8), // 100mhz
35 divr: None, 35 divr: None,
36 }); 36 });
37 config.rcc.pll2 = Some(Pll { 37 config.rcc.pll2 = Some(Pll {
38 prediv: 4, 38 prediv: PllPreDiv::DIV4,
39 mul: 50, 39 mul: PllMul::MUL50,
40 divp: Some(8), // 100mhz 40 divp: Some(PllDiv::DIV8), // 100mhz
41 divq: None, 41 divq: None,
42 divr: None, 42 divr: None,
43 }); 43 });
@@ -79,7 +79,7 @@ async fn dac_task1(mut dac: Dac1Type) {
79 dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap(); 79 dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
80 dac.enable_channel().unwrap(); 80 dac.enable_channel().unwrap();
81 81
82 TIM6::enable(); 82 TIM6::enable_and_reset();
83 TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1)); 83 TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
84 TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE)); 84 TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
85 TIM6::regs().cr1().modify(|w| { 85 TIM6::regs().cr1().modify(|w| {
@@ -118,7 +118,7 @@ async fn dac_task2(mut dac: Dac2Type) {
118 error!("Reload value {} below threshold!", reload); 118 error!("Reload value {} below threshold!", reload);
119 } 119 }
120 120
121 TIM7::enable(); 121 TIM7::enable_and_reset();
122 TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1)); 122 TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
123 TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE)); 123 TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
124 TIM7::regs().cr1().modify(|w| { 124 TIM7::regs().cr1().modify(|w| {
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 1b5d71ed3..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};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 13use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
14use embassy_time::{Duration, Timer}; 14use embassy_time::Timer;
15use embedded_io_async::Write; 15use embedded_io_async::Write;
16use rand_core::RngCore; 16use rand_core::RngCore;
17use static_cell::make_static; 17use static_cell::make_static;
@@ -39,9 +39,9 @@ async fn main(spawner: Spawner) -> ! {
39 config.rcc.hsi48 = true; // needed for RNG 39 config.rcc.hsi48 = true; // needed for RNG
40 config.rcc.pll_src = PllSource::Hsi; 40 config.rcc.pll_src = PllSource::Hsi;
41 config.rcc.pll1 = Some(Pll { 41 config.rcc.pll1 = Some(Pll {
42 prediv: 4, 42 prediv: PllPreDiv::DIV4,
43 mul: 50, 43 mul: PllMul::MUL50,
44 divp: Some(2), 44 divp: Some(PllDiv::DIV2),
45 divq: None, 45 divq: None,
46 divr: None, 46 divr: None,
47 }); 47 });
@@ -77,9 +77,8 @@ async fn main(spawner: Spawner) -> ! {
77 p.PG13, 77 p.PG13,
78 p.PB13, 78 p.PB13,
79 p.PG11, 79 p.PG11,
80 GenericSMI::new(), 80 GenericSMI::new(0),
81 mac_addr, 81 mac_addr,
82 0,
83 ); 82 );
84 83
85 let config = embassy_net::Config::dhcpv4(Default::default()); 84 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -119,7 +118,7 @@ async fn main(spawner: Spawner) -> ! {
119 let r = socket.connect(remote_endpoint).await; 118 let r = socket.connect(remote_endpoint).await;
120 if let Err(e) = r { 119 if let Err(e) = r {
121 info!("connect error: {:?}", e); 120 info!("connect error: {:?}", e);
122 Timer::after(Duration::from_secs(1)).await; 121 Timer::after_secs(1).await;
123 continue; 122 continue;
124 } 123 }
125 info!("connected!"); 124 info!("connected!");
@@ -129,7 +128,7 @@ async fn main(spawner: Spawner) -> ! {
129 info!("write error: {:?}", e); 128 info!("write error: {:?}", e);
130 break; 129 break;
131 } 130 }
132 Timer::after(Duration::from_secs(1)).await; 131 Timer::after_secs(1).await;
133 } 132 }
134 } 133 }
135} 134}
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs
index 3abd31c73..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};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 13use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
14use embassy_time::{Duration, Timer}; 14use embassy_time::Timer;
15use embedded_io_async::Write; 15use embedded_io_async::Write;
16use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; 16use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
17use rand_core::RngCore; 17use rand_core::RngCore;
@@ -40,9 +40,9 @@ async fn main(spawner: Spawner) -> ! {
40 config.rcc.hsi48 = true; // needed for RNG 40 config.rcc.hsi48 = true; // needed for RNG
41 config.rcc.pll_src = PllSource::Hsi; 41 config.rcc.pll_src = PllSource::Hsi;
42 config.rcc.pll1 = Some(Pll { 42 config.rcc.pll1 = Some(Pll {
43 prediv: 4, 43 prediv: PllPreDiv::DIV4,
44 mul: 50, 44 mul: PllMul::MUL50,
45 divp: Some(2), 45 divp: Some(PllDiv::DIV2),
46 divq: None, 46 divq: None,
47 divr: None, 47 divr: None,
48 }); 48 });
@@ -78,9 +78,8 @@ async fn main(spawner: Spawner) -> ! {
78 p.PG13, 78 p.PG13,
79 p.PB13, 79 p.PB13,
80 p.PG11, 80 p.PG11,
81 GenericSMI::new(), 81 GenericSMI::new(0),
82 mac_addr, 82 mac_addr,
83 0,
84 ); 83 );
85 84
86 let config = embassy_net::Config::dhcpv4(Default::default()); 85 let config = embassy_net::Config::dhcpv4(Default::default());
@@ -106,8 +105,8 @@ async fn main(spawner: Spawner) -> ! {
106 105
107 info!("Network task initialized"); 106 info!("Network task initialized");
108 107
109 static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); 108 let state: TcpClientState<1, 1024, 1024> = TcpClientState::new();
110 let client = TcpClient::new(&stack, &STATE); 109 let client = TcpClient::new(&stack, &state);
111 110
112 loop { 111 loop {
113 let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(10, 42, 0, 1), 8000)); 112 let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(10, 42, 0, 1), 8000));
@@ -116,7 +115,7 @@ async fn main(spawner: Spawner) -> ! {
116 let r = client.connect(addr).await; 115 let r = client.connect(addr).await;
117 if let Err(e) = r { 116 if let Err(e) = r {
118 info!("connect error: {:?}", e); 117 info!("connect error: {:?}", e);
119 Timer::after(Duration::from_secs(1)).await; 118 Timer::after_secs(1).await;
120 continue; 119 continue;
121 } 120 }
122 let mut connection = r.unwrap(); 121 let mut connection = r.unwrap();
@@ -127,7 +126,7 @@ async fn main(spawner: Spawner) -> ! {
127 info!("write error: {:?}", e); 126 info!("write error: {:?}", e);
128 break; 127 break;
129 } 128 }
130 Timer::after(Duration::from_secs(1)).await; 129 Timer::after_secs(1).await;
131 } 130 }
132 } 131 }
133} 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 @@
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::flash::Flash; 7use embassy_stm32::flash::Flash;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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 de0b351df..cffd47093 100644
--- a/examples/stm32h7/src/bin/fmc.rs
+++ b/examples/stm32h7/src/bin/fmc.rs
@@ -6,7 +6,7 @@ use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::fmc::Fmc; 7use embassy_stm32::fmc::Fmc;
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Delay, Duration, Timer}; 9use embassy_time::{Delay, Timer};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) {
18 config.rcc.csi = true; 18 config.rcc.csi = true;
19 config.rcc.pll_src = PllSource::Hsi; 19 config.rcc.pll_src = PllSource::Hsi;
20 config.rcc.pll1 = Some(Pll { 20 config.rcc.pll1 = Some(Pll {
21 prediv: 4, 21 prediv: PllPreDiv::DIV4,
22 mul: 50, 22 mul: PllMul::MUL50,
23 divp: Some(2), 23 divp: Some(PllDiv::DIV2),
24 divq: Some(8), // 100mhz 24 divq: Some(PllDiv::DIV8), // 100mhz
25 divr: None, 25 divr: None,
26 }); 26 });
27 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 27 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
@@ -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/i2c.rs b/examples/stm32h7/src/bin/i2c.rs
index c2979c59b..9aa0ca08b 100644
--- a/examples/stm32h7/src/bin/i2c.rs
+++ b/examples/stm32h7/src/bin/i2c.rs
@@ -4,10 +4,9 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::i2c::{Error, I2c, TimeoutI2c}; 7use embassy_stm32::i2c::{Error, I2c};
8use embassy_stm32::time::Hertz; 8use embassy_stm32::time::Hertz;
9use embassy_stm32::{bind_interrupts, i2c, peripherals}; 9use embassy_stm32::{bind_interrupts, i2c, peripherals};
10use embassy_time::Duration;
11use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
12 11
13const ADDRESS: u8 = 0x5F; 12const ADDRESS: u8 = 0x5F;
@@ -33,13 +32,9 @@ async fn main(_spawner: Spawner) {
33 Default::default(), 32 Default::default(),
34 ); 33 );
35 34
36 // I2C bus can freeze if SCL line is shorted or due to a broken device that clock stretches for too long.
37 // TimeoutI2c allows recovering from such errors by throwing `Error::Timeout` after a given delay.
38 let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000));
39
40 let mut data = [0u8; 1]; 35 let mut data = [0u8; 1];
41 36
42 match timeout_i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) { 37 match i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) {
43 Ok(()) => info!("Whoami: {}", data[0]), 38 Ok(()) => info!("Whoami: {}", data[0]),
44 Err(Error::Timeout) => error!("Operation timed out"), 39 Err(Error::Timeout) => error!("Operation timed out"),
45 Err(e) => error!("I2c Error: {:?}", e), 40 Err(e) => error!("I2c Error: {:?}", e),
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs
index a1e955c39..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;
9use embassy_stm32::time::{khz, Hertz}; 9use embassy_stm32::time::{khz, Hertz};
10use embassy_stm32::timer::*; 10use embassy_stm32::timer::*;
11use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; 11use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15#[embassy_executor::main] 15#[embassy_executor::main]
@@ -22,10 +22,10 @@ async fn main(_spawner: Spawner) {
22 config.rcc.hsi48 = true; // needed for RNG 22 config.rcc.hsi48 = true; // needed for RNG
23 config.rcc.pll_src = PllSource::Hsi; 23 config.rcc.pll_src = PllSource::Hsi;
24 config.rcc.pll1 = Some(Pll { 24 config.rcc.pll1 = Some(Pll {
25 prediv: 4, 25 prediv: PllPreDiv::DIV4,
26 mul: 50, 26 mul: PllMul::MUL50,
27 divp: Some(2), 27 divp: Some(PllDiv::DIV2),
28 divq: Some(8), // 100 Mhz 28 divq: Some(PllDiv::DIV8), // 100mhz
29 divr: None, 29 divr: None,
30 }); 30 });
31 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 31 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
@@ -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}
61pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> { 61pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> {
@@ -73,8 +73,7 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
73 ) -> Self { 73 ) -> Self {
74 into_ref!(tim, ch1, ch2, ch3, ch4); 74 into_ref!(tim, ch1, ch2, ch3, ch4);
75 75
76 T::enable(); 76 T::enable_and_reset();
77 <T as embassy_stm32::rcc::low_level::RccPeripheral>::reset();
78 77
79 ch1.set_speed(Speed::VeryHigh); 78 ch1.set_speed(Speed::VeryHigh);
80 ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull); 79 ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull);
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs
index 9d6d805ae..c023f4584 100644
--- a/examples/stm32h7/src/bin/mco.rs
+++ b/examples/stm32h7/src/bin/mco.rs
@@ -5,8 +5,8 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::rcc::{Mco, Mco1Source}; 8use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -16,15 +16,15 @@ async fn main(_spawner: Spawner) {
16 16
17 let mut led = Output::new(p.PB14, Level::High, Speed::Low); 17 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
18 18
19 let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, 8); 19 let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV8);
20 20
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 84e7df267..973a10cdd 100644
--- a/examples/stm32h7/src/bin/pwm.rs
+++ b/examples/stm32h7/src/bin/pwm.rs
@@ -9,7 +9,7 @@ use embassy_stm32::time::khz;
9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; 9use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
10use embassy_stm32::timer::Channel; 10use embassy_stm32::timer::Channel;
11use embassy_stm32::Config; 11use embassy_stm32::Config;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15#[embassy_executor::main] 15#[embassy_executor::main]
@@ -21,9 +21,9 @@ async fn main(_spawner: Spawner) {
21 config.rcc.csi = true; 21 config.rcc.csi = true;
22 config.rcc.pll_src = PllSource::Hsi; 22 config.rcc.pll_src = PllSource::Hsi;
23 config.rcc.pll1 = Some(Pll { 23 config.rcc.pll1 = Some(Pll {
24 prediv: 4, 24 prediv: PllPreDiv::DIV4,
25 mul: 50, 25 mul: PllMul::MUL50,
26 divp: Some(2), 26 divp: Some(PllDiv::DIV2),
27 divq: None, 27 divq: None,
28 divr: None, 28 divr: None,
29 }); 29 });
@@ -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
new file mode 100644
index 000000000..78cea9c89
--- /dev/null
+++ b/examples/stm32h7/src/bin/rtc.rs
@@ -0,0 +1,37 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use chrono::{NaiveDate, NaiveDateTime};
6use defmt::*;
7use embassy_executor::Spawner;
8use embassy_stm32::rcc::LsConfig;
9use embassy_stm32::rtc::{Rtc, RtcConfig};
10use embassy_stm32::Config;
11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _};
13
14#[embassy_executor::main]
15async fn main(_spawner: Spawner) {
16 let mut config = Config::default();
17 config.rcc.ls = LsConfig::default_lse();
18
19 let p = embassy_stm32::init(config);
20 info!("Hello World!");
21
22 let now = NaiveDate::from_ymd_opt(2020, 5, 15)
23 .unwrap()
24 .and_hms_opt(10, 30, 15)
25 .unwrap();
26
27 let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
28 info!("Got RTC! {:?}", now.timestamp());
29
30 rtc.set_datetime(now.into()).expect("datetime not set");
31
32 // In reality the delay would be much longer
33 Timer::after_millis(20000).await;
34
35 let then: NaiveDateTime = rtc.now().unwrap().into();
36 info!("Got RTC! {:?}", then.timestamp());
37}
diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs
index 752aefdf7..ecb8d6542 100644
--- a/examples/stm32h7/src/bin/sdmmc.rs
+++ b/examples/stm32h7/src/bin/sdmmc.rs
@@ -22,10 +22,10 @@ async fn main(_spawner: Spawner) -> ! {
22 config.rcc.csi = true; 22 config.rcc.csi = true;
23 config.rcc.pll_src = PllSource::Hsi; 23 config.rcc.pll_src = PllSource::Hsi;
24 config.rcc.pll1 = Some(Pll { 24 config.rcc.pll1 = Some(Pll {
25 prediv: 4, 25 prediv: PllPreDiv::DIV4,
26 mul: 50, 26 mul: PllMul::MUL50,
27 divp: Some(2), 27 divp: Some(PllDiv::DIV2),
28 divq: Some(4), // default clock chosen by SDMMCSEL. 200 Mhz 28 divq: Some(PllDiv::DIV4), // default clock chosen by SDMMCSEL. 200 Mhz
29 divr: None, 29 divr: None,
30 }); 30 });
31 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 31 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
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};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 7use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
8use embassy_sync::signal::Signal; 8use embassy_sync::signal::Signal;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12static SIGNAL: Signal<CriticalSectionRawMutex, u32> = Signal::new(); 12static 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/spi.rs b/examples/stm32h7/src/bin/spi.rs
index 9fe46f031..f128d4a56 100644
--- a/examples/stm32h7/src/bin/spi.rs
+++ b/examples/stm32h7/src/bin/spi.rs
@@ -44,10 +44,10 @@ fn main() -> ! {
44 config.rcc.csi = true; 44 config.rcc.csi = true;
45 config.rcc.pll_src = PllSource::Hsi; 45 config.rcc.pll_src = PllSource::Hsi;
46 config.rcc.pll1 = Some(Pll { 46 config.rcc.pll1 = Some(Pll {
47 prediv: 4, 47 prediv: PllPreDiv::DIV4,
48 mul: 50, 48 mul: PllMul::MUL50,
49 divp: Some(2), 49 divp: Some(PllDiv::DIV2),
50 divq: Some(4), // used by SPI3. 100Mhz. 50 divq: Some(PllDiv::DIV8), // used by SPI3. 100Mhz.
51 divr: None, 51 divr: None,
52 }); 52 });
53 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 53 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs
index 88d65d5be..d4c0bcdbd 100644
--- a/examples/stm32h7/src/bin/spi_dma.rs
+++ b/examples/stm32h7/src/bin/spi_dma.rs
@@ -40,10 +40,10 @@ fn main() -> ! {
40 config.rcc.csi = true; 40 config.rcc.csi = true;
41 config.rcc.pll_src = PllSource::Hsi; 41 config.rcc.pll_src = PllSource::Hsi;
42 config.rcc.pll1 = Some(Pll { 42 config.rcc.pll1 = Some(Pll {
43 prediv: 4, 43 prediv: PllPreDiv::DIV4,
44 mul: 50, 44 mul: PllMul::MUL50,
45 divp: Some(2), 45 divp: Some(PllDiv::DIV2),
46 divq: Some(4), // used by SPI3. 100Mhz. 46 divq: Some(PllDiv::DIV8), // used by SPI3. 100Mhz.
47 divr: None, 47 divr: None,
48 }); 48 });
49 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz 49 config.rcc.sys = Sysclk::Pll1P; // 400 Mhz
diff --git a/examples/stm32h7/src/bin/usb_serial.rs b/examples/stm32h7/src/bin/usb_serial.rs
index 14de43568..c1e5144be 100644
--- a/examples/stm32h7/src/bin/usb_serial.rs
+++ b/examples/stm32h7/src/bin/usb_serial.rs
@@ -28,9 +28,9 @@ async fn main(_spawner: Spawner) {
28 config.rcc.hsi48 = true; // needed for USB 28 config.rcc.hsi48 = true; // needed for USB
29 config.rcc.pll_src = PllSource::Hsi; 29 config.rcc.pll_src = PllSource::Hsi;
30 config.rcc.pll1 = Some(Pll { 30 config.rcc.pll1 = Some(Pll {
31 prediv: 4, 31 prediv: PllPreDiv::DIV4,
32 mul: 50, 32 mul: PllMul::MUL50,
33 divp: Some(2), 33 divp: Some(PllDiv::DIV2),
34 divq: None, 34 divq: None,
35 divr: None, 35 divr: None,
36 }); 36 });
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::wdg::IndependentWatchdog; 7use embassy_stm32::wdg::IndependentWatchdog;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/Cargo.toml b/examples/stm32l0/Cargo.toml
index 502ebfc8d..03b6d600b 100644
--- a/examples/stm32l0/Cargo.toml
+++ b/examples/stm32l0/Cargo.toml
@@ -14,7 +14,7 @@ nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstab
14embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } 14embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
15embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 15embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
16embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 16embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
17embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 17embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
18embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } 18embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true }
19lora-phy = { version = "2", optional = true } 19lora-phy = { version = "2", optional = true }
20lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } 20lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true }
@@ -24,8 +24,8 @@ defmt = "0.3"
24defmt-rtt = "0.4" 24defmt-rtt = "0.4"
25 25
26embedded-storage = "0.3.0" 26embedded-storage = "0.3.0"
27embedded-io = { version = "0.5.0" } 27embedded-io = { version = "0.6.0" }
28embedded-io-async = { version = "0.5.0", optional = true } 28embedded-io-async = { version = "0.6.0", optional = true }
29 29
30cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 30cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
31cortex-m-rt = "0.7.0" 31cortex-m-rt = "0.7.0"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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};
12use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
13use embassy_stm32::spi; 13use embassy_stm32::spi;
14use embassy_stm32::time::khz; 14use embassy_stm32::time::khz;
15use embassy_time::{Delay, Duration, Timer}; 15use embassy_time::{Delay, Timer};
16use lora_phy::mod_params::*; 16use lora_phy::mod_params::*;
17use lora_phy::sx1276_7_8_9::SX1276_7_8_9; 17use lora_phy::sx1276_7_8_9::SX1276_7_8_9;
18use lora_phy::LoRa; 18use 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};
12use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
13use embassy_stm32::spi; 13use embassy_stm32::spi;
14use embassy_stm32::time::khz; 14use embassy_stm32::time::khz;
15use embassy_time::{Delay, Duration, Timer}; 15use embassy_time::{Delay, Timer};
16use lora_phy::mod_params::*; 16use lora_phy::mod_params::*;
17use lora_phy::sx1276_7_8_9::SX1276_7_8_9; 17use lora_phy::sx1276_7_8_9::SX1276_7_8_9;
18use lora_phy::LoRa; 18use 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;
7use defmt::*; 7use defmt::*;
8use embassy_executor::raw::TaskStorage; 8use embassy_executor::raw::TaskStorage;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use static_cell::StaticCell; 11use static_cell::StaticCell;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14async fn run1() { 14async 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
21async fn run2() { 21async 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/Cargo.toml b/examples/stm32l1/Cargo.toml
index a75275a0b..70058d49b 100644
--- a/examples/stm32l1/Cargo.toml
+++ b/examples/stm32l1/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
9embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 9embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
10embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/Cargo.toml b/examples/stm32l4/Cargo.toml
index 59e89c537..b420ad563 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -9,14 +9,14 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "unstable-traits", "chrono"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "unstable-traits", "chrono"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", "unstable-traits", "nightly"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", "unstable-traits", "nightly"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" } 15embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" }
16embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "udp", "tcp", "dhcpv4", "medium-ethernet"] } 16embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "udp", "tcp", "dhcpv4", "medium-ethernet"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
18embedded-io-async = { version = "0.5.0", features = ["defmt-03"] } 18embedded-io-async = { version = "0.6.0", features = ["defmt-03"] }
19embedded-io = { version = "0.5.0", features = ["defmt-03"] } 19embedded-io = { version = "0.6.0", features = ["defmt-03"] }
20 20
21defmt = "0.3" 21defmt = "0.3"
22defmt-rtt = "0.4" 22defmt-rtt = "0.4"
diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs
index 1771e5202..a0ec5c33e 100644
--- a/examples/stm32l4/src/bin/adc.rs
+++ b/examples/stm32l4/src/bin/adc.rs
@@ -13,7 +13,7 @@ fn main() -> ! {
13 info!("Hello World!"); 13 info!("Hello World!");
14 14
15 pac::RCC.ccipr().modify(|w| { 15 pac::RCC.ccipr().modify(|w| {
16 w.set_adcsel(0b11); 16 w.set_adcsel(pac::rcc::vals::Adcsel::SYS);
17 }); 17 });
18 pac::RCC.ahb2enr().modify(|w| w.set_adcen(true)); 18 pac::RCC.ahb2enr().modify(|w| w.set_adcen(true));
19 19
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/dac_dma.rs b/examples/stm32l4/src/bin/dac_dma.rs
index c27cc03e1..98f37f906 100644
--- a/examples/stm32l4/src/bin/dac_dma.rs
+++ b/examples/stm32l4/src/bin/dac_dma.rs
@@ -51,7 +51,7 @@ async fn dac_task1(mut dac: Dac1Type) {
51 dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap(); 51 dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
52 dac.enable_channel().unwrap(); 52 dac.enable_channel().unwrap();
53 53
54 TIM6::enable(); 54 TIM6::enable_and_reset();
55 TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1)); 55 TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
56 TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE)); 56 TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
57 TIM6::regs().cr1().modify(|w| { 57 TIM6::regs().cr1().modify(|w| {
@@ -90,7 +90,7 @@ async fn dac_task2(mut dac: Dac2Type) {
90 error!("Reload value {} below threshold!", reload); 90 error!("Reload value {} below threshold!", reload);
91 } 91 }
92 92
93 TIM7::enable(); 93 TIM7::enable_and_reset();
94 TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1)); 94 TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
95 TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE)); 95 TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
96 TIM7::regs().cr1().modify(|w| { 96 TIM7::regs().cr1().modify(|w| {
diff --git a/examples/stm32l4/src/bin/mco.rs b/examples/stm32l4/src/bin/mco.rs
index dea0c66e0..504879887 100644
--- a/examples/stm32l4/src/bin/mco.rs
+++ b/examples/stm32l4/src/bin/mco.rs
@@ -5,8 +5,8 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; 8use embassy_stm32::rcc::{Mco, McoPrescaler, McoSource};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -14,14 +14,14 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello World!"); 15 info!("Hello World!");
16 16
17 let _mco = Mco::new(p.MCO, p.PA8, Mco1Source::Hsi16, McoClock::DIV1); 17 let _mco = Mco::new(p.MCO, p.PA8, McoSource::HSI, McoPrescaler::DIV1);
18 18
19 let mut led = Output::new(p.PB14, Level::High, Speed::Low); 19 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
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/rng.rs b/examples/stm32l4/src/bin/rng.rs
index 806e49f59..d8a4e825f 100644
--- a/examples/stm32l4/src/bin/rng.rs
+++ b/examples/stm32l4/src/bin/rng.rs
@@ -4,7 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; 7use embassy_stm32::rcc::{ClockSrc, PLLSource, Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv};
8use embassy_stm32::rng::Rng; 8use embassy_stm32::rng::Rng;
9use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, rng, Config};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
@@ -16,14 +16,16 @@ bind_interrupts!(struct Irqs {
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let mut config = Config::default(); 18 let mut config = Config::default();
19 // 72Mhz clock (16 / 1 * 18 / 4) 19 config.rcc.mux = ClockSrc::PLL1_R;
20 config.rcc.mux = ClockSrc::PLL( 20 config.rcc.hsi16 = true;
21 PLLSource::HSI16, 21 config.rcc.pll = Some(Pll {
22 PLLClkDiv::Div4, 22 source: PLLSource::HSI,
23 PLLSrcDiv::Div1, 23 prediv: PllPreDiv::DIV1,
24 PLLMul::Mul18, 24 mul: PllMul::MUL18,
25 Some(PLLClkDiv::Div6), // 48Mhz (16 / 1 * 18 / 6) 25 divp: None,
26 ); 26 divq: Some(PllQDiv::DIV6), // 48Mhz (16 / 1 * 18 / 6)
27 divr: Some(PllRDiv::DIV4), // sysclk 72Mhz clock (16 / 1 * 18 / 4)
28 });
27 let p = embassy_stm32::init(config); 29 let p = embassy_stm32::init(config);
28 30
29 info!("Hello World!"); 31 info!("Hello World!");
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs
index eb1eed012..fec0a349d 100644
--- a/examples/stm32l4/src/bin/rtc.rs
+++ b/examples/stm32l4/src/bin/rtc.rs
@@ -5,28 +5,29 @@
5use chrono::{NaiveDate, NaiveDateTime}; 5use chrono::{NaiveDate, NaiveDateTime};
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::rcc::{self, ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; 8use embassy_stm32::rcc::{ClockSrc, LsConfig, PLLSource, Pll, PllMul, PllPreDiv, PllRDiv};
9use embassy_stm32::rtc::{Rtc, RtcConfig}; 9use embassy_stm32::rtc::{Rtc, RtcConfig};
10use embassy_stm32::time::Hertz; 10use embassy_stm32::time::Hertz;
11use embassy_stm32::Config; 11use embassy_stm32::Config;
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15#[embassy_executor::main] 15#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 16async fn main(_spawner: Spawner) {
17 let p = { 17 let mut config = Config::default();
18 let mut config = Config::default(); 18 config.rcc.mux = ClockSrc::PLL1_R;
19 config.rcc.mux = ClockSrc::PLL( 19 config.rcc.hse = Some(Hertz::mhz(8));
20 PLLSource::HSE(Hertz::mhz(8)), 20 config.rcc.pll = Some(Pll {
21 PLLClkDiv::Div2, 21 source: PLLSource::HSE,
22 PLLSrcDiv::Div1, 22 prediv: PllPreDiv::DIV1,
23 PLLMul::Mul20, 23 mul: PllMul::MUL20,
24 None, 24 divp: None,
25 ); 25 divq: None,
26 config.rcc.lse = Some(Hertz(32_768)); 26 divr: Some(PllRDiv::DIV2), // sysclk 80Mhz clock (8 / 1 * 20 / 2)
27 config.rcc.rtc_mux = rcc::RtcClockSource::LSE; 27 });
28 embassy_stm32::init(config) 28 config.rcc.ls = LsConfig::default_lse();
29 }; 29 let p = embassy_stm32::init(config);
30
30 info!("Hello World!"); 31 info!("Hello World!");
31 32
32 let now = NaiveDate::from_ymd_opt(2020, 5, 15) 33 let now = NaiveDate::from_ymd_opt(2020, 5, 15)
@@ -40,7 +41,7 @@ async fn main(_spawner: Spawner) {
40 rtc.set_datetime(now.into()).expect("datetime not set"); 41 rtc.set_datetime(now.into()).expect("datetime not set");
41 42
42 // In reality the delay would be much longer 43 // In reality the delay would be much longer
43 Timer::after(Duration::from_millis(20000)).await; 44 Timer::after_millis(20000).await;
44 45
45 let then: NaiveDateTime = rtc.now().unwrap().into(); 46 let then: NaiveDateTime = rtc.now().unwrap().into();
46 info!("Got RTC! {:?}", then.timestamp()); 47 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 287521582..3c9d2cfc0 100644
--- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
+++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
@@ -32,7 +32,6 @@ use embedded_io::Write as bWrite;
32use embedded_io_async::Write; 32use embedded_io_async::Write;
33use hal::gpio::{Input, Level, Output, Speed}; 33use hal::gpio::{Input, Level, Output, Speed};
34use hal::i2c::{self, I2c}; 34use hal::i2c::{self, I2c};
35use hal::rcc::{self};
36use hal::rng::{self, Rng}; 35use hal::rng::{self, Rng};
37use hal::{bind_interrupts, exti, pac, peripherals}; 36use hal::{bind_interrupts, exti, pac, peripherals};
38use heapless::Vec; 37use heapless::Vec;
@@ -49,7 +48,7 @@ use embassy_net_adin1110::{self, Device, Runner, ADIN1110};
49use embedded_hal_bus::spi::ExclusiveDevice; 48use embedded_hal_bus::spi::ExclusiveDevice;
50use hal::gpio::Pull; 49use hal::gpio::Pull;
51use hal::i2c::Config as I2C_Config; 50use hal::i2c::Config as I2C_Config;
52use hal::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; 51use hal::rcc::{ClockSrc, PLLSource, Pll, PllMul, PllPreDiv, PllRDiv};
53use hal::spi::{Config as SPI_Config, Spi}; 52use hal::spi::{Config as SPI_Config, Spi};
54use hal::time::Hertz; 53use hal::time::Hertz;
55 54
@@ -78,15 +77,17 @@ async fn main(spawner: Spawner) {
78 77
79 // 80Mhz clock (Source: 8 / SrcDiv: 1 * PLLMul 20 / ClkDiv 2) 78 // 80Mhz clock (Source: 8 / SrcDiv: 1 * PLLMul 20 / ClkDiv 2)
80 // 80MHz highest frequency for flash 0 wait. 79 // 80MHz highest frequency for flash 0 wait.
81 config.rcc.mux = ClockSrc::PLL( 80 config.rcc.mux = ClockSrc::PLL1_R;
82 PLLSource::HSE(Hertz(8_000_000)), 81 config.rcc.hse = Some(Hertz::mhz(8));
83 PLLClkDiv::Div2, 82 config.rcc.pll = Some(Pll {
84 PLLSrcDiv::Div1, 83 source: PLLSource::HSE,
85 PLLMul::Mul20, 84 prediv: PllPreDiv::DIV1,
86 None, 85 mul: PllMul::MUL20,
87 ); 86 divp: None,
87 divq: None,
88 divr: Some(PllRDiv::DIV2), // sysclk 80Mhz clock (8 / 1 * 20 / 2)
89 });
88 config.rcc.hsi48 = true; // needed for rng 90 config.rcc.hsi48 = true; // needed for rng
89 config.rcc.rtc_mux = rcc::RtcClockSource::LSI;
90 91
91 let dp = embassy_stm32::init(config); 92 let dp = embassy_stm32::init(config);
92 93
@@ -308,7 +309,7 @@ async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, periphera
308 309
309 loop { 310 loop {
310 led.set_low(); 311 led.set_low();
311 match select(temp_sens.read_temp(), Timer::after(Duration::from_millis(500))).await { 312 match select(temp_sens.read_temp(), Timer::after_millis(500)).await {
312 Either::First(i2c_ret) => match i2c_ret { 313 Either::First(i2c_ret) => match i2c_ret {
313 Ok(value) => { 314 Ok(value) => {
314 led.set_high(); 315 led.set_high();
@@ -366,7 +367,7 @@ pub struct ADT7422<'d, BUS: I2cBus> {
366 bus: BUS, 367 bus: BUS,
367} 368}
368 369
369#[derive(Debug, Format)] 370#[derive(Debug, Format, PartialEq, Eq)]
370pub enum Error<I2cError: Format> { 371pub enum Error<I2cError: Format> {
371 I2c(I2cError), 372 I2c(I2cError),
372 Address, 373 Address,
@@ -426,7 +427,7 @@ where
426 // Start: One shot 427 // Start: One shot
427 let cfg = 0b01 << 5; 428 let cfg = 0b01 << 5;
428 self.write_cfg(cfg).await?; 429 self.write_cfg(cfg).await?;
429 Timer::after(Duration::from_millis(250)).await; 430 Timer::after_millis(250).await;
430 self.bus 431 self.bus
431 .write_read(self.addr, &[Registers::Temp_MSB as u8], &mut buffer) 432 .write_read(self.addr, &[Registers::Temp_MSB as u8], &mut buffer)
432 .await 433 .await
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs
index 410d6891b..282476547 100644
--- a/examples/stm32l4/src/bin/usb_serial.rs
+++ b/examples/stm32l4/src/bin/usb_serial.rs
@@ -23,8 +23,17 @@ async fn main(_spawner: Spawner) {
23 info!("Hello World!"); 23 info!("Hello World!");
24 24
25 let mut config = Config::default(); 25 let mut config = Config::default();
26 config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None);
27 config.rcc.hsi48 = true; 26 config.rcc.hsi48 = true;
27 config.rcc.mux = ClockSrc::PLL1_R;
28 config.rcc.hsi16 = true;
29 config.rcc.pll = Some(Pll {
30 source: PLLSource::HSI,
31 prediv: PllPreDiv::DIV1,
32 mul: PllMul::MUL10,
33 divp: None,
34 divq: None,
35 divr: Some(PllRDiv::DIV2), // sysclk 80Mhz (16 / 1 * 10 / 2)
36 });
28 37
29 let p = embassy_stm32::init(config); 38 let p = embassy_stm32::init(config);
30 39
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml
index 583e1a776..ecf88d7e6 100644
--- a/examples/stm32l5/Cargo.toml
+++ b/examples/stm32l5/Cargo.toml
@@ -9,9 +9,9 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } 14embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16usbd-hid = "0.6.0" 16usbd-hid = "0.6.0"
17 17
@@ -25,7 +25,7 @@ embedded-hal = "0.2.6"
25futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 25futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
26heapless = { version = "0.7.5", default-features = false } 26heapless = { version = "0.7.5", default-features = false }
27rand_core = { version = "0.6.3", default-features = false } 27rand_core = { version = "0.6.3", default-features = false }
28embedded-io-async = { version = "0.5.0" } 28embedded-io-async = { version = "0.6.0" }
29static_cell = { version = "1.1", features = ["nightly"]} 29static_cell = { version = "1.1", features = ["nightly"]}
30 30
31[profile.release] 31[profile.release]
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs
index 9549d64d8..b57f438ff 100644
--- a/examples/stm32l5/src/bin/rng.rs
+++ b/examples/stm32l5/src/bin/rng.rs
@@ -4,7 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; 7use embassy_stm32::rcc::{ClockSrc, PLLSource, Pll, PllMul, PllPreDiv, PllRDiv};
8use embassy_stm32::rng::Rng; 8use embassy_stm32::rng::Rng;
9use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; 9use embassy_stm32::{bind_interrupts, peripherals, rng, Config};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
@@ -16,13 +16,17 @@ bind_interrupts!(struct Irqs {
16#[embassy_executor::main] 16#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
18 let mut config = Config::default(); 18 let mut config = Config::default();
19 config.rcc.mux = ClockSrc::PLL( 19 config.rcc.hsi16 = true;
20 PLLSource::HSI16, 20 config.rcc.mux = ClockSrc::PLL1_R;
21 PLLClkDiv::Div2, 21 config.rcc.pll = Some(Pll {
22 PLLSrcDiv::Div1, 22 // 64Mhz clock (16 / 1 * 8 / 2)
23 PLLMul::Mul8, 23 source: PLLSource::HSI,
24 Some(PLLClkDiv::Div2), 24 prediv: PllPreDiv::DIV1,
25 ); 25 mul: PllMul::MUL8,
26 divp: None,
27 divq: None,
28 divr: Some(PllRDiv::DIV2),
29 });
26 let p = embassy_stm32::init(config); 30 let p = embassy_stm32::init(config);
27 31
28 info!("Hello World!"); 32 info!("Hello World!");
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs
index 15b84761b..bbe44642b 100644
--- a/examples/stm32l5/src/bin/usb_ethernet.rs
+++ b/examples/stm32l5/src/bin/usb_ethernet.rs
@@ -45,8 +45,17 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
45#[embassy_executor::main] 45#[embassy_executor::main]
46async fn main(spawner: Spawner) { 46async fn main(spawner: Spawner) {
47 let mut config = Config::default(); 47 let mut config = Config::default();
48 config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); 48 config.rcc.hsi16 = true;
49 config.rcc.hsi48 = true; 49 config.rcc.mux = ClockSrc::PLL1_R;
50 config.rcc.pll = Some(Pll {
51 // 80Mhz clock (16 / 1 * 10 / 2)
52 source: PLLSource::HSI,
53 prediv: PllPreDiv::DIV1,
54 mul: PllMul::MUL10,
55 divp: None,
56 divq: None,
57 divr: Some(PllRDiv::DIV2),
58 });
50 let p = embassy_stm32::init(config); 59 let p = embassy_stm32::init(config);
51 60
52 // Create the driver, from the HAL. 61 // Create the driver, from the HAL.
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs
index 7e894e407..44e29ee9c 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;
8use embassy_stm32::rcc::*; 8use embassy_stm32::rcc::*;
9use embassy_stm32::usb::Driver; 9use embassy_stm32::usb::Driver;
10use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; 10use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; 12use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State};
13use embassy_usb::control::OutResponse; 13use embassy_usb::control::OutResponse;
14use embassy_usb::Builder; 14use embassy_usb::Builder;
@@ -22,8 +22,17 @@ bind_interrupts!(struct Irqs {
22#[embassy_executor::main] 22#[embassy_executor::main]
23async fn main(_spawner: Spawner) { 23async fn main(_spawner: Spawner) {
24 let mut config = Config::default(); 24 let mut config = Config::default();
25 config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); 25 config.rcc.hsi16 = true;
26 config.rcc.hsi48 = true; 26 config.rcc.mux = ClockSrc::PLL1_R;
27 config.rcc.pll = Some(Pll {
28 // 80Mhz clock (16 / 1 * 10 / 2)
29 source: PLLSource::HSI,
30 prediv: PllPreDiv::DIV1,
31 mul: PllMul::MUL10,
32 divp: None,
33 divq: None,
34 divr: Some(PllRDiv::DIV2),
35 });
27 let p = embassy_stm32::init(config); 36 let p = embassy_stm32::init(config);
28 37
29 // Create the driver, from the HAL. 38 // Create the driver, from the HAL.
@@ -76,7 +85,7 @@ async fn main(_spawner: Spawner) {
76 let hid_fut = async { 85 let hid_fut = async {
77 let mut y: i8 = 5; 86 let mut y: i8 = 5;
78 loop { 87 loop {
79 Timer::after(Duration::from_millis(500)).await; 88 Timer::after_millis(500).await;
80 89
81 y = -y; 90 y = -y;
82 let report = MouseReport { 91 let report = MouseReport {
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs
index 0c719560f..612b891ac 100644
--- a/examples/stm32l5/src/bin/usb_serial.rs
+++ b/examples/stm32l5/src/bin/usb_serial.rs
@@ -20,8 +20,17 @@ bind_interrupts!(struct Irqs {
20#[embassy_executor::main] 20#[embassy_executor::main]
21async fn main(_spawner: Spawner) { 21async fn main(_spawner: Spawner) {
22 let mut config = Config::default(); 22 let mut config = Config::default();
23 config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); 23 config.rcc.hsi16 = true;
24 config.rcc.hsi48 = true; 24 config.rcc.mux = ClockSrc::PLL1_R;
25 config.rcc.pll = Some(Pll {
26 // 80Mhz clock (16 / 1 * 10 / 2)
27 source: PLLSource::HSI,
28 prediv: PllPreDiv::DIV1,
29 mul: PllMul::MUL10,
30 divp: None,
31 divq: None,
32 divr: Some(PllRDiv::DIV2),
33 });
25 let p = embassy_stm32::init(config); 34 let p = embassy_stm32::init(config);
26 35
27 info!("Hello World!"); 36 info!("Hello World!");
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml
index e361856c5..de60b3b19 100644
--- a/examples/stm32u5/Cargo.toml
+++ b/examples/stm32u5/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
14 14
15defmt = "0.3" 15defmt = "0.3"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs
index 9e47fb18a..9b2adb0ac 100644
--- a/examples/stm32u5/src/bin/usb_serial.rs
+++ b/examples/stm32u5/src/bin/usb_serial.rs
@@ -23,7 +23,12 @@ async fn main(_spawner: Spawner) {
23 info!("Hello World!"); 23 info!("Hello World!");
24 24
25 let mut config = Config::default(); 25 let mut config = Config::default();
26 config.rcc.mux = ClockSrc::PLL1R(PllSrc::HSI16, PllM::Div2, PllN::Mul10, PllClkDiv::NotDivided); 26 config.rcc.mux = ClockSrc::PLL1R(PllConfig {
27 source: PllSrc::HSI16,
28 m: Pllm::DIV2,
29 n: Plln::MUL10,
30 r: Plldiv::DIV1,
31 });
27 //config.rcc.mux = ClockSrc::MSI(MSIRange::Range48mhz); 32 //config.rcc.mux = ClockSrc::MSI(MSIRange::Range48mhz);
28 config.rcc.hsi48 = true; 33 config.rcc.hsi48 = true;
29 34
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml
index 320678ddc..fa2cc63fa 100644
--- a/examples/stm32wb/Cargo.toml
+++ b/examples/stm32wb/Cargo.toml
@@ -10,8 +10,8 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["
10embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } 10embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] }
11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
12embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 12embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
13embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 13embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } 14embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true }
15 15
16defmt = "0.3" 16defmt = "0.3"
17defmt-rtt = "0.4" 17defmt-rtt = "0.4"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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;
8use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; 8use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
9use embassy_stm32::rcc::WPAN_DEFAULT; 9use embassy_stm32::rcc::WPAN_DEFAULT;
10use embassy_stm32_wpan::TlMbox; 10use embassy_stm32_wpan::TlMbox;
11use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14bind_interrupts!(struct Irqs{ 14bind_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/Cargo.toml b/examples/stm32wba/Cargo.toml
index 26fcce26b..68ab5a468 100644
--- a/examples/stm32wba/Cargo.toml
+++ b/examples/stm32wba/Cargo.toml
@@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0"
8embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } 8embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] }
9embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 10embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
11embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 11embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
12embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } 12embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true }
13 13
14defmt = "0.3" 14defmt = "0.3"
15defmt-rtt = "0.4" 15defmt-rtt = "0.4"
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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/Cargo.toml b/examples/stm32wl/Cargo.toml
index f47a9a906..6a338af40 100644
--- a/examples/stm32wl/Cargo.toml
+++ b/examples/stm32wl/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } 9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] }
10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
14embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } 14embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] }
15lora-phy = { version = "2" } 15lora-phy = { version = "2" }
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 @@
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {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_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs
index fb2495326..8c789afbc 100644
--- a/examples/stm32wl/src/bin/lora_lorawan.rs
+++ b/examples/stm32wl/src/bin/lora_lorawan.rs
@@ -33,8 +33,7 @@ bind_interrupts!(struct Irqs{
33#[embassy_executor::main] 33#[embassy_executor::main]
34async fn main(_spawner: Spawner) { 34async fn main(_spawner: Spawner) {
35 let mut config = embassy_stm32::Config::default(); 35 let mut config = embassy_stm32::Config::default();
36 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; 36 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE;
37 config.rcc.rtc_mux = embassy_stm32::rcc::RtcClockSource::LSI;
38 let p = embassy_stm32::init(config); 37 let p = embassy_stm32::init(config);
39 38
40 pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)); 39 pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01));
diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs
index 3d8c31ff3..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};
11use embassy_stm32::bind_interrupts; 11use embassy_stm32::bind_interrupts;
12use embassy_stm32::gpio::{Level, Output, Pin, Speed}; 12use embassy_stm32::gpio::{Level, Output, Pin, Speed};
13use embassy_stm32::spi::Spi; 13use embassy_stm32::spi::Spi;
14use embassy_time::{Delay, Duration, Timer}; 14use embassy_time::{Delay, Timer};
15use lora_phy::mod_params::*; 15use lora_phy::mod_params::*;
16use lora_phy::sx1261_2::SX1261_2; 16use lora_phy::sx1261_2::SX1261_2;
17use lora_phy::LoRa; 17use lora_phy::LoRa;
@@ -26,7 +26,7 @@ bind_interrupts!(struct Irqs{
26#[embassy_executor::main] 26#[embassy_executor::main]
27async fn main(_spawner: Spawner) { 27async fn main(_spawner: Spawner) {
28 let mut config = embassy_stm32::Config::default(); 28 let mut config = embassy_stm32::Config::default();
29 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; 29 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE;
30 let p = embassy_stm32::init(config); 30 let p = embassy_stm32::init(config);
31 31
32 let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2); 32 let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2);
@@ -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/lora_p2p_send.rs b/examples/stm32wl/src/bin/lora_p2p_send.rs
index fbd0b0320..85f6a84b7 100644
--- a/examples/stm32wl/src/bin/lora_p2p_send.rs
+++ b/examples/stm32wl/src/bin/lora_p2p_send.rs
@@ -26,7 +26,7 @@ bind_interrupts!(struct Irqs{
26#[embassy_executor::main] 26#[embassy_executor::main]
27async fn main(_spawner: Spawner) { 27async fn main(_spawner: Spawner) {
28 let mut config = embassy_stm32::Config::default(); 28 let mut config = embassy_stm32::Config::default();
29 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; 29 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE;
30 let p = embassy_stm32::init(config); 30 let p = embassy_stm32::init(config);
31 31
32 let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2); 32 let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2);
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs
index 18eeac4fa..70676c704 100644
--- a/examples/stm32wl/src/bin/random.rs
+++ b/examples/stm32wl/src/bin/random.rs
@@ -4,6 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::rcc::{ClockSrc, MSIRange};
7use embassy_stm32::rng::{self, Rng}; 8use embassy_stm32::rng::{self, Rng};
8use embassy_stm32::{bind_interrupts, pac, peripherals}; 9use embassy_stm32::{bind_interrupts, pac, peripherals};
9use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
@@ -15,13 +16,10 @@ bind_interrupts!(struct Irqs{
15#[embassy_executor::main] 16#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
17 let mut config = embassy_stm32::Config::default(); 18 let mut config = embassy_stm32::Config::default();
18 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; 19 config.rcc.mux = ClockSrc::MSI(MSIRange::RANGE32M);
19 config.rcc.rtc_mux = embassy_stm32::rcc::RtcClockSource::LSI;
20
21 let p = embassy_stm32::init(config); 20 let p = embassy_stm32::init(config);
22 pac::RCC.ccipr().modify(|w| { 21
23 w.set_rngsel(0b01); 22 pac::RCC.ccipr().modify(|w| w.set_rngsel(0b11)); // msi
24 });
25 23
26 info!("Hello World!"); 24 info!("Hello World!");
27 25
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs
index 11734e4b6..9ebb05f22 100644
--- a/examples/stm32wl/src/bin/rtc.rs
+++ b/examples/stm32wl/src/bin/rtc.rs
@@ -5,20 +5,18 @@
5use chrono::{NaiveDate, NaiveDateTime}; 5use chrono::{NaiveDate, NaiveDateTime};
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::rcc::ClockSrc; 8use embassy_stm32::rcc::{ClockSrc, LsConfig};
9use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig}; 9use embassy_stm32::rtc::{Rtc, RtcConfig};
10use embassy_stm32::time::Hertz;
11use embassy_stm32::Config; 10use embassy_stm32::Config;
12use embassy_time::{Duration, Timer}; 11use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
14 13
15#[embassy_executor::main] 14#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 15async fn main(_spawner: Spawner) {
17 let p = { 16 let p = {
18 let mut config = Config::default(); 17 let mut config = Config::default();
19 config.rcc.mux = ClockSrc::HSE32; 18 config.rcc.mux = ClockSrc::HSE;
20 config.rcc.lse = Some(Hertz(32_768)); 19 config.rcc.ls = LsConfig::default_lse();
21 config.rcc.rtc_mux = RtcClockSource::LSE;
22 embassy_stm32::init(config) 20 embassy_stm32::init(config)
23 }; 21 };
24 info!("Hello World!"); 22 info!("Hello World!");
@@ -34,7 +32,7 @@ async fn main(_spawner: Spawner) {
34 rtc.set_datetime(now.into()).expect("datetime not set"); 32 rtc.set_datetime(now.into()).expect("datetime not set");
35 33
36 // In reality the delay would be much longer 34 // In reality the delay would be much longer
37 Timer::after(Duration::from_millis(20000)).await; 35 Timer::after_millis(20000).await;
38 36
39 let then: NaiveDateTime = rtc.now().unwrap().into(); 37 let then: NaiveDateTime = rtc.now().unwrap().into();
40 info!("Got RTC! {:?}", then.timestamp()); 38 info!("Got RTC! {:?}", then.timestamp());
diff --git a/examples/stm32wl/src/bin/uart_async.rs b/examples/stm32wl/src/bin/uart_async.rs
index 2c9b7c691..44e8f83a2 100644
--- a/examples/stm32wl/src/bin/uart_async.rs
+++ b/examples/stm32wl/src/bin/uart_async.rs
@@ -21,7 +21,7 @@ but can be surely changed for your needs.
21#[embassy_executor::main] 21#[embassy_executor::main]
22async fn main(_spawner: Spawner) { 22async fn main(_spawner: Spawner) {
23 let mut config = embassy_stm32::Config::default(); 23 let mut config = embassy_stm32::Config::default();
24 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; 24 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE;
25 let p = embassy_stm32::init(config); 25 let p = embassy_stm32::init(config);
26 26
27 defmt::info!("Starting system"); 27 defmt::info!("Starting system");
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml
index 12b2e2bd4..29339295a 100644
--- a/examples/wasm/Cargo.toml
+++ b/examples/wasm/Cargo.toml
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
10[dependencies] 10[dependencies]
11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] } 11embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] }
12embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } 12embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] }
13embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } 13embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "wasm", "nightly"] }
14 14
15wasm-logger = "0.2.0" 15wasm-logger = "0.2.0"
16wasm-bindgen = "0.2" 16wasm-bindgen = "0.2"
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
3use embassy_executor::Spawner; 3use embassy_executor::Spawner;
4use embassy_time::{Duration, Timer}; 4use embassy_time::Timer;
5 5
6#[embassy_executor::task] 6#[embassy_executor::task]
7async fn ticker() { 7async 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