Skip to content

Commit ba74c1a

Browse files
committed
examples: update blinky example to use GPIO driver
1 parent 4e2bed9 commit ba74c1a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

examples/blinky.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ fn main() -> ! {
2222
let rcc = dp.RCC.constrain();
2323
let ccdr = rcc.sys_ck(250.MHz()).freeze(pwrcfg, &dp.SBS);
2424

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

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

3331
loop {
34-
dp.GPIOA.odr().write(|w| w.od5().low());
35-
delay.delay_ms(duration);
32+
led.set_low();
3633
log::info!("Off");
37-
dp.GPIOA.odr().write(|w| w.od5().high());
3834
delay.delay_ms(duration);
35+
led.set_high();
3936
log::info!("On");
37+
delay.delay_ms(duration);
4038
}
4139
}

0 commit comments

Comments
 (0)