diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-01-14 22:02:00 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-01-19 17:59:55 +0100 |
| commit | 58fc64722c65bbdc209ae0fd1700f03702bbcd08 (patch) | |
| tree | 77f9412b47259cd4cf4170b0a257b371398d4f2c /examples/stm32wl55 | |
| parent | 52e156b429417bde59d0ea67d11256866f1dcec9 (diff) | |
stm32/gpio: expose all functionality as inherent methods.
Diffstat (limited to 'examples/stm32wl55')
| -rw-r--r-- | examples/stm32wl55/src/bin/blinky.rs | 5 | ||||
| -rw-r--r-- | examples/stm32wl55/src/bin/button.rs | 11 | ||||
| -rw-r--r-- | examples/stm32wl55/src/bin/subghz.rs | 11 |
3 files changed, 12 insertions, 15 deletions
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; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after(Duration::from_millis(500)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(500)).await; | 26 | Timer::after(Duration::from_millis(500)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
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 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 8 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 9 | use example_common::*; | 8 | use example_common::*; |
| 10 | 9 | ||
| 11 | use cortex_m_rt::entry; | 10 | use cortex_m_rt::entry; |
| @@ -21,12 +20,12 @@ fn main() -> ! { | |||
| 21 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); | 20 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); |
| 22 | 21 | ||
| 23 | loop { | 22 | loop { |
| 24 | if button.is_high().unwrap() { | 23 | if button.is_high() { |
| 25 | led1.set_high().unwrap(); | 24 | led1.set_high(); |
| 26 | led2.set_low().unwrap(); | 25 | led2.set_low(); |
| 27 | } else { | 26 | } else { |
| 28 | led1.set_low().unwrap(); | 27 | led1.set_low(); |
| 29 | led2.set_high().unwrap(); | 28 | led2.set_high(); |
| 30 | } | 29 | } |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
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}; | |||
| 17 | use embassy_stm32::interrupt; | 17 | use embassy_stm32::interrupt; |
| 18 | use embassy_stm32::subghz::*; | 18 | use embassy_stm32::subghz::*; |
| 19 | use embassy_stm32::Peripherals; | 19 | use embassy_stm32::Peripherals; |
| 20 | use embedded_hal::digital::v2::OutputPin; | ||
| 21 | use example_common::unwrap; | 20 | use example_common::unwrap; |
| 22 | 21 | ||
| 23 | const PING_DATA: &str = "PING"; | 22 | const PING_DATA: &str = "PING"; |
| @@ -89,9 +88,9 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 89 | 88 | ||
| 90 | defmt::info!("Radio ready for use"); | 89 | defmt::info!("Radio ready for use"); |
| 91 | 90 | ||
| 92 | unwrap!(led1.set_low()); | 91 | led1.set_low(); |
| 93 | 92 | ||
| 94 | unwrap!(led2.set_high()); | 93 | led2.set_high(); |
| 95 | 94 | ||
| 96 | unwrap!(radio.set_standby(StandbyClk::Rc)); | 95 | unwrap!(radio.set_standby(StandbyClk::Rc)); |
| 97 | unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); | 96 | unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); |
| @@ -110,11 +109,11 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 110 | 109 | ||
| 111 | defmt::info!("Status: {:?}", unwrap!(radio.status())); | 110 | defmt::info!("Status: {:?}", unwrap!(radio.status())); |
| 112 | 111 | ||
| 113 | unwrap!(led2.set_low()); | 112 | led2.set_low(); |
| 114 | 113 | ||
| 115 | loop { | 114 | loop { |
| 116 | pin.wait_for_rising_edge().await; | 115 | pin.wait_for_rising_edge().await; |
| 117 | unwrap!(led3.set_high()); | 116 | led3.set_high(); |
| 118 | unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); | 117 | unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); |
| 119 | unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); | 118 | unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); |
| 120 | unwrap!(radio.set_tx(Timeout::DISABLED)); | 119 | unwrap!(radio.set_tx(Timeout::DISABLED)); |
| @@ -127,6 +126,6 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 127 | defmt::info!("TX done"); | 126 | defmt::info!("TX done"); |
| 128 | } | 127 | } |
| 129 | unwrap!(radio.clear_irq_status(irq_status)); | 128 | unwrap!(radio.clear_irq_status(irq_status)); |
| 130 | unwrap!(led3.set_low()); | 129 | led3.set_low(); |
| 131 | } | 130 | } |
| 132 | } | 131 | } |
