#![no_std]
#![no_main]
use bsp::hal;
use feather_m4 as bsp;
#[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::ehal::digital::OutputPin;
use hal::nb;
use hal::pac::Peripherals;
use hal::time::Hertz;
use hal::timer_traits::InterruptDrivenTimer;
use hal::timer::TimerCounter;
#[entry]
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let pins = bsp::Pins::new(peripherals.port);
let mut red_led = pins.d13.into_push_pull_output();
let gclk0 = clocks.gclk0();
let timer_clock = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc2_(&timer_clock, peripherals.tc2, &mut peripherals.mclk);
timer.start(Hertz::Hz(50u32).into_duration());
loop {
red_led.set_high().unwrap();
nb::block!(timer.wait()).ok();
red_led.set_low().unwrap();
nb::block!(timer.wait()).ok();
}
}