embassy-rs/embassy · error

unsupported configuration

Error message

unsupported configuration

What it means

When reading SPI's I2SCFGR register, the driver maps the previous I2S configuration (i2scfg) to an RX-capable mode. Only SlaveRx/SlaveFullDuplex and MasterRx/MasterFullDuplex have defined mappings; any other encoded value hits the catch-all panic. The type is exposed as PioSpi's return surface (declared as _), so users typically see it as an unexpected panic rather than a typed error.

Solutions

  1. Configure the I2S peripheral into one of the four supported modes (SlaveRx, SlaveFullDuplex, MasterRx, MasterFullDuplex) before this call.
  2. Avoid reusing a peripheral previously configured by bootloader/other firmware with unsupported I2S mode bits; reset the peripheral first.
  3. Update the embassy-stm32 version if your chip variant encodes additional I2S modes not handled by this match.

Example fix

// before (register left in unsupported i2scfg, e.g. transmit-only)
// panic in mapping code
// after
w.set_i2scfg(vals::I2scfg::MasterRx); // or SlaveRx/MasterFullDuplex/SlaveFullDuplex
Defensive patterns

Strategy: validation

Validate before calling

// Reset/check the SPI peripheral's I2SCFGR before use:
// let i2scfg = spi.regs.i2scfgr().read().i2scfg();
// assert!(matches!(i2scfg, vals::I2scfg::SlaveRx | vals::I2scfg::SlaveFullDuplex | vals::I2scfg::MasterRx | vals::I2scfg::MasterFullDuplex));

Type guard

fn i2s_mode_supported(m: vals::I2scfg) -> bool {
    matches!(m, vals::I2scfg::SlaveRx | vals::I2scfg::SlaveFullDuplex | vals::I2scfg::MasterRx | vals::I2scfg::MasterFullDuplex)
}

Prevention

When it happens

Trigger: Calling the SPI/I2S register-mapping path when i2scfgr.i2scfg contains an unexpected value — e.g. the register is in a mode not covered by the match (transmit-only or corrupted encoding) while i2smod is set.

Common situations: Using the peripheral in an I2S configuration not supported by this driver path; reading state from a peripheral configured by other code/firmware to transmit-only mode; misuse of PioSpi wrappers.

Related errors


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/baa2f903d19a77bd. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/spi/mod.rs:1324

        self.set_word_size(W::CONFIG);

        let comm = {
            let mut w = regs.cfg2().read();
            let prev = w.comm();
            w.set_comm(vals::Comm::Receiver);
            regs.cfg2().write_value(w);
            prev
        };

        #[cfg(spi_v4)]
        let i2scfg = {
            let mut w = regs.i2scfgr().read();
            let r = w.i2smod().then(|| {
                let prev = w.i2scfg();
                w.set_i2scfg(match prev {
                    vals::I2scfg::SlaveRx | vals::I2scfg::SlaveFullDuplex => vals::I2scfg::SlaveRx,
                    vals::I2scfg::MasterRx | vals::I2scfg::MasterFullDuplex => vals::I2scfg::MasterRx,
                    _ => panic!("unsupported configuration"),
                });
                prev
            });
            regs.i2scfgr().write_value(w);
            r
        };

        let rx_src = regs.rx_ptr();

        for chunk in data.chunks_mut(u16::MAX.into()) {
            set_rxdmaen(regs, true);

            let tsize = chunk.len();

            let transfer = unsafe { self.rx_dma.as_mut().unwrap().read(rx_src, chunk, Default::default()) };

            regs.cr2().modify(|w| {
                w.set_tsize(tsize as u16);

View on GitHub (pinned to 463a07b963)