49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use atsame54_xpro as bsp;
|
|
use bsp::hal;
|
|
|
|
#[cfg(not(feature = "use_semihosting"))]
|
|
use panic_halt as _;
|
|
#[cfg(feature = "use_semihosting")]
|
|
use panic_semihosting as _;
|
|
|
|
use bsp::entry;
|
|
use hal::clock::GenericClockController;
|
|
use hal::delay::Delay;
|
|
use hal::pac::{CorePeripherals, Peripherals};
|
|
use hal::prelude::*;
|
|
|
|
use hal::watchdog::{Watchdog, WatchdogTimeout};
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let mut peripherals = Peripherals::take().unwrap();
|
|
let core = CorePeripherals::take().unwrap();
|
|
let mut clocks = GenericClockController::with_internal_32kosc(
|
|
peripherals.GCLK,
|
|
&mut peripherals.MCLK,
|
|
&mut peripherals.OSC32KCTRL,
|
|
&mut peripherals.OSCCTRL,
|
|
&mut peripherals.NVMCTRL,
|
|
);
|
|
let mut delay = Delay::new(core.SYST, &mut clocks);
|
|
delay.delay_ms(400u16);
|
|
|
|
let mut pins = bsp::Pins::new(peripherals.PORT);
|
|
let mut led = pins.led.into_open_drain_output(&mut pins.port);
|
|
|
|
let mut wdt = Watchdog::new(peripherals.WDT);
|
|
wdt.start(WatchdogTimeout::Cycles256 as u8);
|
|
|
|
loop {
|
|
delay.delay_ms(200u8);
|
|
wdt.feed();
|
|
led.set_high().unwrap();
|
|
delay.delay_ms(200u8);
|
|
wdt.feed();
|
|
led.set_low().unwrap();
|
|
}
|
|
}
|