embassy-rs/embassy · error

Invalid ADC channel side

Error message

Invalid ADC channel side: {}

What it means

The build script generates ADC peripheral implementations by parsing signal names of the form `CH<n>_<side>` where side must be `A` or `B`. If a signal name in the chip metadata ends in a suffix other than A/B after the last underscore, the parser cannot map it to the SideA/SideB enum and panics. This guards against malformed or unexpected signal naming in the metadata.

Solutions

  1. Update embassy-nxp and metadata dependencies to versions whose ADC signal names match the `CHn_A`/`CHn_B` convention.
  2. Check the release notes/changelog for ADC signal renames and pin your embassy-nxp version to a known-good release.
  3. Report the offending signal name (from the panic message) upstream if the chip is officially supported.
Defensive patterns

Strategy: fallback

Try / catch

// Build-time panic; guard by using a known-good release.
[dependencies]
embassy-nxp = { version = "=0.1.0", features = ["mimxrt1062"] } // pinned release with valid ADC metadata

Prevention

When it happens

Trigger: Building embassy-nxp for a chip whose metadata defines an ADC signal whose name, when split on the last `_`, yields a side token other than `"A"` or `"B"` (e.g. `CH0_DIFF`, `CH1_SE`).

Common situations: Using a chip feature with incomplete/renamed ADC signal metadata; version skew between embassy-nxp and the metadata crate after a signal-naming change upstream.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at embassy-nxp/build.rs:278

            #cfg
            #ident
        }
    });

    quote! {
        embassy_hal_internal::peripherals_definition!(#(#defs),*);
        embassy_hal_internal::peripherals_struct!(#(#peripherals),*);
    }
}

fn impl_adc(impls: &mut Vec<TokenStream>, peripheral: &Peripheral) {
    for signal in peripheral.signals.iter() {
        let (ch_num, ch_side) = signal.name.rsplit_once("_").unwrap();
        let ch_num = ch_num.strip_prefix("CH").unwrap().parse::<u8>().unwrap();
        let ch_side = match ch_side {
            "A" => format_ident!("SideA"),
            "B" => format_ident!("SideB"),
            side => panic!("Invalid ADC channel side: {}", side),
        };

        assert_eq!(signal.pins.len(), 1);
        let pin = format_ident!("{}", signal.pins[0].pin);
        let ch_num = Literal::u8_unsuffixed(ch_num);

        impls.push(quote! {
            impl_adc_pin!(#pin, #ch_num, crate::adc::ChannelSide::#ch_side);
        })
    }
}

fn impl_gpio_pin(impls: &mut Vec<TokenStream>, peripheral: &Peripheral) {
    let instance = peripheral.name.strip_prefix("GPIO").unwrap();
    let bank = format_ident!("Gpio{}", instance);
    // let pin =

    for signal in peripheral.signals.iter() {

View on GitHub (pinned to 463a07b963)