Docs.rs
  • embassy-stm32-0.1.0
    • embassy-stm32 0.1.0
    • Docs.rs crate page
    • MIT OR Apache-2.0
    • Links
    • Documentation
    • Repository
    • crates.io
    • Source
    • Owners
    • Dirbaio
    • github:embassy-rs:crates-io
    • Dependencies
      • bit_field ^0.10.2 normal
      • bxcan ^0.7.0 normal
      • cfg-if ^1.0.0 normal
      • chrono ^0.4 normal
      • cortex-m ^0.7.6 normal
      • cortex-m-rt >=0.6.15, <0.8 normal
      • critical-section ^1.1 normal
      • defmt ^0.3 normal
      • document-features ^0.2.7 normal
      • embassy-embedded-hal ^0.1.0 normal
      • embassy-executor ^0.5.0 normal
      • embassy-futures ^0.1.0 normal
      • embassy-hal-internal ^0.1.0 normal
      • embassy-net-driver ^0.2.0 normal
      • embassy-sync ^0.5.0 normal
      • embassy-time ^0.3.0 normal
      • embassy-time-driver ^0.1 normal
      • embassy-usb-driver ^0.1.0 normal
      • embedded-hal ^0.2.6 normal
      • embedded-hal ^1.0 normal
      • embedded-hal-async ^1.0 normal
      • embedded-hal-nb ^1.0 normal
      • embedded-io ^0.6.0 normal
      • embedded-io-async ^0.6.1 normal
      • embedded-storage ^0.3.1 normal
      • embedded-storage-async ^0.4.1 normal
      • futures ^0.3.17 normal
      • log ^0.4.14 normal
      • nb ^1.0.0 normal
      • rand_core ^0.6.3 normal
      • sdio-host ^0.5.0 normal
      • stm32-fmc ^0.3.0 normal
      • stm32-metapac ^15 normal
      • vcell ^0.1.3 normal
      • critical-section ^1.1 dev
      • proc-macro2 ^1.0.36 build
      • quote ^1.0.15 build
      • stm32-metapac ^15 build
    • Versions
    • 100% of the crate is documented
  • Go to latest version
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • Rust
    • About docs.rs
    • Privacy policy
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate embassy_stm32

embassy_stm320.1.0

  • All Items
  • Re-exports
  • Modules
  • Macros
  • Structs
  • Constants
  • Traits
  • Functions
  • Attribute Macros

Crates

  • embassy_stm32
?
Change settings

Crate embassy_stm32

source ·
Expand description

You might want to browse the `embassy-stm32` documentation on the Embassy website instead.

The documentation here on `docs.rs` is built for a single chip only (STM32H755 in particular), while on the Embassy website you can pick your exact chip from the top menu. Available peripherals and their APIs change depending on the chip.

Embassy STM32 HAL

The embassy-stm32 HAL aims to provide a safe, idiomatic hardware abstraction layer for all STM32 families. The HAL implements both blocking and async APIs for many peripherals. Where appropriate, traits from both blocking and asynchronous versions of embedded-hal v0.2 and v1.0 are implemented, as well as serial traits from embedded-io[-async].

  • embassy-stm32 on crates.io
  • Documentation (Important: use docs.embassy.dev rather than docs.rs to see the specific docs for the chip you’re using!)
  • Source
  • Examples

embassy-stm32 supports all STM32 chip families

STM32 microcontrollers come in many families and flavors, and supporting all of them is a big undertaking. Embassy takes advantage of the fact that the STM32 peripheral versions are shared across chip families. For example, instead of re-implementing the SPI peripheral for every STM32 chip family, embassy has a single SPI implementation that depends on code-generated register types that are identical for STM32 families with the same version of a given peripheral.

In practice, this works as follows:

  1. You tell the compiler which chip you’re using with a feature flag
  2. The stm32-metapac module generates register types for that chip at compile time, based on data from the stm32-data module
  3. The embassy-stm32 HAL picks the correct implementation each peripheral based on automatically-generated feature flags, and applies any other tweaks which are required for the HAL to work on that chip

Be aware that, while embassy-stm32 strives to consistently support all peripherals across all chips, this approach can lead to slightly different APIs and capabilities being available on different families. Check the documentation for the specific chip you’re using to confirm exactly what’s available.

Embedded-hal

The embassy-stm32 HAL implements the traits from embedded-hal (v0.2 and 1.0) and embedded-hal-async, as well as embedded-io and embedded-io-async.

embassy-time time driver

If a time-driver-* feature is enabled, embassy-stm32 provides a time driver for use with embassy-time. You can pick which hardware timer is used for this internally via the time-driver-tim* features, or let embassy pick with time-driver-any.

embassy-time has a default tick rate of 1MHz, which is fast enough to cause problems with the 16-bit timers currently supported by the embassy-stm32 time driver (specifically, if a critical section delays an IRQ by more than 32ms). To avoid this, it’s recommended to pick a lower tick rate. 32.768kHz is a reasonable default for many purposes.

Interoperability

This crate can run on any executor.

Optionally, some features requiring embassy-time can be activated with the time feature. If you enable it, you must link an embassy-time driver in your project.

The low-power feature integrates specifically with embassy-executor, it can’t be ued on other executors for now.

