{"record":{"id":"fd6a0766d8362ef4","repo":"embassy-rs/embassy","slug":"invalid-pio-no-expected-one-of-0-1-2","errorCode":null,"errorMessage":"Invalid PIO_NO: {}, expected one of 0,1,2","messagePattern":"Invalid PIO_NO: (.+?), expected one of 0,1,2","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-rp/src/pio/mod.rs","lineNumber":1645,"sourceCode":"            1 => {\n                static STATE_1: State = State {\n                    users: AtomicU8::new(0),\n                    used_pins: AtomicU64::new(0),\n                };\n\n                &STATE_1\n            }\n            #[cfg(feature = \"_rp235x\")]\n            2 => {\n                static STATE_2: State = State {\n                    users: AtomicU8::new(0),\n                    used_pins: AtomicU64::new(0),\n                };\n\n                &STATE_2\n            }\n            #[cfg(feature = \"_rp235x\")]\n            _ => panic!(\"Invalid PIO_NO: {}, expected one of 0,1,2\", Self::PIO_NO),\n            #[cfg(not(feature = \"_rp235x\"))]\n            _ => panic!(\"Invalid PIO_NO: {}, expected one of 0,1\", Self::PIO_NO),\n        }\n    }\n}\n\n/// PIO instance.\n#[allow(private_bounds)]\npub trait Instance: SealedInstance + PeripheralType + Sized + Unpin {\n    /// Interrupt for this peripheral.\n    type Interrupt: crate::interrupt::typelevel::Interrupt;\n}\n\nmacro_rules! impl_pio {\n    ($name:ident, $pio:expr, $pac:ident, $funcsel:ident, $irq:ident) => {\n        impl SealedInstance for peripherals::$name {\n            const PIO_NO: u8 = $pio;\n            const PIO: &'static pac::pio::Pio = &pac::$pac;","sourceCodeStart":1627,"sourceCodeEnd":1663,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-rp/src/pio/mod.rs#L1627-L1663","documentation":"embassy-rp's PIO state plumbing maps each PIO type (PIO0/PIO1/PIO2) to a static state instance via a match on `Self::PIO_NO`. The `_` arm is unreachable for valid PIO numbers, so it panics with the PIO_NO value and the list of valid values — 0,1,2 on RP235x (this arm), 0,1 on RP2040. Reaching it means the PIO_NO type-level constant is invalid or a platform mismatch occurred.","triggerScenarios":"Compile-time misuse where a PIO constant other than 0/1/2 reaches the match (essentially an internal invariant violation), or platform/feature mismatch where code built for RP235x uses a PIO number not defined for that target.","commonSituations":"Feature-flag mix-ups (building `_rp235x` code against RP2040 PIO abstractions); hand-rolled PIO trait impls with a wrong PIO_NO; this panic surfaces when cyw43-pio or other drivers reference PIO state on a mismatched target.","solutions":["Check your target/feature flags: `rp2040` vs `rp235x` builds define different valid PIO sets","Ensure you only instantiate Pio<PIO0>/PIO1 (and PIO2 only on RP235x)","If using cyw43-pio or another driver, verify the selected PIO instance exists on your chip","Report as a bug if reached with a legitimate PIO instance — this arm should be unreachable"],"exampleFix":"// before (rp2040 target)\nlet pio = Pio::new(p.PIO2, Irqs); // PIO2 does not exist on RP2040\n// after\nlet pio = Pio::new(p.PIO1, Irqs); // or build with rp235x features","handlingStrategy":"validation","validationCode":"#[cfg(feature = \"_rp235x\")]\nconst _: () = assert!(PIO_NO <= 2);\n#[cfg(not(feature = \"_rp235x\"))]\nconst _: () = assert!(PIO_NO <= 1);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match embassy-rp cargo features to your actual chip target","Only instantiate PIO blocks defined by your hardware","Treat this panic as an internal bug and file an upstream report"],"tags":["pio","embedded","rust","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}