onyx/src/main.rs

37 lines
1.2 KiB
Rust
Raw Normal View History

2020-01-25 20:49:11 +00:00
#![no_std]
#![no_main]
// pick a panicking behavior
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
2020-01-25 22:53:06 +00:00
// extern crate panic_abort; // requires nightly
// extern crate panic_itm; // logs messages over ITM; requires ITM support
// extern crate panic_semihosting; // logs messages to the host stderr; requires a debugger
2020-01-25 20:49:11 +00:00
2020-01-25 22:53:06 +00:00
use metro_m0 as hal;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;
2020-01-25 20:49:11 +00:00
#[entry]
fn main() -> ! {
2020-01-25 22:53:06 +00:00
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_external_32kosc(
peripherals.GCLK,
&mut peripherals.PM,
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
2020-01-26 00:14:40 +00:00
let mut red_led = pins.d13.into_push_pull_output(&mut pins.port);
2020-01-25 20:49:11 +00:00
2020-01-25 22:53:06 +00:00
let mut delay = Delay::new(core.SYST, &mut clocks);
2020-01-25 20:49:11 +00:00
loop {
2020-01-26 00:14:40 +00:00
delay.delay_ms(1000u16);
red_led.toggle();
2020-01-25 20:49:11 +00:00
}
2020-01-24 19:10:30 +00:00
}