mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
Add led to example to demonstrate revert state detection
This commit is contained in:
parent
ab0a227e4c
commit
df23a77bfc
@ -8,6 +8,7 @@ use embassy_executor::Spawner;
|
|||||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||||
use embassy_nrf::nvmc::Nvmc;
|
use embassy_nrf::nvmc::Nvmc;
|
||||||
use embassy_nrf::wdt::{self, Watchdog};
|
use embassy_nrf::wdt::{self, Watchdog};
|
||||||
|
use embassy_boot::State;
|
||||||
use embassy_sync::mutex::Mutex;
|
use embassy_sync::mutex::Mutex;
|
||||||
use panic_reset as _;
|
use panic_reset as _;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
let mut button = Input::new(p.P0_11, Pull::Up);
|
let mut button = Input::new(p.P0_11, Pull::Up);
|
||||||
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
|
||||||
|
let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard);
|
||||||
|
|
||||||
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
|
||||||
//let mut button = Input::new(p.P1_02, Pull::Up);
|
//let mut button = Input::new(p.P1_02, Pull::Up);
|
||||||
@ -53,6 +55,13 @@ async fn main(_spawner: Spawner) {
|
|||||||
let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc);
|
let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc);
|
||||||
let mut magic = [0; 4];
|
let mut magic = [0; 4];
|
||||||
let mut updater = FirmwareUpdater::new(config, &mut magic);
|
let mut updater = FirmwareUpdater::new(config, &mut magic);
|
||||||
|
let state = updater.get_state().await.unwrap();
|
||||||
|
if state == State::Revert {
|
||||||
|
led_reverted.set_low();
|
||||||
|
} else {
|
||||||
|
led_reverted.set_high();
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
led.set_low();
|
led.set_low();
|
||||||
button.wait_for_any_edge().await;
|
button.wait_for_any_edge().await;
|
||||||
|
Loading…
Reference in New Issue
Block a user