Feature flags

  • rt (enabled by default) — Enable stm32-metapac’s rt feature
  • defmt — Use defmt for logging
  • memory-x — Automatically generate memory.x file using stm32-metapac
  • unstable-pac — Re-export stm32-metapac at embassy_stm32::pac. This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version. If this is an issue for you, you’re encouraged to directly depend on a fixed version of the PAC. There are no plans to make this stable.

Time

  • time — Enables additional driver features that depend on embassy-time
  • time-driver-any — Use any time driver
  • time-driver-tim2 — Use TIM2 as time driver
  • time-driver-tim3 — Use TIM3 as time driver
  • time-driver-tim4 — Use TIM4 as time driver
  • time-driver-tim5 — Use TIM5 as time driver
  • time-driver-tim9 — Use TIM9 as time driver
  • time-driver-tim11 — Use TIM11 as time driver
  • time-driver-tim12 — Use TIM12 as time driver
  • time-driver-tim15 — Use TIM15 as time driver

Analog Switch Pins (Pxy_C) on STM32H7 series

Get PXY and PXY_C singletons. Digital impls are on PXY, Analog impls are on PXY_C If disabled, you get only the PXY singleton. It has both digital and analog impls.

  • split-pa0 — Split PA0
  • split-pa1 — Split PA1
  • split-pc2 — Split PC2
  • split-pc3 — Split PC3
  • _split-pins-enabled — internal use only

Chip-selection features

Select your chip by specifying the model as a feature, e.g. stm32c011d6. Check the Cargo.toml for the latest list of supported chips.

Important: Do not forget to adapt the target chip in your toolchain, e.g. in .cargo/config.toml.

Re-exports

  • pub use stm32_metapac as pac;

Modules

  • adc
    Analog to Digital Converter (ADC)
  • can
    Controller Area Network (CAN)
  • crc
    Cyclic Redundancy Check (CRC)
  • dac
    Digital to Analog Converter (DAC)
  • dcmi
    Digital Camera Interface (DCMI)
  • dma
    Direct Memory Access (DMA)
  • eth
    Ethernet (ETH)
  • exti
    External Interrupts (EXTI)
  • flash
    Flash memory (FLASH)
  • fmc
    Flexible Memory Controller (FMC) / Flexible Static Memory Controller (FSMC)
  • gpio
    General-purpose Input/Output (GPIO)
  • hrtim
    High Resolution Timer (HRTIM)
  • i2c
    Inter-Integrated-Circuit (I2C)
  • interrupt
    Interrupt definitions.
  • peripherals
    Types for the peripheral singletons.
  • qspi
    Quad Serial Peripheral Interface (QSPI)
  • rcc
    Reset and Clock Control (RCC)
  • rng
    Random Number Generator (RNG)
  • rtc
    Real Time Clock (RTC)
  • sai
    Serial Audio Interface (SAI)
  • sdmmc
    Secure Digital / MultiMedia Card (SDMMC)
  • spi
    Serial Peripheral Interface (SPI)
  • time
    Time units
  • timer
    Timers, PWM, quadrature decoder.
  • uid
    Unique ID (UID)
  • usart
    Universal Synchronous/Asynchronous Receiver Transmitter (USART, UART, LPUART)
  • usb_otg
    USB On The Go (OTG)
  • wdg
    Watchdog Timer (IWDG, WWDG)

Macros

  • bind_interrupts
    Macro to bind interrupts to handlers.
  • into_ref
    Convenience converting into reference.

Structs

  • Config
    embassy-stm32 global configuration.
  • PeripheralRef
    An exclusive reference to a peripheral.
  • Peripherals
    Struct containing all the peripheral singletons.

Constants

  • NVIC_PRIO_BITS
    Number available in the NVIC for configuring priority

Traits

  • Peripheral
    Trait for any type that can be used as a peripheral of type P.

Functions

  • init
    Initialize the embassy-stm32 HAL with the provided configuration.

Attribute Macros

  • interrupt

Results

Type "channel4complementarypin" not found. Showing results for closest type name "channelecomplementarypin" instead.

trait
embassy_stm32::timer::Channel4ComplementaryPin
Channel4ComplementaryPin pin trait
trait
embassy_stm32::timer::Channel1ComplementaryPin
Channel1ComplementaryPin pin trait
trait
embassy_stm32::timer::Channel2ComplementaryPin
Channel2ComplementaryPin pin trait
trait
embassy_stm32::timer::Channel3ComplementaryPin
Channel3ComplementaryPin pin trait
trait
embassy_stm32::hrtim::ChannelAComplementaryPin
ChannelAComplementaryPin pin trait
trait
embassy_stm32::hrtim::ChannelBComplementaryPin
ChannelBComplementaryPin pin trait
trait
embassy_stm32::hrtim::ChannelCComplementaryPin
ChannelCComplementaryPin pin trait
trait
embassy_stm32::hrtim::ChannelDComplementaryPin
ChannelDComplementaryPin pin trait
trait
embassy_stm32::hrtim::ChannelEComplementaryPin
ChannelEComplementaryPin pin trait
trait method
embassy_stm32::hrtim::ChannelEComplementaryPin::af_num
Get the AF number needed to use this pin as …
method
embassy_stm32::hrtim::ComplementaryPwmPin::new_che
Create a new ChE complementary PWM pin instance.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.