From ea54f19cfb3275e05f6b34eed6ae9c45262796f5 Mon Sep 17 00:00:00 2001 From: astapleton Date: Thu, 10 Oct 2024 11:04:53 -0700 Subject: [PATCH 1/2] examples: update blinky example to use GPIO driver --- examples/blinky.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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); } } From 769f23b635103604035a22d68e063dc6d5f6272f Mon Sep 17 00:00:00 2001 From: astapleton Date: Fri, 15 Nov 2024 11:06:05 -0800 Subject: [PATCH 2/2] Restrict blinky example to STM32H503 This blinky example was built for the NUCLEO-H503RB, so restrict it to the H503 for now. --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) 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"]