diff options
| author | Ben Gamari <[email protected]> | 2021-07-31 10:01:32 -0400 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-08-20 01:28:50 +0200 |
| commit | ee841499ee8ee4d073930b2645eb70a0e652b383 (patch) | |
| tree | fe44a0b81be02994c5d0d9db8a0e74fd5001a3e8 /examples/stm32g0/src/bin/button.rs | |
| parent | e2f71ffbbdeac4f64b0468fc7e93452388c16eee (diff) | |
Add STM32G0 examples
Diffstat (limited to 'examples/stm32g0/src/bin/button.rs')
| -rw-r--r-- | examples/stm32g0/src/bin/button.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs new file mode 100644 index 000000000..a834b2fce --- /dev/null +++ b/examples/stm32g0/src/bin/button.rs | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(trait_alias)] | ||
| 4 | #![feature(type_alias_impl_trait)] | ||
| 5 | #![allow(incomplete_features)] | ||
| 6 | |||
| 7 | #[path = "../example_common.rs"] | ||
| 8 | mod example_common; | ||
| 9 | use cortex_m_rt::entry; | ||
| 10 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 11 | use embedded_hal::digital::v2::InputPin; | ||
| 12 | use example_common::*; | ||
| 13 | |||
| 14 | #[entry] | ||
| 15 | fn main() -> ! { | ||
| 16 | info!("Hello World!"); | ||
| 17 | |||
| 18 | let p = embassy_stm32::init(Default::default()); | ||
| 19 | |||
| 20 | let button = Input::new(p.PC13, Pull::Up); | ||
| 21 | |||
| 22 | loop { | ||
| 23 | if unwrap!(button.is_high()) { | ||
| 24 | info!("high"); | ||
| 25 | } else { | ||
| 26 | info!("low"); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
