#![no_std]
#![no_main]
#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;
use bsp::hal;
use bsp::pac;
use feather_m0 as bsp;
use bsp::{entry, pin_alias};
use hal::clock::GenericClockController;
use hal::ehal::digital::OutputPin;
use hal::nb;
use hal::time::Hertz;
use hal::timer::TimerCounter;
use hal::timer_traits::InterruptDrivenTimer;
use pac::Peripherals;
#[entry]
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.gclk,
&mut peripherals.pm,
&mut peripherals.sysctrl,
&mut peripherals.nvmctrl,
);
let pins = bsp::Pins::new(peripherals.port);
let mut red_led: bsp::RedLed = pin_alias!(pins.red_led).into();
let gclk0 = clocks.gclk0();
let tc45 = &clocks.tc4_tc5(&gclk0).unwrap();
let mut timer = TimerCounter::tc4_(tc45, peripherals.tc4, &mut peripherals.pm);
timer.start(Hertz::Hz(5).into_duration());
loop {
nb::block!(timer.wait()).unwrap();
red_led.set_high().unwrap();
nb::block!(timer.wait()).unwrap();
red_led.set_low().unwrap();
}
}