diff --git a/Cargo.toml b/Cargo.toml index 05c2bea..11a81af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,3 +69,7 @@ codegen-units = 1 # better optimizations debug = true # symbols are nice and they don't increase the size in flash lto = true # better optimizations opt-level = "s" # optimize for binary size + +[[example]] +name = "blinky" +required-features = ["stm32h503"] diff --git a/examples/blinky.rs b/examples/blinky.rs index b3110a1..142f462 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -1,3 +1,4 @@ +#![deny(warnings)] #![no_main] #![no_std] @@ -6,7 +7,7 @@ mod utilities; use cortex_m_rt::entry; use embedded_hal::delay::DelayNs; use fugit::SecsDurationU32; -use stm32h5xx_hal::{delay::Delay, pac, prelude::*, rcc::ResetEnable}; +use stm32h5xx_hal::{delay::Delay, pac, prelude::*}; #[entry] fn main() -> ! { @@ -22,20 +23,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); } }