From 58fc64722c65bbdc209ae0fd1700f03702bbcd08 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 14 Jan 2022 22:02:00 +0100 Subject: stm32/gpio: expose all functionality as inherent methods. --- examples/stm32wl55/src/bin/blinky.rs | 5 ++--- examples/stm32wl55/src/bin/button.rs | 11 +++++------ examples/stm32wl55/src/bin/subghz.rs | 11 +++++------ 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'examples/stm32wl55/src') diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs index 3c12a79d0..9ec208c3d 100644 --- a/examples/stm32wl55/src/bin/blinky.rs +++ b/examples/stm32wl55/src/bin/blinky.rs @@ -8,7 +8,6 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use embedded_hal::digital::v2::OutputPin; use example_common::*; #[embassy::main] @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { loop { info!("high"); - unwrap!(led.set_high()); + led.set_high(); Timer::after(Duration::from_millis(500)).await; info!("low"); - unwrap!(led.set_low()); + led.set_low(); Timer::after(Duration::from_millis(500)).await; } } diff --git a/examples/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs index 55b688663..be8f60e26 100644 --- a/examples/stm32wl55/src/bin/button.rs +++ b/examples/stm32wl55/src/bin/button.rs @@ -5,7 +5,6 @@ #[path = "../example_common.rs"] mod example_common; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; use cortex_m_rt::entry; @@ -21,12 +20,12 @@ fn main() -> ! { let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); loop { - if button.is_high().unwrap() { - led1.set_high().unwrap(); - led2.set_low().unwrap(); + if button.is_high() { + led1.set_high(); + led2.set_low(); } else { - led1.set_low().unwrap(); - led2.set_high().unwrap(); + led1.set_low(); + led2.set_high(); } } } diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs index 52fe6e9fa..570bd980f 100644 --- a/examples/stm32wl55/src/bin/subghz.rs +++ b/examples/stm32wl55/src/bin/subghz.rs @@ -17,7 +17,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::interrupt; use embassy_stm32::subghz::*; use embassy_stm32::Peripherals; -use embedded_hal::digital::v2::OutputPin; use example_common::unwrap; const PING_DATA: &str = "PING"; @@ -89,9 +88,9 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { defmt::info!("Radio ready for use"); - unwrap!(led1.set_low()); + led1.set_low(); - unwrap!(led2.set_high()); + led2.set_high(); unwrap!(radio.set_standby(StandbyClk::Rc)); unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); @@ -110,11 +109,11 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { defmt::info!("Status: {:?}", unwrap!(radio.status())); - unwrap!(led2.set_low()); + led2.set_low(); loop { pin.wait_for_rising_edge().await; - unwrap!(led3.set_high()); + led3.set_high(); unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); unwrap!(radio.set_tx(Timeout::DISABLED)); @@ -127,6 +126,6 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { defmt::info!("TX done"); } unwrap!(radio.clear_irq_status(irq_status)); - unwrap!(led3.set_low()); + led3.set_low(); } } -- cgit