#![no_std] #![no_main] // Halt on all panics. If breaking on a panic is required use `rust_begin_unwind`. #[allow(unused_imports)] use panic_halt; use cortex_m_rt::entry; use stm32l4xx_hal::{prelude::*, flash::FlashExt, gpio::GpioExt, pac, pwr::PwrExt, rcc::RccExt, time::Hertz, delay::Delay}; #[entry] fn main() -> ! { let dp = pac::Peripherals::take().unwrap(); let cp = cortex_m::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1); // Ok for now, but ideally actually think about what this does (especially when we have tim). let clocks = rcc .cfgr .hclk(Hertz::MHz(8)) .freeze(&mut flash.acr, &mut pwr); let mut gpioa = dp.GPIOA.split(&mut rcc.ahb2); let mut led_pin = gpioa .pa0 .into_push_pull_output(&mut gpioa.moder, &mut gpioa.otyper); let mut timer = Delay::new(cp.SYST, clocks); loop { timer.delay_ms(1000_u32); led_pin.set_high(); timer.delay_ms(1000_u32); led_pin.set_low(); } }