diff options
| author | WillaWillNot <[email protected]> | 2025-11-22 18:18:04 -0500 |
|---|---|---|
| committer | WillaWillNot <[email protected]> | 2025-11-22 18:18:04 -0500 |
| commit | b877b0dc6b5fe4541a45e6b43ed9d82131608aee (patch) | |
| tree | 6bc432aa7081bf6d2df36e322d5c742eaa449977 | |
| parent | 2589d3539903356c524b38f04f740b1735a80207 (diff) | |
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
| -rw-r--r-- | embassy-stm32/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | embassy-stm32/build.rs | 21 | ||||
| -rw-r--r-- | 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 | |||
| 77 | - feat: stm32/flash: add async support for h7 family | 77 | - feat: stm32/flash: add async support for h7 family |
| 78 | - feat: exti brought in line with other drivers' interrupt rebinding system ([#4922](https://github.com/embassy-rs/embassy/pull/4922)) | 78 | - feat: exti brought in line with other drivers' interrupt rebinding system ([#4922](https://github.com/embassy-rs/embassy/pull/4922)) |
| 79 | - removal: ExtiInput no longer accepts AnyPin/AnyChannel; AnyChannel removed entirely | 79 | - removal: ExtiInput no longer accepts AnyPin/AnyChannel; AnyChannel removed entirely |
| 80 | - change: build script now generates `unimpl_tsc` cfg option when a chip has a TSC peripheral but no driver | 80 | - fix: build script ensures EXTI2_TSC is listed as the IRQ of EXTI2 even if the PAC doesn't |
| 81 | - feat: stm32/lcd: added implementation | 81 | - feat: stm32/lcd: added implementation |
| 82 | 82 | ||
| 83 | ## 0.4.0 - 2025-08-26 | 83 | ## 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() { | |||
| 56 | 56 | ||
| 57 | eprintln!("chip: {chip_name}"); | 57 | eprintln!("chip: {chip_name}"); |
| 58 | 58 | ||
| 59 | cfgs.declare("unimpl_tsc"); | ||
| 60 | for p in METADATA.peripherals { | 59 | for p in METADATA.peripherals { |
| 61 | if let Some(r) = &p.registers { | 60 | if let Some(r) = &p.registers { |
| 62 | cfgs.enable(r.kind); | 61 | cfgs.enable(r.kind); |
| 63 | foreach_version_cfg(&mut cfgs, r.kind, r.version, |cfgs, cfg_name| { | 62 | foreach_version_cfg(&mut cfgs, r.kind, r.version, |cfgs, cfg_name| { |
| 64 | cfgs.enable(cfg_name); | 63 | cfgs.enable(cfg_name); |
| 65 | }); | 64 | }); |
| 66 | } else if p.name == "TSC" { | ||
| 67 | //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 | ||
| 68 | cfgs.enable("unimpl_tsc") | ||
| 69 | } | 65 | } |
| 70 | } | 66 | } |
| 71 | 67 | ||
| @@ -357,8 +353,13 @@ fn main() { | |||
| 357 | // ======== | 353 | // ======== |
| 358 | // Generate interrupt declarations | 354 | // Generate interrupt declarations |
| 359 | 355 | ||
| 356 | let mut exti2_tsc_shared_int_present: Option<stm32_metapac::metadata::Interrupt> = None; | ||
| 360 | let mut irqs = Vec::new(); | 357 | let mut irqs = Vec::new(); |
| 361 | for irq in METADATA.interrupts { | 358 | for irq in METADATA.interrupts { |
| 359 | // The PAC doesn't ensure this is listed as the IRQ of EXTI2, so we must do so | ||
| 360 | if irq.name == "EXTI2_TSC" { | ||
| 361 | exti2_tsc_shared_int_present = Some(irq.clone()) | ||
| 362 | } | ||
| 362 | irqs.push(format_ident!("{}", irq.name)); | 363 | irqs.push(format_ident!("{}", irq.name)); |
| 363 | } | 364 | } |
| 364 | 365 | ||
| @@ -1816,7 +1817,19 @@ fn main() { | |||
| 1816 | for p in METADATA.peripherals { | 1817 | for p in METADATA.peripherals { |
| 1817 | let mut pt = TokenStream::new(); | 1818 | let mut pt = TokenStream::new(); |
| 1818 | 1819 | ||
| 1820 | let mut exti2_tsc_injected = false; | ||
| 1821 | if let Some(ref irq) = exti2_tsc_shared_int_present | ||
| 1822 | && p.name == "EXTI" | ||
| 1823 | { | ||
| 1824 | exti2_tsc_injected = true; | ||
| 1825 | let iname = format_ident!("{}", irq.name); | ||
| 1826 | let sname = format_ident!("{}", "EXTI2"); | ||
| 1827 | pt.extend(quote!(pub type #sname = crate::interrupt::typelevel::#iname;)); | ||
| 1828 | } | ||
| 1819 | for irq in p.interrupts { | 1829 | for irq in p.interrupts { |
| 1830 | if exti2_tsc_injected && irq.signal == "EXTI2" { | ||
| 1831 | continue; | ||
| 1832 | } | ||
| 1820 | let iname = format_ident!("{}", irq.interrupt); | 1833 | let iname = format_ident!("{}", irq.interrupt); |
| 1821 | let sname = format_ident!("{}", irq.signal); | 1834 | let sname = format_ident!("{}", irq.signal); |
| 1822 | pt.extend(quote!(pub type #sname = crate::interrupt::typelevel::#iname;)); | 1835 | 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 { | |||
| 395 | 395 | ||
| 396 | macro_rules! impl_exti { | 396 | macro_rules! impl_exti { |
| 397 | ($type:ident, $number:expr) => { | 397 | ($type:ident, $number:expr) => { |
| 398 | impl_exti!(@inner $type, $number, crate::_generated::peripheral_interrupts::EXTI::$type); | ||
| 399 | }; | ||
| 400 | ($type:ident, $number:expr, @tsc) => { | ||
| 401 | impl_exti!(@inner $type, $number, crate::_generated::peripheral_interrupts::TSC::GLOBAL); | ||
| 402 | }; | ||
| 403 | (@inner $type:ident, $number:expr, $irq:path) => { | ||
| 404 | impl SealedChannel for crate::peripherals::$type {} | 398 | impl SealedChannel for crate::peripherals::$type {} |
| 405 | impl Channel for crate::peripherals::$type { | 399 | impl Channel for crate::peripherals::$type { |
| 406 | fn number(&self) -> PinNumber { | 400 | fn number(&self) -> PinNumber { |
| 407 | $number | 401 | $number |
| 408 | } | 402 | } |
| 409 | fn irq(&self) -> InterruptEnum { | 403 | fn irq(&self) -> InterruptEnum { |
| 410 | <$irq>::IRQ | 404 | crate::_generated::peripheral_interrupts::EXTI::$type::IRQ |
| 411 | } | 405 | } |
| 412 | type IRQ = $irq; | 406 | type IRQ = crate::_generated::peripheral_interrupts::EXTI::$type; |
| 413 | } | 407 | } |
| 414 | 408 | ||
| 415 | //Still here to surface deprecation messages to the user - remove when removing AnyChannel | 409 | //Still here to surface deprecation messages to the user - remove when removing AnyChannel |
| 416 | #[allow(deprecated)] | 410 | #[allow(deprecated)] |
| 417 | impl From<crate::peripherals::$type> for AnyChannel { | 411 | impl From<crate::peripherals::$type> for AnyChannel { |
| 418 | fn from(_val: crate::peripherals::$type) -> Self { | 412 | fn from(_val: crate::peripherals::$type) -> Self { |
| 419 | Self { | 413 | Self { number: $number } |
| 420 | number: $number, | ||
| 421 | } | 414 | } |
| 422 | }} | 415 | } |
| 423 | }; | 416 | }; |
| 424 | } | 417 | } |
| 425 | 418 | ||
| 426 | impl_exti!(EXTI0, 0); | 419 | impl_exti!(EXTI0, 0); |
| 427 | impl_exti!(EXTI1, 1); | 420 | impl_exti!(EXTI1, 1); |
| 428 | #[cfg(not(any(tsc, unimpl_tsc)))] | ||
| 429 | impl_exti!(EXTI2, 2); | 421 | impl_exti!(EXTI2, 2); |
| 430 | #[cfg(any(tsc, unimpl_tsc))] | ||
| 431 | impl_exti!(EXTI2, 2, @tsc); | ||
| 432 | impl_exti!(EXTI3, 3); | 422 | impl_exti!(EXTI3, 3); |
| 433 | impl_exti!(EXTI4, 4); | 423 | impl_exti!(EXTI4, 4); |
| 434 | impl_exti!(EXTI5, 5); | 424 | impl_exti!(EXTI5, 5); |
