aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wl55/src/bin
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-01-14 22:02:00 +0100
committerDario Nieuwenhuis <[email protected]>2022-01-19 17:59:55 +0100
commit58fc64722c65bbdc209ae0fd1700f03702bbcd08 (patch)
tree77f9412b47259cd4cf4170b0a257b371398d4f2c /examples/stm32wl55/src/bin
parent52e156b429417bde59d0ea67d11256866f1dcec9 (diff)
stm32/gpio: expose all functionality as inherent methods.
Diffstat (limited to 'examples/stm32wl55/src/bin')
-rw-r--r--examples/stm32wl55/src/bin/blinky.rs5
-rw-r--r--examples/stm32wl55/src/bin/button.rs11
-rw-r--r--examples/stm32wl55/src/bin/subghz.rs11
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;
8use embassy::time::{Duration, Timer}; 8use embassy::time::{Duration, Timer};
9use embassy_stm32::gpio::{Level, Output, Speed}; 9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use embedded_hal::digital::v2::OutputPin;
12use example_common::*; 11use 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"]
6mod example_common; 6mod example_common;
7use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 7use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
8use embedded_hal::digital::v2::{InputPin, OutputPin};
9use example_common::*; 8use example_common::*;
10 9
11use cortex_m_rt::entry; 10use 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};
17use embassy_stm32::interrupt; 17use embassy_stm32::interrupt;
18use embassy_stm32::subghz::*; 18use embassy_stm32::subghz::*;
19use embassy_stm32::Peripherals; 19use embassy_stm32::Peripherals;
20use embedded_hal::digital::v2::OutputPin;
21use example_common::unwrap; 20use example_common::unwrap;
22 21
23const PING_DATA: &str = "PING"; 22const 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}