Skip to content

Commit

Permalink
examples/stm32h7: switch to stm32_metapac
Browse files Browse the repository at this point in the history
Not building all the horrible svd2rust output knocks 26 seconds off the
build.
  • Loading branch information
cbiffle committed Apr 23, 2024
1 parent 6e8a805 commit 0f1cfc8
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 96 deletions.
18 changes: 5 additions & 13 deletions examples/stm32h7/minimal/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/stm32h7/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ futures = { version = "0.3.21", default-features = false, features = ["async-awa
lilos = { path = "../../../os" }
panic-halt = "0.2.0"

[dependencies.stm32h7]
[dependencies.stm32-metapac]
default-features = false
features = ["rt", "stm32h743"]
version = "0.14.0"
features = ["rt", "pac", "stm32h743zi"]
version = "15.0"

[[bin]]
name = "lilos-example-stm32h7-minimal"
Expand Down
11 changes: 6 additions & 5 deletions examples/stm32h7/minimal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
// because it isn't otherwise referenced in code!
extern crate panic_halt;

use stm32_metapac::{self as device, gpio::vals::Moder};

// How often our blinky task wakes up (1/2 our blink frequency).
const PERIOD: lilos::time::Millis = lilos::time::Millis(500);

#[cortex_m_rt::entry]
fn main() -> ! {
// Check out peripherals from the runtime.
let mut cp = cortex_m::Peripherals::take().unwrap();
let p = stm32h7::stm32h743::Peripherals::take().unwrap();

// Turn on GPIOB. Note the barrier: the H7 is a multi-issue CPU and if we
// want a specific ordering of memory operations, we have to ask for it.
p.RCC.ahb4enr.modify(|_, w| w.gpioben().enabled());
device::RCC.ahb4enr().modify(|w| w.set_gpioben(true));
cortex_m::asm::dmb();

// Configure our output pin, B0.
p.GPIOB.moder.modify(|_, w| w.moder0().output());
device::GPIOB.moder().modify(|w| w.set_moder(0, Moder::OUTPUT));

// Create a task to blink the LED. You could also write this as an `async
// fn` but we've inlined it as an `async` block for simplicity.
Expand All @@ -47,9 +48,9 @@ fn main() -> ! {
// Loop forever, blinking things. Note that this borrows the device
// peripherals `p` from the enclosing stack frame.
loop {
p.GPIOB.bsrr.write(|w| w.bs0().set_bit());
device::GPIOB.bsrr().write(|w| w.set_bs(0, true));
gate.next_time().await;
p.GPIOB.bsrr.write(|w| w.br0().set_bit());
device::GPIOB.bsrr().write(|w| w.set_br(0, true));
gate.next_time().await;
}
});
Expand Down
18 changes: 5 additions & 13 deletions examples/stm32h7/uart-echo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/stm32h7/uart-echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ futures = { version = "0.3.21", default-features = false, features = ["async-awa
lilos = { path = "../../../os" }
panic-halt = "0.2.0"

[dependencies.stm32h7]
[dependencies.stm32-metapac]
default-features = false
features = ["rt", "stm32h743"]
version = "0.14.0"
features = ["rt", "pac", "stm32h743zi"]
version = "15.0"

[[bin]]
name = "lilos-example-stm32h7-uart-echo"
Expand Down
Loading

0 comments on commit 0f1cfc8

Please sign in to comment.