]> patrickod personal git archive - tincan.git/commitdiff
working blinky
authorAndy Isaacson <adi@hexapodia.org>
Sat, 10 Jul 2021 21:49:16 +0000 (14:49 -0700)
committerAndy Isaacson <adi@hexapodia.org>
Sat, 10 Jul 2021 21:49:16 +0000 (14:49 -0700)
rs-lorachat/Cargo.toml
rs-lorachat/src/main.rs

index 85fa0081d6fcf1a1e63fedc35f1913760b9a376d..f64427cb35884f9fb8e1329a67b20bf22060a4f5 100644 (file)
@@ -6,3 +6,21 @@ edition = "2018"
 
 [dependencies]
 feather_m0 = { git = "https://github.com/atsamd-rs/atsamd" }
+
+
+[dependencies.cortex-m-rt]
+version = "0.6.12"
+optional = true
+
+[dependencies.atsamd-hal]
+version = "0.12"
+default-features = false
+
+[dependencies.panic-halt]
+version = "0.2"
+optional = true
+
+[features]
+default = ["rt", "atsamd-hal/samd21g", "panic_halt"]
+rt = ["cortex-m-rt", "atsamd-hal/samd21g-rt"]
+panic_halt = ["panic-halt"]
index e7a11a969c037e00a796aafeff6258501ec15e9a..a0395d5c7edb6aee6774e607da205cd9dfc6c22b 100644 (file)
@@ -1,3 +1,42 @@
-fn main() {
-    println!("Hello, world!");
+#![no_std]
+#![no_main]
+
+use panic_halt as _;
+
+use bsp::hal;
+use bsp::pac;
+use feather_m0 as bsp;
+
+use bsp::entry;
+use hal::clock::GenericClockController;
+use hal::delay::Delay;
+use hal::prelude::*;
+use pac::{CorePeripherals, Peripherals};
+
+#[entry]
+fn main() -> ! {
+    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 pins = bsp::Pins::new(peripherals.PORT);
+    let mut red_led: bsp::RedLed = pins.d13.into();
+    let mut delay = Delay::new(core.SYST, &mut clocks);
+    loop {
+        delay.delay_ms(250u8);
+        delay.delay_ms(250u8);
+        delay.delay_ms(250u8);
+        delay.delay_ms(250u8);
+        red_led.set_high().unwrap();
+        delay.delay_ms(100u8);
+        red_led.set_low().unwrap();
+        delay.delay_ms(100u8);
+        red_led.set_high().unwrap();
+        delay.delay_ms(100u8);
+        red_led.set_low().unwrap();
+    }
 }