Copper Embedded Registry
A shared registry for Copper components to register and retrieve serial ports, SPI buses, chip-select pins, and delay providers in no-std environments.
Overview
This library provides global slot-based registries for embedded devices so Copper applications can configure hardware in main and Copper components can pick them up later. It works in both std and no-std environments.
Usage
Registering devices in your board-support crate
use cu_embedded_registry as reg;
use ;
use embedded_hal as eh1;
// Register serial at slot 0
let serial: MySerial = /* ... */;
register?;
// Register SPI + CS + delay for a sensor at slot 1
let spi: MySpi = /* ... */;
let cs: MyCsPin = /* ... */;
let delay: MyDelay = /* ... */;
register_spi?;
register_cs?;
register_delay?;
Consuming devices inside a Copper component
use cu_embedded_registry as reg;
let spi: MySpi = take_spi.expect;
let cs: MyCsPin = take_cs.expect;
let delay: MyDelay = take_delay.expect;
Slots are consumed when taken; re-register if the handle needs to be shared again.
Features
- no-std compatible: Works in embedded environments
- Type-safe: Uses Rust's type system to ensure correct device types
- Thread-safe: Uses spin locks for concurrent access
- Bounded: Supports up to 8 slots per device class
- Zero-cost when unused: Minimal overhead
Integration with Copper
Bridges and sources can take SPI/CS/delay or serial instances from the registry instead of constructing them directly, letting the board-support crate decide the concrete HAL types.