added watchdog example
This commit is contained in:
parent
0db3837dcc
commit
395b5fed64
1 changed files with 25 additions and 0 deletions
25
examples/stm32f0/src/bin/wdg.rs
Normal file
25
examples/stm32f0/src/bin/wdg.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::wdg::IndependentWatchdog;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
// Initialize and create handle for devicer peripherals
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
// Configure the independent watchdog timer
|
||||
let mut wdg = IndependentWatchdog::new(p.IWDG, 20_000_00);
|
||||
|
||||
info!("Watchdog start");
|
||||
unsafe { wdg.unleash() };
|
||||
|
||||
loop {
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
unsafe { wdg.pet() };
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue