aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatous Hybl <[email protected]>2022-11-09 14:10:46 +0100
committerMatous Hybl <[email protected]>2022-11-10 15:56:28 +0100
commitcbc97758e391d981d497bf37fe63b5a35913c115 (patch)
tree842e130fe0cc9ba25a5630547b6de25da913f104 /examples
parent059610a8de49ff2d38311f343d3d1a6f8d90a720 (diff)
stm32: Fix watchdog division by zero for 256 prescaler, add watchdog example for H7
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/wdg.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/stm32h7/src/bin/wdg.rs b/examples/stm32h7/src/bin/wdg.rs
new file mode 100644
index 000000000..2b0301aad
--- /dev/null
+++ b/examples/stm32h7/src/bin/wdg.rs
@@ -0,0 +1,24 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::wdg::IndependentWatchdog;
8use embassy_time::{Duration, Timer};
9use {defmt_rtt as _, panic_probe as _};
10
11#[embassy_executor::main]
12async fn main(_spawner: Spawner) {
13 let p = embassy_stm32::init(Default::default());
14 info!("Hello World!");
15
16 let mut wdg = IndependentWatchdog::new(p.IWDG1, 20_000_000);
17
18 unsafe { wdg.unleash() };
19
20 loop {
21 Timer::after(Duration::from_secs(1)).await;
22 unsafe { wdg.pet() };
23 }
24}