From b877b0dc6b5fe4541a45e6b43ed9d82131608aee Mon Sep 17 00:00:00 2001 From: WillaWillNot Date: Sat, 22 Nov 2025 18:18:04 -0500 Subject: Build script now injects EXTI2 => EXTI2_TSC peripheral/interrupt mapping if it's not present in the PAC, removed macro magic in exti that was working around this omission --- embassy-stm32/CHANGELOG.md | 2 +- embassy-stm32/build.rs | 21 +++++++++++++++++---- embassy-stm32/src/exti.rs | 18 ++++-------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md index 0f8113863..a66b2d437 100644 --- a/embassy-stm32/CHANGELOG.md +++ b/embassy-stm32/CHANGELOG.md @@ -77,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - feat: stm32/flash: add async support for h7 family - feat: exti brought in line with other drivers' interrupt rebinding system ([#4922](https://github.com/embassy-rs/embassy/pull/4922)) - removal: ExtiInput no longer accepts AnyPin/AnyChannel; AnyChannel removed entirely -- change: build script now generates `unimpl_tsc` cfg option when a chip has a TSC peripheral but no driver +- fix: build script ensures EXTI2_TSC is listed as the IRQ of EXTI2 even if the PAC doesn't - feat: stm32/lcd: added implementation ## 0.4.0 - 2025-08-26 diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 3d0b13fe2..109571e8f 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -56,16 +56,12 @@ fn main() { eprintln!("chip: {chip_name}"); - cfgs.declare("unimpl_tsc"); for p in METADATA.peripherals { if let Some(r) = &p.registers { cfgs.enable(r.kind); foreach_version_cfg(&mut cfgs, r.kind, r.version, |cfgs, cfg_name| { cfgs.enable(cfg_name); }); - } else if p.name == "TSC" { - //Even if the registers are missing, EXTI needs to know if TSC is present in silicon to know whether the EXTI2 interrupt is shadowed by EXTI2_TSC - cfgs.enable("unimpl_tsc") } } @@ -357,8 +353,13 @@ fn main() { // ======== // Generate interrupt declarations + let mut exti2_tsc_shared_int_present: Option = None; let mut irqs = Vec::new(); for irq in METADATA.interrupts { + // The PAC doesn't ensure this is listed as the IRQ of EXTI2, so we must do so + if irq.name == "EXTI2_TSC" { + exti2_tsc_shared_int_present = Some(irq.clone()) + } irqs.push(format_ident!("{}", irq.name)); } @@ -1816,7 +1817,19 @@ fn main() { for p in METADATA.peripherals { let mut pt = TokenStream::new(); + let mut exti2_tsc_injected = false; + if let Some(ref irq) = exti2_tsc_shared_int_present + && p.name == "EXTI" + { + exti2_tsc_injected = true; + let iname = format_ident!("{}", irq.name); + let sname = format_ident!("{}", "EXTI2"); + pt.extend(quote!(pub type #sname = crate::interrupt::typelevel::#iname;)); + } for irq in p.interrupts { + if exti2_tsc_injected && irq.signal == "EXTI2" { + continue; + } let iname = format_ident!("{}", irq.interrupt); let sname = format_ident!("{}", irq.signal); pt.extend(quote!(pub type #sname = crate::interrupt::typelevel::#iname;)); diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 57217034e..7b7896d46 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -395,40 +395,30 @@ pub struct AnyChannel { macro_rules! impl_exti { ($type:ident, $number:expr) => { - impl_exti!(@inner $type, $number, crate::_generated::peripheral_interrupts::EXTI::$type); - }; - ($type:ident, $number:expr, @tsc) => { - impl_exti!(@inner $type, $number, crate::_generated::peripheral_interrupts::TSC::GLOBAL); - }; - (@inner $type:ident, $number:expr, $irq:path) => { impl SealedChannel for crate::peripherals::$type {} impl Channel for crate::peripherals::$type { fn number(&self) -> PinNumber { $number } fn irq(&self) -> InterruptEnum { - <$irq>::IRQ + crate::_generated::peripheral_interrupts::EXTI::$type::IRQ } - type IRQ = $irq; + type IRQ = crate::_generated::peripheral_interrupts::EXTI::$type; } //Still here to surface deprecation messages to the user - remove when removing AnyChannel #[allow(deprecated)] impl From for AnyChannel { fn from(_val: crate::peripherals::$type) -> Self { - Self { - number: $number, + Self { number: $number } } - }} + } }; } impl_exti!(EXTI0, 0); impl_exti!(EXTI1, 1); -#[cfg(not(any(tsc, unimpl_tsc)))] impl_exti!(EXTI2, 2); -#[cfg(any(tsc, unimpl_tsc))] -impl_exti!(EXTI2, 2, @tsc); impl_exti!(EXTI3, 3); impl_exti!(EXTI4, 4); impl_exti!(EXTI5, 5); -- cgit