Expand description
§embassy-stm32-hub75
A no-std Rust driver for HUB75-style LED matrix panels on STM32
microcontrollers. HUB75 is a standard interface for driving large, bright,
and colorful RGB LED displays, commonly used in digital signage and art
installations.
This library uses an ISR-driven DMA refresh loop to continuously output
framebuffer data to a GPIO port. A timer generates the pixel clock via PWM
and triggers DMA transfers on each update event. Once the driver is
initialised via hub75_define!’s init() function, rendering happens
entirely in the background via DMA transfer-complete interrupts — no CPU
involvement per pixel.
§Double Buffering
The driver supports double-buffered operation via Hub75::swap(). The
application writes to one framebuffer while the ISR renders from another,
swapping atomically at frame boundaries.
§8-bit Mode
In 8-bit mode, an external 74HC574-style latch handles the row address lines. This requires only 8 data pins: R1, G1, B1, R2, G2, B2, LATCH, and BLANK. The 8 pins must occupy either the lower byte (pins 0-7) or upper byte (pins 8-15) of a single GPIO port. Byte-width DMA writes to the corresponding ODR byte update only those 8 pins without disturbing the other half of the port.
§16-bit Mode
In 16-bit mode, all 16 pins of a GPIO port are used. Half-word-width DMA writes the full ODR register on each clock cycle. Pin layout and bit assignments depend on the framebuffer implementation used.
§Framebuffers
The hub75-framebuffer crate provides bitplane framebuffers that are
strongly recommended for their memory efficiency. The plain 16-bit variant
requires no external hardware beyond the panel itself. The latched 8-bit
variant saves GPIO pins and cuts framebuffer memory nearly in half (one
byte per pixel-clock instead of two), but requires an external
74HC574-style latch circuit (see the hub75-framebuffer README for the
schematic). Both store one bit per pixel per plane and are output via DMA
without format conversion.
§Defining an Instance
Use the hub75_define! macro to create a driver module bound to specific
timer and DMA channel peripherals:
use embassy_stm32::{bind_interrupts, dma, peripherals};
use embassy_stm32_hub75::hub75_define;
hub75_define!(hub75, embassy_stm32::peripherals::TIM2, embassy_stm32::peripherals::DMA1_CH1);
bind_interrupts!(struct Irqs {
DMA1_CHANNEL1 =>
dma::InterruptHandler<peripherals::DMA1_CH1>,
hub75::Hub75DmaHandler;
});
let hub75 = hub75::init(
p.TIM2, p.PA0, p.DMA1_CH1, Irqs, pins,
Config::new().frequency(Hertz(6_000_000)),
fb,
);§Crate Features
defmt– enabledefmtlogging (forwards to embassy-stm32, hub75-framebuffer, and embedded-graphics)skip-black-pixels– skip writing black pixels to the framebuffer, leaving the bitplane data unchanged (forwards to hub75-framebuffer)invert-oe– invert the output-enable signal in the framebuffer (forwards to hub75-framebuffer)tail-closes-latch– append a tail word that closes the latch after data is shifted in; plain 16-bit mode only (forwards to hub75-framebuffer)blank-delay-{1,2,4,8}– insert 1/2/4/8 blank delay cycles after latching; plain 16-bit mode only (forwards to hub75-framebuffer)
Re-exports§
pub use hub75_framebuffer as framebuffer;
Modules§
- dma
- ISR-driven HUB75 timer+DMA panel driver.
Macros§
- hub75_
define - Define a HUB75 driver instance with its own timer static and ISR handler.
Structs§
- Config
- Driver configuration for pixel clock frequency (defaults to 10 MHz) and GPIO output speed (defaults to Medium).
- Hertz
- Hertz
- Hub75
Pins8 - Pin configuration for a HUB75 panel with an external address latch.
- Hub75
Pins16 - Pin configuration for a HUB75 panel using 16 data pins (full GPIO port width).
Enums§
- Hub75
Error - Represents errors that can occur during HUB75 driver operations.
- Speed
- Speed setting for an output.
Traits§
- Hub75
Pins - Trait implemented by HUB75 pin groups (8-bit or 16-bit).
Type Aliases§
- Color
- The color type used by the HUB75 driver. Color type used in the framebuffer