X-Git-Url: https://git.patrickod.com/tor.noisebridge.net/plain/.gitignore?a=blobdiff_plain;f=rs-lorachat%2Fsrc%2Fmain.rs;h=92e4f458b9cc0de51cf81de13ee84dae9f7d6927;hb=726df4b11c6b68e05815efd162506272913f715f;hp=e7a11a969c037e00a796aafeff6258501ec15e9a;hpb=882e8be16da3fe125ad4d7947f8fb0d81276f2cb;p=tincan.git diff --git a/rs-lorachat/src/main.rs b/rs-lorachat/src/main.rs index e7a11a9..92e4f45 100644 --- a/rs-lorachat/src/main.rs +++ b/rs-lorachat/src/main.rs @@ -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(); + } }