stm32-rs/stm32wlxx-hal

Embedded rust HAL (hardware abstraction layer) for the STM32WL series

This is still in development, the code that exists today covers basic usage of:

stm32wlxx-hal

.

  • 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

[dependencies.stm32wlxx-hal]
version = "0.5.1"
features = [
    # use exactly one to match your target hardware
    "stm32wl5x_cm0p",
    "stm32wl5x_cm4",
    "stm32wle5",
    # optional: use the cortex-m-rt interrupt interface
    "rt",
    # optional: use defmt
    "defmt",
    # optional: enable conversions with embedded-time types
    "embedded-time",
    # optional: use the real time clock (RTC)
    "chrono",
]

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.

DEFMT_LOG=trace cargo run-ex gpio-blink

The on-target tests are also excellent reference material.

System Level Example

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. You must specify the target device as a feature.

cargo test --features stm32wl5x_cm4

On-Target Tests

See testsuite/README.md.

Reference Documentation

  • stm32wl5x reference manual
  • stm32wlex reference manual
  • stm32wl55cc datasheet
  • stm32wle5c8 datasheet
  • stm32wl55xx stm32wl54xx erratum
  • stm32wle5xx stm32wle4xx erratum
Issues

Collection of the latest Issues

justacec

justacec

question
Comment Icon3

I would like to use an LPTIM peripheral to track time. To do so I would like it to be in continuous mode so it just fires off the event and then reloads and keeps going. Unfortunately, the start function implementation for the LPTIM peripherals seems to set the mode to Single. How would I go about setting this up for continuous?

newAM

newAM

enhancement
Comment Icon0
  • Replace wall-of-text # Safety sections with enumerated check-lists of requirements.
  • Lots of duplicated code across testsuites (fixed in #82)
  • Provide a from_millis, from_nanos, from_secs ect. with subghz::Timeout
  • Normalize meta-access of peripherals for all peripherals (maybe trait these to enforce uniformity?)
    • pub unsafe fn steal() -> Self
    • fn mask_irq()
    • pub unsafe fn unmask_irq()
    • pub unsafe fn pulse_reset(rcc: &mut pac::RCC)
    • pub fn enable_clock(rcc: &mut pac::RCC)
    • pub unsafe fn disable_clock(rcc: &mut pac::RCC)
    • Normalize what new does with regards to clocks, resets, enables, and interrupts
Versions

Find the latest versions by id

v0.5.1 - May 14, 2022

Added

  • Added Rtc::alarm_{a,b} to get the alarm value.
  • Added impl From<Alarm> for chrono::NaiveTime.
  • Added RfSwitch::steal() to all BSPs.

v0.5.0 - May 08, 2022

Added

  • Added set_sleep_clock to GPIO ports to enable and disable clocks during sleep.
  • Added subghz::Timeout::saturating_add.
  • Added SubGhz.set_rtc_period and SubGhz.restart_rtc methods required to workaround an erratum with SubGhz.set_rx_duty_cycle.
  • Added SubGhz.new_no_reset and SubGhz.new_with_dma_no_reset to create a SubGhz without resetting the radio.

Changed

  • Changed minimum supported rust version from 1.57 to 1.60.

Fixed

  • Fixed a typo in the Exti::set_falling_trigger function name.
  • Fixed endianness in SubGhz.op_error.

v0.4.1 - Mar 22, 2022

Added

  • Implement embedded_hal::PwmPin for LpTim.

Changed

  • Inlined trivial Rng methods.

Fixed

  • Fixed UART clock_hz methods returning the wrong frequency.

v0.4.0 - Jan 08, 2022

Added

  • Added a is_pending method to the gpio::Exti trait.
  • Added alarm functionality to the RTC.
  • Added Rtc.is_wakeup_timer_en.
  • Added flash::flash_range.
  • Added Flash.program_bytes for safer flash programming.

Changed

  • Replaced Debug implementation with Display implementation for:
    • subghz::FskPacketStatus
    • subghz::LoRaPacketStatus
    • subghz::Stats
    • subghz::Status
  • Flash::standard_program_generic now checks for overflow.

Fixed

  • Fixed an off-by-one error in flash::Page::addr_range.

Removed

  • Removed util::reset_cycle_count; this functionality is now in cortex-m.

v0.3.0 - Dec 21, 2021

Added

  • Added info::Core::CT to get the CPU core at compile time.
  • Added info::Core::from_cpuid() to get the CPU core at runtime.
  • Added a flash module with erase and program functionality.
  • Added defmt::Format for all types declared in the BSPs.
  • Added info::uid::PTR.

Changed

  • Changed minimum rust version from 1.56 to 1.57 for const_panic.
  • info::UID64
    • Moved to info::Uid64::PTR.
    • Changed the type from *const u8 to *const u32.
  • Moved functions in info into the associated structs/enums.
    • Moved info::uid64 to info::Uid64::from_device.
    • Moved info::uid64_devnum to info::Uid64::read_devnum.
    • Moved info::package to info::Package::from_device.
    • Moved info::uid to info::Uid::from_device.
  • Added #[inline] to util::new_delay and util::reset_cycle_count.
  • Large dependencies are now optional.
    • embedded-time is now an optional feature.
      • Changed I2C::new to use u32 instead of embedded_time::Hertz.
    • chrono is now an optional feature.

v0.2.1 - Nov 20, 2021

Fixed

  • Fixed timeouts after calling SubGhz::set_sleep.

v0.2.0 - Nov 11, 2021

Added

  • Added two board support crates
    • nucleo-wl55jc-bsp
    • lora-e5-bsp

Changed

  • Crate ownership changed from tweedegolf to stm32-rs.
    • Thank you tweedegolf for the initial development effort!
  • Sweeping changes throughout the entire crate, nothing is the same.

Information - Updated Jul 08, 2022

Stars: 24
Forks: 8
Issues: 3

rust_embedded_starter

Boilerplate für Embedded Entwicklung mit Rust mit Flash und Debug automatik

rust_embedded_starter

Embedded rust HAL (hardware abstraction layer) for the STM32WL

This is a work in progress, it is unstable, incomplete, and (mostly) untested

Embedded rust HAL (hardware abstraction layer) for the STM32WL

Embedded Rust Template

This template is based on stm32f4xx-hal

Embedded Rust Template

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family

This crate is largely inspired by the awesome work done here:

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family

embedded-rust-H2AL

Hardware abstraction layer - abstraction layer

embedded-rust-H2AL

cargo-pio = Cargo + PlatformIO

Build Rust embedded projects with PlatformIO!

cargo-pio = Cargo + PlatformIO

Microchip MCP4725 DAC Driver for Rust Embedded HAL

This is a driver crate for embedded Rust

Microchip MCP4725 DAC Driver for Rust Embedded HAL

Rust Embedded HAL for Apache NuttX RTOS

This crate provides Rust Embedded HAL interfaces (GPIO, I2C, SPI and Delay) for Apache NuttX RTOS

Rust Embedded HAL for Apache NuttX RTOS

Using Rust to turn on an LED on the NUCLEO-F446RE by pressing a button

This example is mainly copied from the great Rust Embedded Embedded Rust: From Zero to Blinky

Using Rust to turn on an LED on the NUCLEO-F446RE by pressing a button
Facebook Instagram Twitter GitHub Dribbble
Privacy