Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
15 changes: 7 additions & 8 deletions examples/blinky.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(warnings)]
#![no_main]
#![no_std]

Expand All @@ -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() -> ! {
Expand All @@ -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);
}
}