]> patrickod personal git archive - tincan.git/blobdiff - rs-lorachat/src/main.rs
wip on getting this thing to do USB
[tincan.git] / rs-lorachat / src / main.rs
index e7a11a969c037e00a796aafeff6258501ec15e9a..92e4f458b9cc0de51cf81de13ee84dae9f7d6927 100644 (file)
@@ -1,3 +1,46 @@
-fn main() {
-    println!("Hello, world!");
+#![no_std]
+#![no_main]
+
+use panic_halt as _;
+
+use bsp::hal;
+use feather_m0 as bsp;
+
+use bsp::entry;
+use hal::clock::{GenericClockController};
+use hal::delay::Delay;
+use hal::pac::{CorePeripherals, Peripherals};
+use hal::prelude::*;
+
+#[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 delay = Delay::new(core.SYST, &mut clocks);
+    let mut red_led = pins.d13.into_push_pull_output();
+
+
+    red_led.set_high().unwrap();
+    delay.delay_ms(500_u32);
+    red_led.set_low().unwrap();
+    delay.delay_ms(500_u32);
+    red_led.set_high().unwrap();
+
+    red_led.set_low().unwrap();
+    delay.delay_ms(500_u32);
+
+
+    loop {
+        delay.delay_ms(1_000_u32);
+        red_led.set_high().unwrap();
+        delay.delay_ms(1_000_u32);
+        red_led.set_low().unwrap();
+    }
 }