$ show embassy-rs/embassy
Embassy is a next-generation embedded framework for Rust that enables asynchronous programming on microcontrollers using async/await syntax. It provides Hardware Abstraction Layers (HALs) for multiple MCU families (STM32, Nordic nRF, Raspberry Pi RP2040/RP23xx, TI MSPM0, NXP MCX-A, etc.), an async executor for cooperative multitasking, timekeeping utilities, networking stack, USB device/host stack, Bluetooth support, bootloader/DFU capabilities, cryptographic primitives, and synchronization primitives. The framework emphasizes safety, correctness, and energy efficiency through Rust's compile-time guarantees, with an executor that automatically enters low-power sleep when idle. Applications are structured around peripheral initialization, async task spawning via #[embassy_executor::task], and event-driven communication using Embassy's synchronization primitives.
The LLM identified 5 files worth highlighting for reuse:
Implements atomic state operations for the executor with efficient bit-packing of multiple state fields into machine words. Demonstrates low-level concurrency skill through careful use of atomic operations and bit manipulation to minimize memory footprint while ensuring thread-safe state transitions between idle, running, and pending states.
Provides asynchronous channels for communication between tasks with support for zero-sized types and both buffered and unbuffered variants. Shows non-obvious skill in handling task waking and context switching efficiently, avoiding busy-waiting through proper integration with the executor's waker mechanism.
Offers hardware-agnostic timekeeping abstractions that work across different timer peripherals through trait-based design. Demonstrates skilled API design by providing Instant, Duration, and Timer types that enable portable delay and timeout operations while allowing optimal implementation for each hardware timer.
Complete implementation of the USB CDC ACM (serial communications) device class. Shows craftsmanship in correctly handling USB protocol details including setup packets, endpoint management, and state transitions while providing an easy-to-use API for embedded serial communication.
Defines the network interface abstraction that allows the embassy-net stack to work with different hardware drivers (Wiznet, ESP32, etc.). Demonstrates skilled separation of concerns by isolating hardware-specific details behind a common interface while providing a flexible foundation for network protocols.