Skip to main content

Crate rpi_hal_embassy

Crate rpi_hal_embassy 

Source
Expand description

Embassy support for Raspberry Pi boards using the BCM2836/BCM2837 SoC (Pi 2, Pi 3), on top of the rpi-hal crate.

Provides the two platform pieces Embassy needs and cannot supply itself: an embassy-time driver over the BCM System Timer, and a thread-mode executor for AArch32 and AArch64.

This is a separate crate from rpi-hal rather than a feature of it because an embassy-time driver is installed by linkage: the time_driver_impl! macro defines #[unsafe(no_mangle)] symbols that embassy-time resolves against, and a program links only if exactly one driver exists in its crate graph. Behind a feature on the HAL, any dependency enabling that feature would force this driver onto the whole program and conflict with an application supplying its own — an opt-in that cannot be opted out of.

§What an application must provide

  • A critical-section implementation, which rpi-hal’s rt feature provides. The timer queue is guarded by one.
  • rpi-hal’s mmu feature (on by default). The executor’s run queue is built on atomic compare-exchange, and ldrex/strex are UNPREDICTABLE until RAM is mapped as cacheable Normal memory.
  • Interrupt dispatch. rpi-hal leaves __irq_handler to the application, so this crate cannot claim it; the application routes the System Timer’s interrupt here from its own handler.

Re-exports§

pub use executor::Executor;

Modules§

executor
Thread-mode executor for AArch32 and AArch64 — see the module’s own documentation for why this isn’t one of embassy-executor’s backends. Thread-mode executor, idling in wfe and woken by sev.
irq
Getting interrupts to the code waiting on them — see irq::dispatch, and the irq-dispatch feature for the case where an application has no sources of its own. Getting interrupts to the code waiting on them.
time_driver
embassy-time driver over the BCM System Timer — see the module’s own documentation for the interrupt wiring an application must provide. embassy-time driver over the BCM System Timer.