diff options
Diffstat (limited to 'examples/stm32g4/src/bin/button.rs')
| -rw-r--r-- | examples/stm32g4/src/bin/button.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs new file mode 100644 index 000000000..f0a4c8745 --- /dev/null +++ b/examples/stm32g4/src/bin/button.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | #[path = "../example_common.rs"] | ||
| 6 | mod example_common; | ||
| 7 | use cortex_m_rt::entry; | ||
| 8 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 9 | use embedded_hal::digital::v2::InputPin; | ||
| 10 | use example_common::*; | ||
| 11 | |||
| 12 | #[entry] | ||
| 13 | fn main() -> ! { | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | let p = embassy_stm32::init(Default::default()); | ||
| 17 | |||
| 18 | let button = Input::new(p.PC13, Pull::Down); | ||
| 19 | |||
| 20 | loop { | ||
| 21 | if unwrap!(button.is_high()) { | ||
| 22 | info!("high"); | ||
| 23 | } else { | ||
| 24 | info!("low"); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
