Blinky (in theory)...
This commit is contained in:
parent
603d0be507
commit
a433b88319
1 changed files with 24 additions and 2 deletions
26
src/main.rs
26
src/main.rs
|
|
@ -6,12 +6,34 @@
|
||||||
use panic_halt;
|
use panic_halt;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use stm32l4xx_hal::{pac, rcc::RccExt};
|
use stm32l4xx_hal::{prelude::*, flash::FlashExt, gpio::GpioExt, pac, pwr::PwrExt, rcc::RccExt, time::Hertz, delay::Delay};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let dp = pac::Peripherals::take().unwrap();
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
let cp = cortex_m::Peripherals::take().unwrap();
|
let cp = cortex_m::Peripherals::take().unwrap();
|
||||||
|
|
||||||
loop {}
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue