- Notifications
You must be signed in to change notification settings - Fork213
A Rust embedded-hal HAL for all MCUs in the STM32 F4 family
License
stm32-rs/stm32f4xx-hal
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
stm32f4xx-hal contains a multi device hardware abstraction on top of theperipheral access API for the STMicro STM32F4 series microcontrollers. Theselection of the MCU is done by feature gates, typically specified by boardsupport crates. Currently supported configurations are:
|
|
|
The idea behind this crate is to gloss over the slight differences in thevarious peripherals available on those MCUs so a HAL can be written for allchips in that same family without having to cut and paste crates for everysingle model.
rtic1
— supportRTICv1 framework.rtic2
— supportRTICv2 framework (incompatible withrtic1
, require nightly compiller).defmt
— implementation ofdefmt::Format
for public enums and structures. Seedefmt.can
— bxCAN peripheral support. Seebxcan.i2s
— I2S peripheral support. Seestm32_i2s_v12x.usb_fs
orusb_hs
— USB OTG FS/HS peripheral support. Seesynopsys-usb-otg.fsmc_lcd
— LCD support via FMC/FSMC peripheral. Seedisplay-interface.sdio-host
— SDIO peripheral support. Seesdio-host.dsihost
— DSI host support. Seeembedded-display-controller.
Collaboration on this crate is highly welcome as are pull requests!
This crate relies on Adam Greigs fantasticstm32f4 crate to provideappropriate register definitions and implements a partial set of theembedded-hal traits.
Some of the implementation was shamelessly adapted from thestm32f1xx-halcrate originally started by Jorge Aparicio.
Check if the BSP for your board exists in thestm32-rs page.If it exists, thestm32f4xx-hal
crate should be already included, so you canuse the bsp as BSP for your project.
Otherwise, create a new Rust project as you usually do withcargo init
. The"hello world" of embedded development is usually to blink a LED. The code to doso is available inexamples/delay-syst-blinky.rs.Copy that file to themain.rs
of your project.
You also need to add some dependencies to yourCargo.toml
:
[dependencies]embedded-hal ="0.2"nb ="1"cortex-m ="0.7"cortex-m-rt ="0.7"# Panic behaviour, see https://crates.io/keywords/panic-impl for alternativespanic-halt ="0.2"[dependencies.stm32f4xx-hal]version ="0.22.1"features = ["stm32f407"]# replace the model of your microcontroller here# and add other required features
We also need to tell Rust how to link our executable and how to lay out theresult in memory. To accomplish all this, copy.cargo/configandmemory.x from thestm32f4xx-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.
To create empty project faster you could usecargo generate
command. Seestm32-template.
$ cargo generate --git https://github.com/burrbull/stm32-template/
Note that you need to know your chip full name.
About
A Rust embedded-hal HAL for all MCUs in the STM32 F4 family
Resources
License
Uh oh!
There was an error while loading.Please reload this page.