aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBen Gamari <[email protected]>2021-07-31 11:51:40 -0400
committerDario Nieuwenhuis <[email protected]>2021-08-05 22:39:59 +0200
commitf4950c44499b2d1ba1280000a05a1a5edd03d8ca (patch)
treeba2c93392868fe6910868d1d5d58562760ed0ab7 /examples
parent36402b5487a7001c859bf85673e74c64cc2b59cd (diff)
examples: Consistently use unwrap! in favor of .unwrap()
Unfortunately errors from `embedded_graphics` and `core` doesn't provide the necessary instances currently.
Diffstat (limited to 'examples')
-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
22 files changed, 67 insertions, 65 deletions
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..fd4f19e20 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).unwbrap());
35 usart.bwrite_all(&buf).unwrap(); 35 unwrap!(usart.bwrite_all(&buf).unwrap());
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}