diff options
| author | @imrank03 <[email protected]> | 2022-12-21 11:55:09 +0530 |
|---|---|---|
| committer | @imrank03 <[email protected]> | 2022-12-21 11:55:09 +0530 |
| commit | 395b5fed6497e901c4275f90afbffaf069931f84 (patch) | |
| tree | 69ddbb8ed265635456931cb34e49e35bc6f8cad8 /examples | |
| parent | 0db3837dccb9c0ee2fdb236937a6a20b63fb89f8 (diff) | |
added watchdog example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f0/src/bin/wdg.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/stm32f0/src/bin/wdg.rs b/examples/stm32f0/src/bin/wdg.rs new file mode 100644 index 000000000..80e76f901 --- /dev/null +++ b/examples/stm32f0/src/bin/wdg.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::wdg::IndependentWatchdog; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | // Initialize and create handle for devicer peripherals | ||
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | // Configure the independent watchdog timer | ||
| 16 | let mut wdg = IndependentWatchdog::new(p.IWDG, 20_000_00); | ||
| 17 | |||
| 18 | info!("Watchdog start"); | ||
| 19 | unsafe { wdg.unleash() }; | ||
| 20 | |||
| 21 | loop { | ||
| 22 | Timer::after(Duration::from_secs(1)).await; | ||
| 23 | unsafe { wdg.pet() }; | ||
| 24 | } | ||
| 25 | } | ||
