stm32wl-hal
Embedded rust HAL (hardware abstraction layer) for the STM32WL.
⚠️ This is a work in progress, it is unstable (lots of API changes) and incomplete.
The code that exists today covers basic usage of:
- SubGHz LoRa TX + RX
- SubGHz (G)FSK TX + RX
- SPI
- GPIO
- UART
- I2C
- Low-power timers
- ADC
- DAC
- PKA ECDSA signing + verification
- Secure random number generation
- AES ECB encryption + decryption
- RTC date and time
Usage
See hal/README.md.
Examples
All examples run on the NUCLEO-WL55JC2.
Examples are located in the examples
crate.
The arguments got long for this, so a run-ex
cargo alias is provided.
The testsuites are also excellent reference material, they are automatically tested for every commit and are guaranteed to work.
The testsuites and examples are a good starting point, but they demonstrate features independent of each-other. A system-level example using multiple features simultaneously is provided in a separate repo: stm32wl-lightswitch-demo
Unit Tests
Off-target unit tests use the built-in cargo framework. The only abnormal part of this is that you must specify the target device as a feature.
On-Target Tests
Workspaces with testsuite
in the name denote an on-target test.
On-target tests use the NUCLEO-WL55JC2, you can find a place purchase this here.
On-Target Quickstart
The on-target tests use defmt-test.
-
cargo install --git https://github.com/newAM/probe-run.git
(probe-run, newAM/probe-run)- Note: My fork contains unreleased fixes for the stm32wl, see #74 for details.
-
rustup target add --toolchain stable thumbv7m-none-eabi
(rustup) - (Linux users only) udev rules are available at newAM/nucleo-wl55jc2-rs
- Connect the nucleo board to your PC via USB.
-
cargo test -p pka-testsuite --target thumbv7em-none-eabi
Sample output:
SubGhz Tests
The subghz on-target tests require two nucleo boards, one for transmitting,
and one for receiving. Run the subghz-testsuite
twice on two different boards.
Assuming both boards are connected to the same system you will have to pass a specific probe to each.
Reference Documentation
- stm32wl5x reference manual
- stm32wlex reference manual
- stm32wle5c8 datasheet
- stm32wl55cc datasheet
- stm32wl55xx stm32wl54xx erratum
- stm32wle5xx stm32wle4xx erratum