From 7a7d5f1a487c371f761b180a1e79c0f8d519db12 Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Sun, 27 Oct 2019 00:17:49 -0400 Subject: [PATCH] Save a working blinkenlight as a test --- hello_gradient/Cargo.lock | 2 ++ hello_gradient/Cargo.toml | 2 ++ hello_gradient/src/bin/sanity_test.rs | 32 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 hello_gradient/src/bin/sanity_test.rs diff --git a/hello_gradient/Cargo.lock b/hello_gradient/Cargo.lock index b44b77c..3e2a959 100644 --- a/hello_gradient/Cargo.lock +++ b/hello_gradient/Cargo.lock @@ -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]] diff --git a/hello_gradient/Cargo.toml b/hello_gradient/Cargo.toml index bbd0d1f..31589ad 100644 --- a/hello_gradient/Cargo.toml +++ b/hello_gradient/Cargo.toml @@ -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" diff --git a/hello_gradient/src/bin/sanity_test.rs b/hello_gradient/src/bin/sanity_test.rs new file mode 100644 index 0000000..b47580e --- /dev/null +++ b/hello_gradient/src/bin/sanity_test.rs @@ -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(); + } +}