This example showcases how the vl53l1x-uld
crate for the VL53L1X TOF can be used on an STM32F4 chip.
The example logs messages using defmt
.
The example has been tested on a ST Nucleo-F401RE development
board but should work on any STM32F4xx family microcontroller as long as the TOF is connected via I2C1 on pins PB8
(SCL) and PB9
(SDA)
and the interrupt is connected on PA0
, or the code is adapted accordingly.
- Install Rust
- Optional: ensure that the rust toolchain is up-to-date:
rustup update
- Install
probe-run
:cargo install probe-run
- Install
flip-link
:cargo install flip-link
- Note:
flip-link
is not strictly necessary for this example (it doesn't need stack protection), however it can be considered best practices to include it.
- Note:
- Install the cross-compile target:
rustup target add thumbv7em-none-eabihf
- Install the STLink drivers
- Connect the board via USB
- Optional: change your targeted platform in
Cargo.toml
and.cargo/config
(it defaults to STM32F401RE) - Run
cargo run
- Enjoy your running program :)