Save a working blinkenlight as a test

This commit is contained in:
Tangent 128 2019-10-27 00:17:49 -04:00
parent 8171494cce
commit 7a7d5f1a48
3 changed files with 36 additions and 0 deletions

View File

@ -108,8 +108,10 @@ dependencies = [
name = "hello_gradient"
version = "0.1.0"
dependencies = [
"itsybitsy_m0 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itsybitsy_m0_lights 0.1.0",
"lights 0.1.0",
"panic-halt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View File

@ -10,5 +10,7 @@ codegen-units = 1
debug = true
[dependencies]
itsybitsy_m0 = "0.5"
lights = { path = "../lights" }
lights_hal = { path = "../itsybitsy_m0_lights", package = "itsybitsy_m0_lights" }
panic-halt = "0.2"

View File

@ -0,0 +1,32 @@
#![no_std]
#![no_main]
extern crate itsybitsy_m0 as hal;
extern crate panic_halt;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::prelude::*;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
#[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.PM,
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut red_led = pins.d13.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);
loop {
delay.delay_ms(200u8);
red_led.set_high().unwrap();
delay.delay_ms(200u8);
red_led.set_low().unwrap();
}
}