cleanup rp examples

This commit is contained in:
Dario Nieuwenhuis 2021-04-05 22:36:35 +02:00
parent 48ba8d1dae
commit c6738b4f87
2 changed files with 10 additions and 5 deletions

View File

@ -13,12 +13,13 @@ use defmt::*;
use embassy::executor::Spawner; use embassy::executor::Spawner;
use embassy_rp::{gpio, Peripherals}; use embassy_rp::{gpio, Peripherals};
use embedded_hal::digital::v2::OutputPin; use embedded_hal::digital::v2::OutputPin;
use gpio::{Level, Output};
#[embassy::main] #[embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = unwrap!(Peripherals::take()); let p = unwrap!(Peripherals::take());
let mut led = gpio::Output::new(p.PIN_25, gpio::Level::Low); let mut led = Output::new(p.PIN_25, Level::Low);
loop { loop {
info!("led on!"); info!("led on!");

View File

@ -11,18 +11,22 @@ mod example_common;
use defmt::*; use defmt::*;
use embassy::executor::Spawner; use embassy::executor::Spawner;
use embassy_rp::gpio::{Input, Pull}; use embassy_rp::gpio::{Input, Level, Output, Pull};
use embassy_rp::Peripherals; use embassy_rp::Peripherals;
use embedded_hal::digital::v2::InputPin; use embedded_hal::digital::v2::{InputPin, OutputPin};
#[embassy::main] #[embassy::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = unwrap!(Peripherals::take()); let p = unwrap!(Peripherals::take());
let button = Input::new(p.PIN_28, Pull::Up); let button = Input::new(p.PIN_28, Pull::Up);
let mut led = Output::new(p.PIN_25, Level::Low);
loop { loop {
info!("high? {=bool}", button.is_high().unwrap()); if button.is_high().unwrap() {
cortex_m::asm::delay(1_000_000); led.set_high().unwrap();
} else {
led.set_low().unwrap();
}
} }
} }