2026-06-01 13:40:49 -04:00
|
|
|
#![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;
|
2026-06-01 18:19:56 -04:00
|
|
|
use stm32l4xx_hal::{
|
|
|
|
|
delay::Delay, flash::FlashExt, gpio::GpioExt, pac, prelude::*, pwr::PwrExt, rcc::RccExt,
|
|
|
|
|
time::Hertz,
|
|
|
|
|
};
|
2026-06-01 13:40:49 -04:00
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
|
fn main() -> ! {
|
|
|
|
|
let dp = pac::Peripherals::take().unwrap();
|
|
|
|
|
let cp = cortex_m::Peripherals::take().unwrap();
|
|
|
|
|
|
2026-06-01 14:21:38 -04:00
|
|
|
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
|
2026-06-01 18:19:56 -04:00
|
|
|
.sysclk(Hertz::MHz(64))
|
|
|
|
|
.pclk1(Hertz::MHz(32))
|
2026-06-01 14:21:38 -04:00
|
|
|
.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();
|
|
|
|
|
}
|
2026-06-01 13:40:49 -04:00
|
|
|
}
|