|0.9.0||Apr 4, 2021|
|0.8.3||Jun 11, 2020|
|0.8.2||May 29, 2020|
|0.7.0||Mar 7, 2020|
|0.2.5||Nov 17, 2018|
#229 in Embedded development
1,220 downloads per month
Used in less than 23 crates
stm32f4xx-hal contains a multi device hardware abstraction on top of the peripheral access API for the STMicro STM32F4 series microcontrollers. The selection of the MCU is done by feature gates, typically specified by board support crates. Currently supported configurations are:
The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model.
Collaboration on this crate is highly welcome as are pull requests!
Some of the implementation was shamelessly adapted from the stm32f103xx-hal crate by Jorge Aparicio.
Check if the BSP for your board exists in the
If it exists, the
stm32f4xx-hal crate should be already included, so you can
use the bsp as BSP for your project.
Otherwise, create a new Rust project as you usually do with
cargo init. The
"hello world" of embedded development is usually to blink a LED. The code to do
so is available in examples/delay-blinky.rs.
Copy that file to the
main.rs of your project.
You also need to add some dependencies to your
[dependencies] embedded-hal = "0.2" nb = "0.1.2" cortex-m = "0.6" cortex-m-rt = "0.6" # Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives panic-halt = "0.2" [dependencies.stm32f4xx-hal] version = "0.8" features = ["rt", "stm32f407"] # replace the model of your microcontroller here
We also need to tell Rust how to link our executable and how to lay out the
result in memory. To accomplish all this, copy .cargo/config
and memory.x from the
stm32f4xx-hal repository to your project and make sure the sizes match up with the datasheet. Also note that there might be different kinds of memory which are not equal; to be on the safe side only specify the size of the first block at the specified address.