Skip to content

Commit

Permalink
examples: update blinky example to use GPIO driver
Browse files Browse the repository at this point in the history
  • Loading branch information
astapleton committed Nov 15, 2024
1 parent 4e2bed9 commit ba74c1a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ fn main() -> ! {
let rcc = dp.RCC.constrain();
let ccdr = rcc.sys_ck(250.MHz()).freeze(pwrcfg, &dp.SBS);

ccdr.peripheral.GPIOA.enable();

dp.GPIOA.moder().write(|w| w.mode5().output()); // output
dp.GPIOA.pupdr().write(|w| w.pupd5().pull_up()); // pull-up
let gpioa = dp.GPIOA.split(ccdr.peripheral.GPIOA);
let mut led = gpioa.pa5.into_push_pull_output();

let mut delay = Delay::new(cp.SYST, &ccdr.clocks);
let duration = SecsDurationU32::secs(1).to_millis();

loop {
dp.GPIOA.odr().write(|w| w.od5().low());
delay.delay_ms(duration);
led.set_low();
log::info!("Off");
dp.GPIOA.odr().write(|w| w.od5().high());
delay.delay_ms(duration);
led.set_high();
log::info!("On");
delay.delay_ms(duration);
}
}

0 comments on commit ba74c1a

Please sign in to comment.