aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32l4/src/bin/button.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-07-24 14:03:42 +0200
committerGitHub <[email protected]>2021-07-24 14:03:42 +0200
commit495d977b03f6343b424ecddfa5ff0417f94c0c4e (patch)
tree2527a6a77084e2e7d68a178d085dbbc91f95548f /examples/stm32l4/src/bin/button.rs
parent4899168534e70294dd9ec853cbf4efb417e0035a (diff)
parent5b0ae5c25b527069da176afaf1ab45a06b156df4 (diff)
Merge pull request #314 from embassy-rs/example-cleanup-l4
stm32/examples: cleanup L4
Diffstat (limited to 'examples/stm32l4/src/bin/button.rs')
-rw-r--r--examples/stm32l4/src/bin/button.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs
index eff9189ec..08c20ce4b 100644
--- a/examples/stm32l4/src/bin/button.rs
+++ b/examples/stm32l4/src/bin/button.rs
@@ -8,14 +8,15 @@
8 8
9#[path = "../example_common.rs"] 9#[path = "../example_common.rs"]
10mod example_common; 10mod example_common;
11use cortex_m_rt::entry; 11use defmt::panic;
12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 12use embassy::executor::Spawner;
13use embassy_stm32::pac; 13use embassy_stm32::gpio::{Input, Pull};
14use embedded_hal::digital::v2::{InputPin, OutputPin}; 14use embassy_stm32::{pac, Peripherals};
15use embedded_hal::digital::v2::InputPin;
15use example_common::*; 16use example_common::*;
16 17
17#[entry] 18#[embassy::main]
18fn main() -> ! { 19async fn main(_spawner: Spawner, p: Peripherals) {
19 info!("Hello World!"); 20 info!("Hello World!");
20 21
21 unsafe { 22 unsafe {
@@ -26,21 +27,13 @@ fn main() -> ! {
26 }); 27 });
27 } 28 }
28 29
29 let p = embassy_stm32::init(Default::default());
30
31 let button = Input::new(p.PC13, Pull::Up); 30 let button = Input::new(p.PC13, Pull::Up);
32 let mut led1 = Output::new(p.PA5, Level::High, Speed::Low);
33 let mut led2 = Output::new(p.PB14, Level::High, Speed::Low);
34 31
35 loop { 32 loop {
36 if button.is_high().unwrap() { 33 if button.is_high().unwrap() {
37 info!("high"); 34 info!("high");
38 led1.set_high().unwrap();
39 led2.set_low().unwrap();
40 } else { 35 } else {
41 info!("low"); 36 info!("low");
42 led1.set_low().unwrap();
43 led2.set_high().unwrap();
44 } 37 }
45 } 38 }
46} 39}