Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jul 14, 2021
1 parent 85c7c1e commit 0a376b5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/gpio_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
#![no_std]
#![no_main]
use cortex_m_rt::entry;
use embedded_hal::digital::v2::InputPin;
use panic_halt as _;
use stm32f1xx_hal::{delay::Delay, pac, prelude::*};
use stm32f1xx_hal::{delay::Delay, gpio::PinState, pac, prelude::*};

#[entry]
fn main() -> ! {
Expand All @@ -38,10 +37,10 @@ fn main() -> ! {
// red_led and green_led
let mut red_led = gpioa
.pa8
.into_push_pull_output_with_state(&mut gpioa.crh, stm32f1xx_hal::gpio::State::High);
.into_push_pull_output_with_state(&mut gpioa.crh, PinState::High);
let mut green_led = gpiod
.pd2
.into_push_pull_output_with_state(&mut gpiod.crl, stm32f1xx_hal::gpio::State::High);
.into_push_pull_output_with_state(&mut gpiod.crl, PinState::High);

let mut afio = dp.AFIO.constrain(&mut rcc.apb2);
let (gpioa_pa15, _gpiob_pb3, _gpiob_pb4) =
Expand All @@ -56,13 +55,13 @@ fn main() -> ! {
let mut key_up: bool = true;
let mut delay = Delay::new(cp.SYST, clock);
loop {
let key_result = (key_0.is_low().unwrap(), key_1.is_low().unwrap());
let key_result = (key_0.is_low(), key_1.is_low());
if key_up && (key_result.0 || key_result.1) {
key_up = false;
delay.delay_ms(10u8);
match key_result {
(x, _) if x == true => red_led.toggle().unwrap(),
(_, y) if y == true => green_led.toggle().unwrap(),
(x, _) if x == true => red_led.toggle(),
(_, y) if y == true => green_led.toggle(),
(_, _) => (),
}
} else if !key_result.0 && !key_result.1 {
Expand Down

0 comments on commit 0a376b5

Please sign in to comment.