Skip to content

Commit

Permalink
examples: uno: Add watchdog example
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahix committed Jul 11, 2021
1 parent 33da1d1 commit 6444d05
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/arduino-uno/src/bin/uno-watchdog.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#![no_std]
#![no_main]

use arduino_hal::prelude::*;
use panic_halt as _;
use arduino_hal::hal::wdt;

#[arduino_hal::entry]
fn main() -> ! {
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);

let mut led = pins.d13.into_output();
led.set_high();

for i in 0..20 {
led.toggle();
arduino_hal::delay_ms(100);
}

let mut watchdog = wdt::Wdt::new(dp.WDT, &dp.CPU.mcusr);
watchdog.start(wdt::Timeout::Ms2000).unwrap();

loop {
led.toggle();
arduino_hal::delay_ms(1000);
watchdog.feed();
}
}

0 comments on commit 6444d05

Please sign in to comment.