aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-macros/src/lib.rs2
-rw-r--r--embassy-stm32/src/rcc/f4/mod.rs28
-rw-r--r--embassy-stm32/src/rcc/h7/mod.rs4
-rw-r--r--embassy-stm32/src/time_driver.rs5
-rw-r--r--embassy/src/executor/mod.rs8
-rw-r--r--examples/nrf/src/bin/blinky.rs5
-rw-r--r--examples/nrf/src/bin/gpiote_port.rs8
-rw-r--r--examples/nrf/src/bin/mpsc.rs7
-rw-r--r--examples/nrf/src/bin/qspi.rs12
-rw-r--r--examples/nrf/src/bin/qspi_lowpower.rs8
-rw-r--r--examples/nrf/src/bin/rng.rs6
-rw-r--r--examples/nrf/src/bin/spim.rs16
-rw-r--r--examples/nrf/src/bin/twim.rs2
-rw-r--r--examples/nrf/src/bin/twim_lowpower.rs2
-rw-r--r--examples/stm32f4/src/bin/blinky.rs4
-rw-r--r--examples/stm32f4/src/bin/button.rs10
-rw-r--r--examples/stm32f4/src/bin/usart.rs6
-rw-r--r--examples/stm32f4/src/bin/usart_dma.rs2
-rw-r--r--examples/stm32h7/src/bin/blinky.rs4
-rw-r--r--examples/stm32h7/src/bin/usart.rs6
-rw-r--r--examples/stm32l0/src/bin/blinky.rs4
-rw-r--r--examples/stm32l0/src/bin/button.rs10
-rw-r--r--examples/stm32l4/src/bin/blinky.rs4
-rw-r--r--examples/stm32l4/src/bin/button.rs2
-rw-r--r--examples/stm32l4/src/bin/spi_dma.rs4
-rw-r--r--examples/stm32l4/src/bin/usart.rs6
-rw-r--r--examples/stm32wb55/src/bin/blinky.rs4
27 files changed, 94 insertions, 85 deletions
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs
index d00baebfe..ddcee0cb1 100644
--- a/embassy-macros/src/lib.rs
+++ b/embassy-macros/src/lib.rs
@@ -364,7 +364,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
364 #chip_setup 364 #chip_setup
365 365
366 executor.run(|spawner| { 366 executor.run(|spawner| {
367 spawner.spawn(__embassy_main(spawner, p)).unwrap(); 367 spawner.must_spawn(__embassy_main(spawner, p));
368 }) 368 })
369 369
370 } 370 }
diff --git a/embassy-stm32/src/rcc/f4/mod.rs b/embassy-stm32/src/rcc/f4/mod.rs
index 1cf3e5bd9..eab98daf8 100644
--- a/embassy-stm32/src/rcc/f4/mod.rs
+++ b/embassy-stm32/src/rcc/f4/mod.rs
@@ -63,7 +63,7 @@ impl<'d> Rcc<'d> {
63 } 63 }
64 64
65 let sysclk = if sysclk_on_pll { 65 let sysclk = if sysclk_on_pll {
66 plls.pllsysclk.unwrap() 66 unwrap!(plls.pllsysclk)
67 } else { 67 } else {
68 sysclk 68 sysclk
69 }; 69 };
@@ -245,13 +245,11 @@ impl<'d> Rcc<'d> {
245 245
246 // Find the lowest pllm value that minimize the difference between 246 // Find the lowest pllm value that minimize the difference between
247 // target frequency and the real vco_out frequency. 247 // target frequency and the real vco_out frequency.
248 let pllm = (pllm_min..=pllm_max) 248 let pllm = unwrap!((pllm_min..=pllm_max).min_by_key(|pllm| {
249 .min_by_key(|pllm| { 249 let vco_in = pllsrcclk / pllm;
250 let vco_in = pllsrcclk / pllm; 250 let plln = target_freq / vco_in;
251 let plln = target_freq / vco_in; 251 target_freq - vco_in * plln
252 target_freq - vco_in * plln 252 }));
253 })
254 .unwrap();
255 253
256 let vco_in = pllsrcclk / pllm; 254 let vco_in = pllsrcclk / pllm;
257 assert!((1_000_000..=2_000_000).contains(&vco_in)); 255 assert!((1_000_000..=2_000_000).contains(&vco_in));
@@ -261,14 +259,12 @@ impl<'d> Rcc<'d> {
261 let plln = if pll48clk { 259 let plln = if pll48clk {
262 // try the different valid pllq according to the valid 260 // try the different valid pllq according to the valid
263 // main scaller values, and take the best 261 // main scaller values, and take the best
264 let pllq = (4..=9) 262 let pllq = unwrap!((4..=9).min_by_key(|pllq| {
265 .min_by_key(|pllq| { 263 let plln = 48_000_000 * pllq / vco_in;
266 let plln = 48_000_000 * pllq / vco_in; 264 let pll48_diff = 48_000_000 - vco_in * plln / pllq;
267 let pll48_diff = 48_000_000 - vco_in * plln / pllq; 265 let sysclk_diff = (sysclk as i32 - (vco_in * plln / sysclk_div) as i32).abs();
268 let sysclk_diff = (sysclk as i32 - (vco_in * plln / sysclk_div) as i32).abs(); 266 (pll48_diff, sysclk_diff)
269 (pll48_diff, sysclk_diff) 267 }));
270 })
271 .unwrap();
272 48_000_000 * pllq / vco_in 268 48_000_000 * pllq / vco_in
273 } else { 269 } else {
274 sysclk * sysclk_div / vco_in 270 sysclk * sysclk_div / vco_in
diff --git a/embassy-stm32/src/rcc/h7/mod.rs b/embassy-stm32/src/rcc/h7/mod.rs
index 2d9602a34..d6a55c3b4 100644
--- a/embassy-stm32/src/rcc/h7/mod.rs
+++ b/embassy-stm32/src/rcc/h7/mod.rs
@@ -120,7 +120,7 @@ impl<'d> Rcc<'d> {
120 unsafe { pll_setup(srcclk.0, &self.config.pll3, 2) }; 120 unsafe { pll_setup(srcclk.0, &self.config.pll3, 2) };
121 121
122 let sys_ck = if sys_use_pll1_p { 122 let sys_ck = if sys_use_pll1_p {
123 Hertz(pll1_p_ck.unwrap()) // Must have been set by sys_ck_setup 123 Hertz(unwrap!(pll1_p_ck)) // Must have been set by sys_ck_setup
124 } else { 124 } else {
125 sys_ck 125 sys_ck
126 }; 126 };
@@ -390,7 +390,7 @@ impl<'d> Rcc<'d> {
390 // set. The traceclk mux is synchronous with the system 390 // set. The traceclk mux is synchronous with the system
391 // clock mux, but has pll1_r_ck as an input. In order to 391 // clock mux, but has pll1_r_ck as an input. In order to
392 // keep traceclk running, we force a pll1_r_ck. 392 // keep traceclk running, we force a pll1_r_ck.
393 (true, None) => Some(Hertz(self.config.pll1.p_ck.unwrap().0 / 2)), 393 (true, None) => Some(Hertz(unwrap!(self.config.pll1.p_ck).0 / 2)),
394 394
395 // Either pll1 not selected as system clock, free choice 395 // Either pll1 not selected as system clock, free choice
396 // of pll1_r_ck. Or pll1 is selected, assume user has set 396 // of pll1_r_ck. Or pll1 is selected, assume user has set
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs
index 3ae4b1c4d..91b8525ae 100644
--- a/embassy-stm32/src/time_driver.rs
+++ b/embassy-stm32/src/time_driver.rs
@@ -106,7 +106,10 @@ impl State {
106 r.cnt().write(|w| w.set_cnt(0)); 106 r.cnt().write(|w| w.set_cnt(0));
107 107
108 let psc = timer_freq.0 / TICKS_PER_SECOND as u32 - 1; 108 let psc = timer_freq.0 / TICKS_PER_SECOND as u32 - 1;
109 let psc: u16 = psc.try_into().unwrap(); 109 let psc: u16 = match psc.try_into() {
110 Err(_) => panic!("psc division overflow: {}", psc),
111 Ok(n) => n,
112 };
110 113
111 r.psc().write(|w| w.set_psc(psc)); 114 r.psc().write(|w| w.set_psc(psc));
112 r.arr().write(|w| w.set_arr(u16::MAX)); 115 r.arr().write(|w| w.set_arr(u16::MAX));
diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs
index ee05b6760..f3c877290 100644
--- a/embassy/src/executor/mod.rs
+++ b/embassy/src/executor/mod.rs
@@ -56,6 +56,14 @@ impl Spawner {
56 } 56 }
57 } 57 }
58 58
59 /// Used by the `embassy_macros::main!` macro to throw an error when spawn
60 /// fails. This is here to allow conditional use of `defmt::unwrap!`
61 /// without introducing a `defmt` feature in the `embassy_macros` package,
62 /// which would require use of `-Z namespaced-features`.
63 pub fn must_spawn<F>(&self, token: SpawnToken<F>) -> () {
64 unwrap!(self.spawn(token));
65 }
66
59 /// Convert this Spawner to a SendSpawner. This allows you to send the 67 /// Convert this Spawner to a SendSpawner. This allows you to send the
60 /// spawner to other threads, but the spawner loses the ability to spawn 68 /// spawner to other threads, but the spawner loses the ability to spawn
61 /// non-Send tasks. 69 /// non-Send tasks.
diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs
index 6d4561beb..8fa1f87a9 100644
--- a/examples/nrf/src/bin/blinky.rs
+++ b/examples/nrf/src/bin/blinky.rs
@@ -6,6 +6,7 @@
6#[path = "../example_common.rs"] 6#[path = "../example_common.rs"]
7mod example_common; 7mod example_common;
8 8
9use defmt::unwrap;
9use embassy::executor::Spawner; 10use embassy::executor::Spawner;
10use embassy::time::{Duration, Timer}; 11use embassy::time::{Duration, Timer};
11use embassy_nrf::gpio::{Level, Output, OutputDrive}; 12use embassy_nrf::gpio::{Level, Output, OutputDrive};
@@ -17,9 +18,9 @@ async fn main(_spawner: Spawner, p: Peripherals) {
17 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 18 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
18 19
19 loop { 20 loop {
20 led.set_high().unwrap(); 21 unwrap!(led.set_high());
21 Timer::after(Duration::from_millis(300)).await; 22 Timer::after(Duration::from_millis(300)).await;
22 led.set_low().unwrap(); 23 unwrap!(led.set_low());
23 Timer::after(Duration::from_millis(300)).await; 24 Timer::after(Duration::from_millis(300)).await;
24 } 25 }
25} 26}
diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs
index 700247d37..57f8a518e 100644
--- a/examples/nrf/src/bin/gpiote_port.rs
+++ b/examples/nrf/src/bin/gpiote_port.rs
@@ -32,8 +32,8 @@ async fn main(spawner: Spawner, p: Peripherals) {
32 let btn3 = PortInput::new(Input::new(p.P0_24.degrade(), Pull::Up)); 32 let btn3 = PortInput::new(Input::new(p.P0_24.degrade(), Pull::Up));
33 let btn4 = PortInput::new(Input::new(p.P0_25.degrade(), Pull::Up)); 33 let btn4 = PortInput::new(Input::new(p.P0_25.degrade(), Pull::Up));
34 34
35 spawner.spawn(button_task(1, btn1)).unwrap(); 35 unwrap!(spawner.spawn(button_task(1, btn1)));
36 spawner.spawn(button_task(2, btn2)).unwrap(); 36 unwrap!(spawner.spawn(button_task(2, btn2)));
37 spawner.spawn(button_task(3, btn3)).unwrap(); 37 unwrap!(spawner.spawn(button_task(3, btn3)));
38 spawner.spawn(button_task(4, btn4)).unwrap(); 38 unwrap!(spawner.spawn(button_task(4, btn4)));
39} 39}
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs
index e31754eb8..b40ed5e0e 100644
--- a/examples/nrf/src/bin/mpsc.rs
+++ b/examples/nrf/src/bin/mpsc.rs
@@ -6,6 +6,7 @@
6#[path = "../example_common.rs"] 6#[path = "../example_common.rs"]
7mod example_common; 7mod example_common;
8 8
9use defmt::unwrap;
9use embassy::executor::Spawner; 10use embassy::executor::Spawner;
10use embassy::time::{Duration, Timer}; 11use embassy::time::{Duration, Timer};
11use embassy::util::mpsc::TryRecvError; 12use embassy::util::mpsc::TryRecvError;
@@ -39,7 +40,7 @@ async fn main(spawner: Spawner, p: Peripherals) {
39 let channel = CHANNEL.put(Channel::new()); 40 let channel = CHANNEL.put(Channel::new());
40 let (sender, mut receiver) = mpsc::split(channel); 41 let (sender, mut receiver) = mpsc::split(channel);
41 42
42 spawner.spawn(my_task(sender)).unwrap(); 43 unwrap!(spawner.spawn(my_task(sender)));
43 44
44 // We could just loop on `receiver.recv()` for simplicity. The code below 45 // We could just loop on `receiver.recv()` for simplicity. The code below
45 // is optimized to drain the queue as fast as possible in the spirit of 46 // is optimized to drain the queue as fast as possible in the spirit of
@@ -53,8 +54,8 @@ async fn main(spawner: Spawner, p: Peripherals) {
53 Err(TryRecvError::Closed) => break, 54 Err(TryRecvError::Closed) => break,
54 }; 55 };
55 match maybe_message { 56 match maybe_message {
56 Some(LedState::On) => led.set_high().unwrap(), 57 Some(LedState::On) => unwrap!(led.set_high()),
57 Some(LedState::Off) => led.set_low().unwrap(), 58 Some(LedState::Off) => unwrap!(led.set_low()),
58 _ => (), 59 _ => (),
59 } 60 }
60 } 61 }
diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs
index 43bfb83ca..0adeadd65 100644
--- a/examples/nrf/src/bin/qspi.rs
+++ b/examples/nrf/src/bin/qspi.rs
@@ -35,19 +35,19 @@ async fn main(_spawner: Spawner, p: Peripherals) {
35 .await; 35 .await;
36 36
37 let mut id = [1; 3]; 37 let mut id = [1; 3];
38 q.custom_instruction(0x9F, &[], &mut id).await.unwrap(); 38 unwrap!(q.custom_instruction(0x9F, &[], &mut id).await);
39 info!("id: {}", id); 39 info!("id: {}", id);
40 40
41 // Read status register 41 // Read status register
42 let mut status = [4; 1]; 42 let mut status = [4; 1];
43 q.custom_instruction(0x05, &[], &mut status).await.unwrap(); 43 unwrap!(q.custom_instruction(0x05, &[], &mut status).await);
44 44
45 info!("status: {:?}", status[0]); 45 info!("status: {:?}", status[0]);
46 46
47 if status[0] & 0x40 == 0 { 47 if status[0] & 0x40 == 0 {
48 status[0] |= 0x40; 48 status[0] |= 0x40;
49 49
50 q.custom_instruction(0x01, &status, &mut []).await.unwrap(); 50 unwrap!(q.custom_instruction(0x01, &status, &mut []).await);
51 51
52 info!("enabled quad in status"); 52 info!("enabled quad in status");
53 } 53 }
@@ -58,19 +58,19 @@ async fn main(_spawner: Spawner, p: Peripherals) {
58 58
59 for i in 0..8 { 59 for i in 0..8 {
60 info!("page {:?}: erasing... ", i); 60 info!("page {:?}: erasing... ", i);
61 q.erase(i * PAGE_SIZE).await.unwrap(); 61 unwrap!(q.erase(i * PAGE_SIZE).await);
62 62
63 for j in 0..PAGE_SIZE { 63 for j in 0..PAGE_SIZE {
64 buf.0[j] = pattern((j + i * PAGE_SIZE) as u32); 64 buf.0[j] = pattern((j + i * PAGE_SIZE) as u32);
65 } 65 }
66 66
67 info!("programming..."); 67 info!("programming...");
68 q.write(i * PAGE_SIZE, &buf.0).await.unwrap(); 68 unwrap!(q.write(i * PAGE_SIZE, &buf.0).await);
69 } 69 }
70 70
71 for i in 0..8 { 71 for i in 0..8 {
72 info!("page {:?}: reading... ", i); 72 info!("page {:?}: reading... ", i);
73 q.read(i * PAGE_SIZE, &mut buf.0).await.unwrap(); 73 unwrap!(q.read(i * PAGE_SIZE, &mut buf.0).await);
74 74
75 info!("verifying..."); 75 info!("verifying...");
76 for j in 0..PAGE_SIZE { 76 for j in 0..PAGE_SIZE {
diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs
index 502710db9..30df22451 100644
--- a/examples/nrf/src/bin/qspi_lowpower.rs
+++ b/examples/nrf/src/bin/qspi_lowpower.rs
@@ -49,19 +49,19 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
49 .await; 49 .await;
50 50
51 let mut id = [1; 3]; 51 let mut id = [1; 3];
52 q.custom_instruction(0x9F, &[], &mut id).await.unwrap(); 52 unwrap!(q.custom_instruction(0x9F, &[], &mut id).await);
53 info!("id: {}", id); 53 info!("id: {}", id);
54 54
55 // Read status register 55 // Read status register
56 let mut status = [4; 1]; 56 let mut status = [4; 1];
57 q.custom_instruction(0x05, &[], &mut status).await.unwrap(); 57 unwrap!(q.custom_instruction(0x05, &[], &mut status).await);
58 58
59 info!("status: {:?}", status[0]); 59 info!("status: {:?}", status[0]);
60 60
61 if status[0] & 0x40 == 0 { 61 if status[0] & 0x40 == 0 {
62 status[0] |= 0x40; 62 status[0] |= 0x40;
63 63
64 q.custom_instruction(0x01, &status, &mut []).await.unwrap(); 64 unwrap!(q.custom_instruction(0x01, &status, &mut []).await);
65 65
66 info!("enabled quad in status"); 66 info!("enabled quad in status");
67 } 67 }
@@ -69,7 +69,7 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
69 let mut buf = AlignedBuf([0u8; 64]); 69 let mut buf = AlignedBuf([0u8; 64]);
70 70
71 info!("reading..."); 71 info!("reading...");
72 q.read(0, &mut buf.0).await.unwrap(); 72 unwrap!(q.read(0, &mut buf.0).await);
73 info!("read: {=[u8]:x}", buf.0); 73 info!("read: {=[u8]:x}", buf.0);
74 74
75 // Drop the QSPI instance. This disables the peripehral and deconfigures the pins. 75 // Drop the QSPI instance. This disables the peripehral and deconfigures the pins.
diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs
index e19982312..aa5215af6 100644
--- a/examples/nrf/src/bin/rng.rs
+++ b/examples/nrf/src/bin/rng.rs
@@ -6,7 +6,7 @@
6#[path = "../example_common.rs"] 6#[path = "../example_common.rs"]
7mod example_common; 7mod example_common;
8 8
9use defmt::panic; 9use defmt::{panic, unwrap};
10use embassy::executor::Spawner; 10use embassy::executor::Spawner;
11use embassy::traits::rng::Rng as _; 11use embassy::traits::rng::Rng as _;
12use embassy_nrf::interrupt; 12use embassy_nrf::interrupt;
@@ -20,14 +20,14 @@ async fn main(_spawner: Spawner, p: Peripherals) {
20 20
21 // Async API 21 // Async API
22 let mut bytes = [0; 4]; 22 let mut bytes = [0; 4];
23 rng.fill_bytes(&mut bytes).await.unwrap(); // nRF RNG is infallible 23 unwrap!(rng.fill_bytes(&mut bytes).await); // nRF RNG is infallible
24 defmt::info!("Some random bytes: {:?}", bytes); 24 defmt::info!("Some random bytes: {:?}", bytes);
25 25
26 // Sync API with `rand` 26 // Sync API with `rand`
27 defmt::info!("A random number from 1 to 10: {:?}", rng.gen_range(1..=10)); 27 defmt::info!("A random number from 1 to 10: {:?}", rng.gen_range(1..=10));
28 28
29 let mut bytes = [0; 1024]; 29 let mut bytes = [0; 1024];
30 rng.fill_bytes(&mut bytes).await.unwrap(); 30 unwrap!(rng.fill_bytes(&mut bytes).await);
31 let zero_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_zeros()); 31 let zero_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_zeros());
32 let one_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_ones()); 32 let one_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_ones());
33 defmt::info!( 33 defmt::info!(
diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs
index 444e50bcf..7c9779a36 100644
--- a/examples/nrf/src/bin/spim.rs
+++ b/examples/nrf/src/bin/spim.rs
@@ -31,12 +31,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
31 31
32 // softreset 32 // softreset
33 cortex_m::asm::delay(10); 33 cortex_m::asm::delay(10);
34 ncs.set_low().unwrap(); 34 unwrap!(ncs.set_low());
35 cortex_m::asm::delay(5); 35 cortex_m::asm::delay(5);
36 let tx = [0xFF]; 36 let tx = [0xFF];
37 unwrap!(spim.read_write(&mut [], &tx).await); 37 unwrap!(spim.read_write(&mut [], &tx).await);
38 cortex_m::asm::delay(10); 38 cortex_m::asm::delay(10);
39 ncs.set_high().unwrap(); 39 unwrap!(ncs.set_high());
40 40
41 cortex_m::asm::delay(100000); 41 cortex_m::asm::delay(100000);
42 42
@@ -44,31 +44,31 @@ async fn main(_spawner: Spawner, p: Peripherals) {
44 44
45 // read ESTAT 45 // read ESTAT
46 cortex_m::asm::delay(5000); 46 cortex_m::asm::delay(5000);
47 ncs.set_low().unwrap(); 47 unwrap!(ncs.set_low());
48 cortex_m::asm::delay(5000); 48 cortex_m::asm::delay(5000);
49 let tx = [0b000_11101, 0]; 49 let tx = [0b000_11101, 0];
50 unwrap!(spim.read_write(&mut rx, &tx).await); 50 unwrap!(spim.read_write(&mut rx, &tx).await);
51 cortex_m::asm::delay(5000); 51 cortex_m::asm::delay(5000);
52 ncs.set_high().unwrap(); 52 unwrap!(ncs.set_high());
53 info!("estat: {=[?]}", rx); 53 info!("estat: {=[?]}", rx);
54 54
55 // Switch to bank 3 55 // Switch to bank 3
56 cortex_m::asm::delay(10); 56 cortex_m::asm::delay(10);
57 ncs.set_low().unwrap(); 57 unwrap!(ncs.set_low());
58 cortex_m::asm::delay(5); 58 cortex_m::asm::delay(5);
59 let tx = [0b100_11111, 0b11]; 59 let tx = [0b100_11111, 0b11];
60 unwrap!(spim.read_write(&mut rx, &tx).await); 60 unwrap!(spim.read_write(&mut rx, &tx).await);
61 cortex_m::asm::delay(10); 61 cortex_m::asm::delay(10);
62 ncs.set_high().unwrap(); 62 unwrap!(ncs.set_high());
63 63
64 // read EREVID 64 // read EREVID
65 cortex_m::asm::delay(10); 65 cortex_m::asm::delay(10);
66 ncs.set_low().unwrap(); 66 unwrap!(ncs.set_low());
67 cortex_m::asm::delay(5); 67 cortex_m::asm::delay(5);
68 let tx = [0b000_10010, 0]; 68 let tx = [0b000_10010, 0];
69 unwrap!(spim.read_write(&mut rx, &tx).await); 69 unwrap!(spim.read_write(&mut rx, &tx).await);
70 cortex_m::asm::delay(10); 70 cortex_m::asm::delay(10);
71 ncs.set_high().unwrap(); 71 unwrap!(ncs.set_high());
72 72
73 info!("erevid: {=[?]}", rx); 73 info!("erevid: {=[?]}", rx);
74} 74}
diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs
index ad5653cfc..0b8f1407b 100644
--- a/examples/nrf/src/bin/twim.rs
+++ b/examples/nrf/src/bin/twim.rs
@@ -27,7 +27,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
27 info!("Reading..."); 27 info!("Reading...");
28 28
29 let mut buf = [0u8; 16]; 29 let mut buf = [0u8; 16];
30 twi.write_then_read(ADDRESS, &mut [0x00], &mut buf).unwrap(); 30 unwrap!(twi.write_then_read(ADDRESS, &mut [0x00], &mut buf));
31 31
32 info!("Read: {=[u8]:x}", buf); 32 info!("Read: {=[u8]:x}", buf);
33} 33}
diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs
index f8cba2496..a4bab9606 100644
--- a/examples/nrf/src/bin/twim_lowpower.rs
+++ b/examples/nrf/src/bin/twim_lowpower.rs
@@ -37,7 +37,7 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
37 info!("Reading..."); 37 info!("Reading...");
38 38
39 let mut buf = [0u8; 16]; 39 let mut buf = [0u8; 16];
40 twi.write_then_read(ADDRESS, &mut [0x00], &mut buf).unwrap(); 40 unwrap!(twi.write_then_read(ADDRESS, &mut [0x00], &mut buf));
41 41
42 info!("Read: {=[u8]:x}", buf); 42 info!("Read: {=[u8]:x}", buf);
43 43
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs
index 00eab761e..b3a0ffb8e 100644
--- a/examples/stm32f4/src/bin/blinky.rs
+++ b/examples/stm32f4/src/bin/blinky.rs
@@ -26,11 +26,11 @@ async fn main(_spawner: Spawner, p: Peripherals) {
26 26
27 loop { 27 loop {
28 info!("high"); 28 info!("high");
29 led.set_high().unwrap(); 29 unwrap!(led.set_high());
30 Timer::after(Duration::from_millis(300)).await; 30 Timer::after(Duration::from_millis(300)).await;
31 31
32 info!("low"); 32 info!("low");
33 led.set_low().unwrap(); 33 unwrap!(led.set_low());
34 Timer::after(Duration::from_millis(300)).await; 34 Timer::after(Duration::from_millis(300)).await;
35 } 35 }
36} 36}
diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs
index 82c83e80e..90998cf46 100644
--- a/examples/stm32f4/src/bin/button.rs
+++ b/examples/stm32f4/src/bin/button.rs
@@ -28,14 +28,14 @@ fn main() -> ! {
28 let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); 28 let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
29 29
30 loop { 30 loop {
31 if button.is_high().unwrap() { 31 if unwrap!(button.is_high()) {
32 info!("high"); 32 info!("high");
33 led1.set_high().unwrap(); 33 unwrap!(led1.set_high());
34 led3.set_low().unwrap(); 34 unwrap!(led3.set_low());
35 } else { 35 } else {
36 info!("low"); 36 info!("low");
37 led1.set_low().unwrap(); 37 unwrap!(led1.set_low());
38 led3.set_high().unwrap(); 38 unwrap!(led3.set_high());
39 } 39 }
40 } 40 }
41} 41}
diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs
index da3261949..781c6a958 100644
--- a/examples/stm32f4/src/bin/usart.rs
+++ b/examples/stm32f4/src/bin/usart.rs
@@ -26,12 +26,12 @@ fn main() -> ! {
26 let config = Config::default(); 26 let config = Config::default();
27 let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, NoDma, NoDma, config); 27 let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, NoDma, NoDma, config);
28 28
29 usart.bwrite_all(b"Hello Embassy World!\r\n").unwrap(); 29 unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n"));
30 info!("wrote Hello, starting echo"); 30 info!("wrote Hello, starting echo");
31 31
32 let mut buf = [0u8; 1]; 32 let mut buf = [0u8; 1];
33 loop { 33 loop {
34 usart.read_blocking(&mut buf).unwrap(); 34 unwrap!(usart.read_blocking(&mut buf));
35 usart.bwrite_all(&buf).unwrap(); 35 unwrap!(usart.bwrite_all(&buf));
36 } 36 }
37} 37}
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs
index 05a550e95..bf50b8ad9 100644
--- a/examples/stm32f4/src/bin/usart_dma.rs
+++ b/examples/stm32f4/src/bin/usart_dma.rs
@@ -31,7 +31,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
31 let mut s: String<128> = String::new(); 31 let mut s: String<128> = String::new();
32 core::write!(&mut s, "Hello DMA World {}!\r\n", n).unwrap(); 32 core::write!(&mut s, "Hello DMA World {}!\r\n", n).unwrap();
33 33
34 usart.write(s.as_bytes()).await.unwrap(); 34 unwrap!(usart.write(s.as_bytes()).await);
35 info!("wrote DMA"); 35 info!("wrote DMA");
36 } 36 }
37} 37}
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs
index b5e0c18a5..09b34eacb 100644
--- a/examples/stm32h7/src/bin/blinky.rs
+++ b/examples/stm32h7/src/bin/blinky.rs
@@ -24,11 +24,11 @@ async fn main(_spawner: Spawner, p: Peripherals) {
24 24
25 loop { 25 loop {
26 info!("high"); 26 info!("high");
27 led.set_high().unwrap(); 27 unwrap!(led.set_high());
28 Timer::after(Duration::from_millis(500)).await; 28 Timer::after(Duration::from_millis(500)).await;
29 29
30 info!("low"); 30 info!("low");
31 led.set_low().unwrap(); 31 unwrap!(led.set_low());
32 Timer::after(Duration::from_millis(500)).await; 32 Timer::after(Duration::from_millis(500)).await;
33 } 33 }
34} 34}
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs
index 9c93d3f22..a3fcc6d3f 100644
--- a/examples/stm32h7/src/bin/usart.rs
+++ b/examples/stm32h7/src/bin/usart.rs
@@ -23,13 +23,13 @@ async fn main_task() {
23 let config = Config::default(); 23 let config = Config::default();
24 let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, NoDma, NoDma, config); 24 let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, NoDma, NoDma, config);
25 25
26 usart.bwrite_all(b"Hello Embassy World!\r\n").unwrap(); 26 unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n"));
27 info!("wrote Hello, starting echo"); 27 info!("wrote Hello, starting echo");
28 28
29 let mut buf = [0u8; 1]; 29 let mut buf = [0u8; 1];
30 loop { 30 loop {
31 usart.read_blocking(&mut buf).unwrap(); 31 unwrap!(usart.read_blocking(&mut buf));
32 usart.bwrite_all(&buf).unwrap(); 32 unwrap!(usart.bwrite_all(&buf));
33 } 33 }
34} 34}
35 35
diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs
index faa42896b..29f5d7c74 100644
--- a/examples/stm32l0/src/bin/blinky.rs
+++ b/examples/stm32l0/src/bin/blinky.rs
@@ -25,11 +25,11 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
25 25
26 loop { 26 loop {
27 info!("high"); 27 info!("high");
28 led.set_high().unwrap(); 28 unwrap!(led.set_high());
29 Timer::after(Duration::from_millis(300)).await; 29 Timer::after(Duration::from_millis(300)).await;
30 30
31 info!("low"); 31 info!("low");
32 led.set_low().unwrap(); 32 unwrap!(led.set_low());
33 Timer::after(Duration::from_millis(300)).await; 33 Timer::after(Duration::from_millis(300)).await;
34 } 34 }
35} 35}
diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs
index 6b75de509..e37d3f26d 100644
--- a/examples/stm32l0/src/bin/button.rs
+++ b/examples/stm32l0/src/bin/button.rs
@@ -27,14 +27,14 @@ fn main() -> ! {
27 let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); 27 let mut led2 = Output::new(p.PB5, Level::High, Speed::Low);
28 28
29 loop { 29 loop {
30 if button.is_high().unwrap() { 30 if unwrap!(button.is_high()) {
31 info!("high"); 31 info!("high");
32 led1.set_high().unwrap(); 32 unwrap!(led1.set_high());
33 led2.set_low().unwrap(); 33 unwrap!(led2.set_low());
34 } else { 34 } else {
35 info!("low"); 35 info!("low");
36 led1.set_low().unwrap(); 36 unwrap!(led1.set_low());
37 led2.set_high().unwrap(); 37 unwrap!(led2.set_high());
38 } 38 }
39 } 39 }
40} 40}
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs
index fc86b11eb..c9ba587e4 100644
--- a/examples/stm32l4/src/bin/blinky.rs
+++ b/examples/stm32l4/src/bin/blinky.rs
@@ -25,9 +25,9 @@ async fn main(_spawner: Spawner, p: Peripherals) {
25 let mut led = Output::new(p.PB14, Level::High, Speed::Low); 25 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
26 26
27 loop { 27 loop {
28 led.set_high().unwrap(); 28 unwrap!(led.set_high());
29 Timer::after(Duration::from_millis(300)).await; 29 Timer::after(Duration::from_millis(300)).await;
30 led.set_low().unwrap(); 30 unwrap!(led.set_low());
31 Timer::after(Duration::from_millis(300)).await; 31 Timer::after(Duration::from_millis(300)).await;
32 } 32 }
33} 33}
diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs
index e2756b711..883a0d6c8 100644
--- a/examples/stm32l4/src/bin/button.rs
+++ b/examples/stm32l4/src/bin/button.rs
@@ -24,7 +24,7 @@ fn main() -> ! {
24 let button = Input::new(p.PC13, Pull::Up); 24 let button = Input::new(p.PC13, Pull::Up);
25 25
26 loop { 26 loop {
27 if button.is_high().unwrap() { 27 if unwrap!(button.is_high()) {
28 info!("high"); 28 info!("high");
29 } else { 29 } else {
30 info!("low"); 30 info!("low");
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs
index ba77331be..d626a1290 100644
--- a/examples/stm32l4/src/bin/spi_dma.rs
+++ b/examples/stm32l4/src/bin/spi_dma.rs
@@ -45,10 +45,10 @@ async fn main(_spawner: Spawner, p: Peripherals) {
45 let ready = Input::new(p.PE1, Pull::Up); 45 let ready = Input::new(p.PE1, Pull::Up);
46 46
47 cortex_m::asm::delay(100_000); 47 cortex_m::asm::delay(100_000);
48 reset.set_high().unwrap(); 48 unwrap!(reset.set_high());
49 cortex_m::asm::delay(100_000); 49 cortex_m::asm::delay(100_000);
50 50
51 while ready.is_low().unwrap() { 51 while unwrap!(ready.is_low()) {
52 info!("waiting for ready"); 52 info!("waiting for ready");
53 } 53 }
54 54
diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs
index ccb82b8d4..95ac84b23 100644
--- a/examples/stm32l4/src/bin/usart.rs
+++ b/examples/stm32l4/src/bin/usart.rs
@@ -26,12 +26,12 @@ fn main() -> ! {
26 let config = Config::default(); 26 let config = Config::default();
27 let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config); 27 let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config);
28 28
29 usart.bwrite_all(b"Hello Embassy World!\r\n").unwrap(); 29 unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n"));
30 info!("wrote Hello, starting echo"); 30 info!("wrote Hello, starting echo");
31 31
32 let mut buf = [0u8; 1]; 32 let mut buf = [0u8; 1];
33 loop { 33 loop {
34 usart.read_blocking(&mut buf).unwrap(); 34 unwrap!(usart.read_blocking(&mut buf));
35 usart.bwrite_all(&buf).unwrap(); 35 unwrap!(usart.bwrite_all(&buf));
36 } 36 }
37} 37}
diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs
index 5ffef9b38..2deaf5f55 100644
--- a/examples/stm32wb55/src/bin/blinky.rs
+++ b/examples/stm32wb55/src/bin/blinky.rs
@@ -24,11 +24,11 @@ async fn main(_spawner: Spawner, p: Peripherals) {
24 24
25 loop { 25 loop {
26 info!("high"); 26 info!("high");
27 led.set_high().unwrap(); 27 unwrap!(led.set_high());
28 Timer::after(Duration::from_millis(500)).await; 28 Timer::after(Duration::from_millis(500)).await;
29 29
30 info!("low"); 30 info!("low");
31 led.set_low().unwrap(); 31 unwrap!(led.set_low());
32 Timer::after(Duration::from_millis(500)).await; 32 Timer::after(Duration::from_millis(500)).await;
33 } 33 }
34} 34}