Add led to example to demonstrate revert state detection

This commit is contained in:
Ulf Lilleengen 2024-09-19 09:15:35 +02:00
parent ab0a227e4c
commit df23a77bfc

View File

@ -8,6 +8,7 @@ use embassy_executor::Spawner;
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
use embassy_nrf::nvmc::Nvmc;
use embassy_nrf::wdt::{self, Watchdog};
use embassy_boot::State;
use embassy_sync::mutex::Mutex;
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 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 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 mut magic = [0; 4];
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 {
led.set_low();
button.wait_for_any_edge().await;