From ba74c1ac1205f298d1325e16de292d804fb81108 Mon Sep 17 00:00:00 2001 From: astapleton Date: Thu, 10 Oct 2024 11:04:53 -0700 Subject: [PATCH] examples: update blinky example to use GPIO driver --- examples/blinky.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/blinky.rs b/examples/blinky.rs index b3110a1..8afa501 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -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); } }