2021-04-09 21:37:22 +00:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
2021-07-21 21:12:36 +00:00
|
|
|
use cortex_m_rt::entry;
|
2021-06-25 20:32:24 +00:00
|
|
|
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
2021-04-09 21:37:22 +00:00
|
|
|
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
|
|
|
use example_common::*;
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
info!("Hello World!");
|
|
|
|
|
2021-05-01 01:07:17 +00:00
|
|
|
let p = embassy_stm32::init(Default::default());
|
|
|
|
|
2021-04-09 21:37:22 +00:00
|
|
|
let button = Input::new(p.PC13, Pull::Down);
|
2021-06-25 20:32:24 +00:00
|
|
|
let mut led1 = Output::new(p.PB0, Level::High, Speed::Low);
|
|
|
|
let _led2 = Output::new(p.PB7, Level::High, Speed::Low);
|
|
|
|
let mut led3 = Output::new(p.PB14, Level::High, Speed::Low);
|
2021-04-09 21:37:22 +00:00
|
|
|
|
|
|
|
loop {
|
2021-07-31 15:51:40 +00:00
|
|
|
if unwrap!(button.is_high()) {
|
2021-04-09 21:37:22 +00:00
|
|
|
info!("high");
|
2021-07-31 15:51:40 +00:00
|
|
|
unwrap!(led1.set_high());
|
|
|
|
unwrap!(led3.set_low());
|
2021-04-09 21:37:22 +00:00
|
|
|
} else {
|
|
|
|
info!("low");
|
2021-07-31 15:51:40 +00:00
|
|
|
unwrap!(led1.set_low());
|
|
|
|
unwrap!(led3.set_high());
|
2021-04-09 21:37:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|