Skip to content

Commit

Permalink
Merge pull request #2 from libesz/fix-blinky
Browse files Browse the repository at this point in the history
align blinky example with new system init macro
  • Loading branch information
CorvusPrudens authored Dec 7, 2023
2 parents 5b9fed6 + 3a39b88 commit 7ae9d8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ panic-rtt-target = { version = "0.1.2", features = ["cortex-m"], optional = true
panic-semihosting = { version = "0.6", optional = true }
rtt-target = { version = "0.4.0", optional = true }
stm32-fmc = "0.3.0"
stm32h7xx-hal = { version = "0.14.0", features = ["stm32h750v","rt","fmc", "xspi", "sdmmc", "sdmmc-fatfs", "usb_hs"] }
stm32h7xx-hal = { version = "0.15.1", features = ["stm32h750v","rt","fmc", "xspi", "sdmmc", "sdmmc-fatfs", "usb_hs"] }

[features]
default = []
Expand Down
21 changes: 14 additions & 7 deletions examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
)]
mod app {
// Includes a panic handler and optional logging facilities
use libdaisy::logger;
use libdaisy::{gpio, system};
use libdaisy::{gpio, logger, system};
use log::info;
use stm32h7xx_hal::{stm32, time::MilliSeconds, timer::Timer};

Expand All @@ -25,18 +24,26 @@ mod app {
#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
logger::init();
let mut system = system::System::init(ctx.core, ctx.device);
let mut core = ctx.core;
let device = ctx.device;
let ccdr = system::System::init_clocks(device.PWR, device.RCC, &device.SYSCFG);
let system = libdaisy::system_init!(core, device, ccdr);
info!("Startup done!");
let mut timer2 = stm32h7xx_hal::timer::TimerExt::timer(
device.TIM2,
MilliSeconds::from_ticks(100).into_rate(),
ccdr.peripheral.TIM2,
&ccdr.clocks,
);
timer2.listen(stm32h7xx_hal::timer::Event::TimeOut);

system
.timer2
.set_freq(MilliSeconds::from_ticks(500).into_rate());
timer2.set_freq(MilliSeconds::from_ticks(500).into_rate());

(
Shared {},
Local {
seed_led: system.gpio.led,
timer2: system.timer2,
timer2,
},
init::Monotonics(),
)
Expand Down

0 comments on commit 7ae9d8f

Please sign in to comment.