Expand description
Mini-HSM firmware entry point.
Boot sequence:
- Initialise embassy-rp peripherals.
- Configure GPIOs:
- GP15 input with pull-up : touch button (active-low).
- GP16 output : green status LED.
- GP17 output : yellow touch-awaiting LED.
- Build the USB-HID stack and split it into reader/writer.
- Build the ATECC HAL on I2C0 (SCL=GP5, SDA=GP4).
- Spawn the auxiliary tasks: USB run, state machine, animation, touch.
- Fire
Event::BootCompleteso the state machine leaves the boot state. - Enter the dispatch loop in the main task.
ยงstatic_cell instead of static mut
Two pieces of state need to live in static storage so the embassy
USB stack can borrow them with a 'static lifetime: the descriptor
buffers and the HID class state. The idiomatic way to allocate these
without unsafe is [static_cell::StaticCell], which lets the runtime
check at boot that the storage is initialised exactly once. The price
paid is a one-shot init call returning &'static mut T; the runtime
cost is a single atomic flag flip.
Modulesยง
- animation ๐
- LED animation task.
- channels ๐
- Global communication primitives between firmware tasks.
- hal_
rp2040 ๐ - ATECC HAL implementation for the RP2040.
- state ๐
- State machine task.
- tasks ๐
- Async tasks running on the firmware.
- touch ๐
- Touch button sampling task.
- usb ๐
- USB-HID device stack.
Structsยง
- Embassy
Clock ๐ - Clock backed by
embassy_time::Instant. Provides milliseconds since boot, monotonic, used by the PIN session timeout.
Staticsยง
- HID_
STATE ๐ - Storage for the HID class state. Kept separate from
USB_BUFFERSbecauseStateis invariant over its lifetime parameter, which forces it to share a single named lifetime with the device borrow. - USB_
BUFFERS ๐ - Storage for the USB descriptor / control buffers. The contents are
borrowed by the USB device for the rest of the program. Initialised
once at boot via
init.
Functionsยง
- __
cortex_ ๐m_ rt_ main - __
embassy_ ๐main