Skip to the content.

Typed-error catalog

Every driver crate in this workspace exposes a generic Error<E> enum. The E parameter is the underlying transport error (I²C, SPI, or UART), which the firmware wraps with Debug2Format for defmt logging.

This page summarises every variant across the workspace so a new contributor (or an AI agent debugging a panic trace) can map an error log line to its root cause without grepping the source.

Common pattern: transport vs protocol

Most drivers split errors into two categories:

Recovery hint: transport errors usually warrant a retry; protocol errors usually mean a wiring or firmware bug and should not be retried blindly.

Per-crate catalog

axp2101::Error<E>

PMU init / battery gauge.

aw9523::Error<E>

I/O expander init.

aw88298::Error<E>

Mono Class-D amplifier (TX path).

bm8563::Error<E>

RTC.

bmi270::Error<E>

6-axis IMU.

bmm150::Error<E>

Magnetometer.

es7210::Error<E>

4-channel ADC (RX path).

ft6336u::Error<E>

Capacitive touch.

gc0308::Error<E>

Camera SCCB.

ltr553::Error<E>

Ambient + proximity.

py32::Error<E>

Co-processor (servo power gate, LED ring).

scservo::Error<E>

Half-duplex serial servo bus.

si12t::Error<E>

ir-nec

No Error enum — decoder returns Option<NecCommand> and treats noise as “no decode” rather than an error.

stackchan_net::ConfigError

RON config parse + validation. Host crate; firmware wraps with Debug2Format for defmt logging. Validators only fire through parse_ron — the firmware’s Config::default() fallback path never trips them.

stackchan_tts::RenderError

Speech-backend rendering. Returned from SpeechBackend::render when a backend that answered can_handle == true can’t produce audio for the specific utterance, or is currently degraded. #[non_exhaustive].

Firmware-side error wrapping

stackchan-firmware does not introduce its own typed-error enum. Init failures inside #[esp_rtos::main] panic via defmt::panic! because there’s no caller to bubble to. Per-task failures are logged with defmt::warn! or defmt::error! and the task continues, parks forever, or restarts depending on severity (see each src/<chip>.rs).

Adding a new error variant

When adding a variant to a driver crate’s Error:

  1. Document what triggered it and what to do about it in the doc-comment — the catalog above relies on this to stay accurate.
  2. Carry the offending value (u8, u16, etc.) when it aids debugging. Logs that just say “bad chip ID” without the byte are hard to triage.
  3. Update this catalog in the same PR.