diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 1257e015..e67c4b98 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -2,6 +2,7 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; use std::collections::{HashMap, HashSet}; use std::env; +use std::fmt::Write as _; use std::fs; use std::path::PathBuf; use stm32_metapac::metadata::METADATA; @@ -530,9 +531,127 @@ fn main() { } // ======== - // Write generated.rs + // Write foreach_foo! macrotables + + let mut interrupts_table: Vec> = Vec::new(); + let mut peripherals_table: Vec> = Vec::new(); + let mut pins_table: Vec> = Vec::new(); + let mut dma_channels_table: Vec> = Vec::new(); + + let gpio_base = METADATA + .peripherals + .iter() + .find(|p| p.name == "GPIOA") + .unwrap() + .address as u32; + let gpio_stride = 0x400; + + for p in METADATA.peripherals { + if let Some(regs) = &p.registers { + if regs.kind == "gpio" { + let port_letter = p.name.chars().skip(4).next().unwrap(); + assert_eq!(0, (p.address as u32 - gpio_base) % gpio_stride); + let port_num = (p.address as u32 - gpio_base) / gpio_stride; + + for pin_num in 0u32..16 { + let pin_name = format!("P{}{}", port_letter, pin_num); + pins_table.push(vec![ + pin_name, + p.name.to_string(), + port_num.to_string(), + pin_num.to_string(), + format!("EXTI{}", pin_num), + ]); + } + } + + for irq in p.interrupts { + let mut row = Vec::new(); + row.push(p.name.to_string()); + row.push(regs.kind.to_string()); + row.push(regs.block.to_string()); + row.push(irq.signal.to_string()); + row.push(irq.interrupt.to_ascii_uppercase()); + interrupts_table.push(row) + } + + let mut row = Vec::new(); + row.push(regs.kind.to_string()); + row.push(p.name.to_string()); + peripherals_table.push(row); + } + } + + let mut dma_channel_count: usize = 0; + let mut bdma_channel_count: usize = 0; + + for ch in METADATA.dma_channels { + let mut row = Vec::new(); + let dma_peri = METADATA + .peripherals + .iter() + .find(|p| p.name == ch.dma) + .unwrap(); + let bi = dma_peri.registers.as_ref().unwrap(); + + let num; + match bi.kind { + "dma" => { + num = dma_channel_count; + dma_channel_count += 1; + } + "bdma" => { + num = bdma_channel_count; + bdma_channel_count += 1; + } + _ => panic!("bad dma channel kind {}", bi.kind), + } + + row.push(ch.name.to_string()); + row.push(ch.dma.to_string()); + row.push(bi.kind.to_string()); + row.push(ch.channel.to_string()); + row.push(num.to_string()); + if let Some(dmamux) = &ch.dmamux { + let dmamux_channel = ch.dmamux_channel.unwrap(); + row.push(format!( + "{{dmamux: {}, dmamux_channel: {}}}", + dmamux, dmamux_channel + )); + } else { + row.push("{}".to_string()); + } + + dma_channels_table.push(row); + } + + g.extend(quote! { + pub(crate) const DMA_CHANNEL_COUNT: usize = #dma_channel_count; + pub(crate) const BDMA_CHANNEL_COUNT: usize = #bdma_channel_count; + }); + + for irq in METADATA.interrupts { + let name = irq.name.to_ascii_uppercase(); + interrupts_table.push(vec![name.clone()]); + if name.contains("EXTI") { + interrupts_table.push(vec!["EXTI".to_string(), name.clone()]); + } + } + + let mut m = String::new(); + + make_table(&mut m, "foreach_interrupt", &interrupts_table); + make_table(&mut m, "foreach_peripheral", &peripherals_table); + make_table(&mut m, "foreach_pin", &pins_table); + make_table(&mut m, "foreach_dma_channel", &dma_channels_table); let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let out_file = out_dir.join("macros.rs").to_string_lossy().to_string(); + fs::write(out_file, m).unwrap(); + + // ======== + // Write generated.rs + let out_file = out_dir.join("generated.rs").to_string_lossy().to_string(); fs::write(out_file, g.to_string()).unwrap(); @@ -644,3 +763,30 @@ impl IteratorExt for T { } } } + +fn make_table(out: &mut String, name: &str, data: &Vec>) { + write!( + out, + "#[macro_export] +macro_rules! {} {{ + ($($pat:tt => $code:tt;)*) => {{ + macro_rules! __{}_inner {{ + $(($pat) => $code;)* + ($_:tt) => {{}} + }} +", + name, name + ) + .unwrap(); + + for row in data { + write!(out, " __{}_inner!(({}));\n", name, row.join(",")).unwrap(); + } + + write!( + out, + " }}; +}}" + ) + .unwrap(); +} diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index 86f33ca1..7b3233a1 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs @@ -36,7 +36,7 @@ pub trait Instance: sealed::Instance + crate::rcc::RccPeripheral + 'static {} pub trait Common: sealed::Common + 'static {} pub trait AdcPin: sealed::AdcPin {} -crate::pac::peripherals!( +foreach_peripheral!( (adc, $inst:ident) => { impl crate::adc::sealed::Instance for peripherals::$inst { fn regs() -> &'static crate::pac::adc::Adc { @@ -44,7 +44,7 @@ crate::pac::peripherals!( } #[cfg(not(adc_f1))] fn common_regs() -> &'static crate::pac::adccommon::AdcCommon { - crate::pac::peripherals!{ + foreach_peripheral!{ (adccommon, $common_inst:ident) => { return &crate::pac::$common_inst }; @@ -57,7 +57,7 @@ crate::pac::peripherals!( ); #[cfg(not(adc_f1))] -crate::pac::peripherals!( +foreach_peripheral!( (adccommon, $inst:ident) => { impl sealed::Common for peripherals::$inst { fn regs() -> &'static crate::pac::adccommon::AdcCommon { diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs index 856f3151..c52d737b 100644 --- a/embassy-stm32/src/can/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs @@ -70,7 +70,7 @@ pub(crate) mod sealed { pub trait Instance: sealed::Instance + RccPeripheral {} -crate::pac::peripherals!( +foreach_peripheral!( (can, $inst:ident) => { impl sealed::Instance for peripherals::$inst { fn regs() -> &'static crate::pac::can::Can { @@ -86,7 +86,7 @@ crate::pac::peripherals!( }; ); -crate::pac::peripherals!( +foreach_peripheral!( (can, CAN) => { unsafe impl bxcan::FilterOwner for peripherals::CAN { const NUM_FILTER_BANKS: u8 = 14; diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index 7432c34a..1f6ba63d 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs @@ -16,7 +16,7 @@ pub trait Instance: sealed::Instance + 'static {} pub trait DacPin: crate::gpio::Pin + 'static {} -crate::pac::peripherals!( +foreach_peripheral!( (dac, $inst:ident) => { impl crate::dac::sealed::Instance for peripherals::$inst { fn regs() -> &'static crate::pac::dac::Dac { diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index 9ac96c69..bf78b631 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs @@ -474,7 +474,7 @@ macro_rules! impl_peripheral { }; } -crate::pac::interrupts! { +foreach_interrupt! { ($inst:ident, dcmi, $block:ident, GLOBAL, $irq:ident) => { impl_peripheral!($inst, $irq); }; diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 2f0715cf..4fafe7df 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs @@ -7,6 +7,7 @@ use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::waitqueue::AtomicWaker; use crate::dma::Request; +use crate::generated::BDMA_CHANNEL_COUNT; use crate::pac; use crate::pac::bdma::vals; @@ -22,62 +23,44 @@ impl From for vals::Size { } } -const CH_COUNT: usize = pac::peripheral_count!(bdma) * 8; - struct State { - ch_wakers: [AtomicWaker; CH_COUNT], + ch_wakers: [AtomicWaker; BDMA_CHANNEL_COUNT], } impl State { const fn new() -> Self { const AW: AtomicWaker = AtomicWaker::new(); Self { - ch_wakers: [AW; CH_COUNT], + ch_wakers: [AW; BDMA_CHANNEL_COUNT], } } } static STATE: State = State::new(); -macro_rules! dma_num { - (DMA1) => { - 0 - }; - (DMA2) => { - 1 - }; - (BDMA) => { - 0 - }; - (BDMA1) => { - 0 - }; - (BDMA2) => { - 1 - }; -} - pub(crate) unsafe fn on_irq() { - pac::peripherals! { + foreach_peripheral! { + (bdma, BDMA1) => { + // BDMA1 in H7 doesn't use DMAMUX, which breaks + }; (bdma, $dma:ident) => { - let isr = pac::$dma.isr().read(); - let dman = dma_num!($dma); - - for chn in 0..pac::dma_channels_count!($dma) { - let cr = pac::$dma.ch(chn).cr(); - if isr.tcif(chn) && cr.read().tcie() { + let isr = pac::$dma.isr().read(); + foreach_dma_channel! { + ($channel_peri:ident, $dma, bdma, $channel_num:expr, $index:expr, $dmamux:tt) => { + let cr = pac::$dma.ch($channel_num).cr(); + if isr.tcif($channel_num) && cr.read().tcie() { cr.write(|_| ()); // Disable channel interrupts with the default value. - let n = dma_num!($dma) * 8 + chn; - STATE.ch_wakers[n].wake(); + STATE.ch_wakers[$index].wake(); } - } + }; + } }; } } /// safety: must be called only once pub(crate) unsafe fn init() { - pac::interrupts! { + foreach_interrupt! { ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { crate::interrupt::$irq::steal().enable(); }; @@ -85,20 +68,20 @@ pub(crate) unsafe fn init() { crate::generated::init_bdma(); } -pac::dma_channels! { - ($channel_peri:ident, BDMA1, bdma, $channel_num:expr, $dmamux:tt) => { +foreach_dma_channel! { + ($channel_peri:ident, BDMA1, bdma, $channel_num:expr, $index:expr, $dmamux:tt) => { // BDMA1 in H7 doesn't use DMAMUX, which breaks }; - ($channel_peri:ident, $dma_peri:ident, bdma, $channel_num:expr, $dmamux:tt) => { + ($channel_peri:ident, $dma_peri:ident, bdma, $channel_num:expr, $index:expr, $dmamux:tt) => { impl crate::dma::sealed::Channel for crate::peripherals::$channel_peri { - unsafe fn start_write(&mut self, request: Request, buf: *const[W], reg_addr: *mut W) { + unsafe fn start_write(&mut self, _request: Request, buf: *const[W], reg_addr: *mut W) { let (ptr, len) = super::slice_ptr_parts(buf); low_level_api::start_transfer( pac::$dma_peri, $channel_num, #[cfg(any(bdma_v2, dmamux))] - request, + _request, vals::Dir::FROMMEMORY, reg_addr as *const u32, ptr as *mut u32, @@ -113,13 +96,13 @@ pac::dma_channels! { } - unsafe fn start_write_repeated(&mut self, request: Request, repeated: W, count: usize, reg_addr: *mut W) { + unsafe fn start_write_repeated(&mut self, _request: Request, repeated: W, count: usize, reg_addr: *mut W) { let buf = [repeated]; low_level_api::start_transfer( pac::$dma_peri, $channel_num, #[cfg(any(bdma_v2, dmamux))] - request, + _request, vals::Dir::FROMMEMORY, reg_addr as *const u32, buf.as_ptr() as *mut u32, @@ -133,13 +116,13 @@ pac::dma_channels! { ) } - unsafe fn start_read(&mut self, request: Request, reg_addr: *const W, buf: *mut [W]) { + unsafe fn start_read(&mut self, _request: Request, reg_addr: *const W, buf: *mut [W]) { let (ptr, len) = super::slice_ptr_parts_mut(buf); low_level_api::start_transfer( pac::$dma_peri, $channel_num, #[cfg(any(bdma_v2, dmamux))] - request, + _request, vals::Dir::FROMPERIPHERAL, reg_addr as *const u32, ptr as *mut u32, @@ -165,7 +148,7 @@ pac::dma_channels! { } fn set_waker(&mut self, waker: &Waker) { - unsafe {low_level_api::set_waker(dma_num!($dma_peri) * 8 + $channel_num, waker )} + unsafe { low_level_api::set_waker($index, waker) } } } diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index c885452b..fd1732fb 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs @@ -4,14 +4,13 @@ use core::task::Waker; use embassy::interrupt::{Interrupt, InterruptExt}; use embassy::waitqueue::AtomicWaker; +use crate::generated::DMA_CHANNEL_COUNT; use crate::interrupt; use crate::pac; use crate::pac::dma::{regs, vals}; use super::{Request, Word, WordSize}; -const CH_COUNT: usize = pac::peripheral_count!(DMA) * 8; - impl From for vals::Size { fn from(raw: WordSize) -> Self { match raw { @@ -23,44 +22,31 @@ impl From for vals::Size { } struct State { - ch_wakers: [AtomicWaker; CH_COUNT], + ch_wakers: [AtomicWaker; DMA_CHANNEL_COUNT], } impl State { const fn new() -> Self { const AW: AtomicWaker = AtomicWaker::new(); Self { - ch_wakers: [AW; CH_COUNT], + ch_wakers: [AW; DMA_CHANNEL_COUNT], } } } static STATE: State = State::new(); -macro_rules! dma_num { - (DMA1) => { - 0 - }; - (DMA2) => { - 1 - }; -} - pub(crate) unsafe fn on_irq() { - pac::peripherals! { + foreach_peripheral! { (dma, $dma:ident) => { - for isrn in 0..2 { - let isr = pac::$dma.isr(isrn).read(); - - for chn in 0..4 { - let cr = pac::$dma.st(isrn * 4 + chn).cr(); - - if isr.tcif(chn) && cr.read().tcie() { + foreach_dma_channel! { + ($channel_peri:ident, $dma, dma, $channel_num:expr, $index:expr, $dmamux:tt) => { + let cr = pac::$dma.st($channel_num).cr(); + if pac::$dma.isr($channel_num/4).read().tcif($channel_num%4) && cr.read().tcie() { cr.write(|_| ()); // Disable channel interrupts with the default value. - let n = dma_num!($dma) * 8 + isrn * 4 + chn; - STATE.ch_wakers[n].wake(); + STATE.ch_wakers[$index].wake(); } - } + }; } }; } @@ -68,7 +54,7 @@ pub(crate) unsafe fn on_irq() { /// safety: must be called only once pub(crate) unsafe fn init() { - pac::interrupts! { + foreach_interrupt! { ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { interrupt::$irq::steal().enable(); }; @@ -76,8 +62,8 @@ pub(crate) unsafe fn init() { crate::generated::init_dma(); } -pac::dma_channels! { - ($channel_peri:ident, $dma_peri:ident, dma, $channel_num:expr, $dmamux:tt) => { +foreach_dma_channel! { + ($channel_peri:ident, $dma_peri:ident, dma, $channel_num:expr, $index:expr, $dmamux:tt) => { impl crate::dma::sealed::Channel for crate::peripherals::$channel_peri { unsafe fn start_write(&mut self, request: Request, buf: *const [W], reg_addr: *mut W) { let (ptr, len) = super::slice_ptr_parts(buf); @@ -149,7 +135,7 @@ pac::dma_channels! { } fn set_waker(&mut self, waker: &Waker) { - unsafe {low_level_api::set_waker(dma_num!($dma_peri) * 8 + $channel_num, waker )} + unsafe {low_level_api::set_waker($index, waker )} } } diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index 971695a0..628f496b 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs @@ -35,8 +35,8 @@ pub trait MuxChannel: sealed::MuxChannel + super::Channel { type Mux; } -pac::dma_channels! { - ($channel_peri:ident, $dma_peri:ident, $version:ident, $channel_num:expr, {dmamux: $dmamux:ident, dmamux_channel: $dmamux_channel:expr}) => { +foreach_dma_channel! { + ($channel_peri:ident, $dma_peri:ident, $version:ident, $channel_num:expr, $index:expr, {dmamux: $dmamux:ident, dmamux_channel: $dmamux_channel:expr}) => { impl sealed::MuxChannel for peripherals::$channel_peri { const DMAMUX_CH_NUM: u8 = $dmamux_channel; const DMAMUX_REGS: pac::dmamux::Dmamux = pac::$dmamux; diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 909d0ee8..47307530 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -278,7 +278,7 @@ impl<'a> Future for ExtiInputFuture<'a> { macro_rules! foreach_exti_irq { ($action:ident) => { - crate::pac::interrupts!( + foreach_interrupt!( (EXTI0) => { $action!(EXTI0); }; (EXTI1) => { $action!(EXTI1); }; (EXTI2) => { $action!(EXTI2); }; diff --git a/embassy-stm32/src/fmc/mod.rs b/embassy-stm32/src/fmc/mod.rs index a17b88ea..2a730f5f 100644 --- a/embassy-stm32/src/fmc/mod.rs +++ b/embassy-stm32/src/fmc/mod.rs @@ -127,7 +127,7 @@ impl<'d, T: Instance> Fmc<'d, T> { )); } -crate::pac::peripherals!( +foreach_peripheral!( (fmc, $inst:ident) => { impl crate::fmc::sealed::Instance for crate::peripherals::$inst { fn regs() -> stm32_metapac::fmc::Fmc { diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index aef8ee55..4837c412 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -558,7 +558,7 @@ impl sealed::Pin for AnyPin { // ==================== -crate::pac::pins!( +foreach_pin!( ($pin_name:ident, $port_name:ident, $port_num:expr, $pin_num:expr, $exti_ch:ident) => { impl Pin for peripherals::$pin_name { #[cfg(feature = "exti")] diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index 7fc4f044..c2a4c254 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs @@ -37,7 +37,7 @@ pin_trait!(SdaPin, Instance); dma_trait!(RxDma, Instance); dma_trait!(TxDma, Instance); -crate::pac::interrupts!( +foreach_interrupt!( ($inst:ident, i2c, $block:ident, EV, $irq:ident) => { impl sealed::Instance for peripherals::$inst { fn regs() -> crate::pac::i2c::I2c { diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 0a3a14f5..5e8d6dd8 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -11,6 +11,7 @@ pub(crate) use stm32_metapac as pac; // This must go FIRST so that all the other modules see its macros. pub mod fmt; +include!(concat!(env!("OUT_DIR"), "/macros.rs")); // Utilities pub mod interrupt; @@ -62,7 +63,7 @@ pub mod usb_otg; pub mod subghz; // This must go last, so that it sees all the impl_foo! macros defined earlier. -mod generated { +pub(crate) mod generated { #![allow(dead_code)] #![allow(unused_imports)] diff --git a/embassy-stm32/src/pwm/mod.rs b/embassy-stm32/src/pwm/mod.rs index edc34fa5..e8938ffa 100644 --- a/embassy-stm32/src/pwm/mod.rs +++ b/embassy-stm32/src/pwm/mod.rs @@ -127,7 +127,7 @@ macro_rules! impl_compare_capable_16bit { }; } -crate::pac::interrupts! { +foreach_interrupt! { ($inst:ident, timer, TIM_GP16, UP, $irq:ident) => { impl crate::pwm::sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { unsafe fn set_output_compare_mode( diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 032fee01..0a93951b 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs @@ -136,7 +136,7 @@ pub(crate) mod sealed { pub trait Instance: sealed::Instance + crate::rcc::RccPeripheral {} -crate::pac::peripherals!( +foreach_peripheral!( (rng, $inst:ident) => { impl Instance for peripherals::$inst {} @@ -165,7 +165,7 @@ macro_rules! irq { }; } -crate::pac::interrupts!( +foreach_interrupt!( (RNG) => { irq!(RNG); }; diff --git a/embassy-stm32/src/sdmmc/v2.rs b/embassy-stm32/src/sdmmc/v2.rs index 1f4c9db7..cb8fa554 100644 --- a/embassy-stm32/src/sdmmc/v2.rs +++ b/embassy-stm32/src/sdmmc/v2.rs @@ -1271,7 +1271,7 @@ where } } -crate::pac::peripherals!( +foreach_peripheral!( (sdmmc, $inst:ident) => { impl sealed::Instance for peripherals::$inst { type Interrupt = crate::interrupt::$inst; diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index fe201414..e3b64728 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -874,7 +874,7 @@ pin_trait!(MisoPin, Instance); dma_trait!(RxDma, Instance); dma_trait!(TxDma, Instance); -crate::pac::peripherals!( +foreach_peripheral!( (spi, $inst:ident) => { impl sealed::Instance for peripherals::$inst { fn regs() -> &'static crate::pac::spi::Spi { diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 98054e05..009c6203 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -29,7 +29,7 @@ type T = peripherals::TIM4; #[cfg(time_driver_tim5)] type T = peripherals::TIM5; -crate::pac::interrupts! { +foreach_interrupt! { (TIM2, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim2)] #[interrupt] diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index e3389fba..4c1eb946 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs @@ -155,7 +155,7 @@ macro_rules! impl_32bit_timer { }; } -crate::pac::interrupts! { +foreach_interrupt! { ($inst:ident, timer, TIM_BASIC, UP, $irq:ident) => { impl_basic_16bit_timer!($inst, $irq); diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 12e5d503..60e60712 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -601,7 +601,7 @@ pin_trait!(CkPin, Instance); dma_trait!(TxDma, Instance); dma_trait!(RxDma, Instance); -crate::pac::interrupts!( +foreach_interrupt!( ($inst:ident, usart, $block:ident, $signal_name:ident, $irq:ident) => { impl sealed::Instance for peripherals::$inst { fn regs(&self) -> crate::pac::usart::Usart { diff --git a/embassy-stm32/src/usb_otg.rs b/embassy-stm32/src/usb_otg.rs index 6e08815d..8c2c1e99 100644 --- a/embassy-stm32/src/usb_otg.rs +++ b/embassy-stm32/src/usb_otg.rs @@ -135,7 +135,7 @@ pin_trait!(UlpiD5Pin, Instance); pin_trait!(UlpiD6Pin, Instance); pin_trait!(UlpiD7Pin, Instance); -crate::pac::peripherals!( +foreach_peripheral!( (otgfs, $inst:ident) => { impl sealed::Instance for peripherals::$inst { const REGISTERS: *const () = crate::pac::$inst.0 as *const (); @@ -223,7 +223,7 @@ crate::pac::peripherals!( }; ); -crate::pac::interrupts!( +foreach_interrupt!( ($inst:ident, otgfs, $block:ident, GLOBAL, $irq:ident) => { unsafe impl USBInterrupt for crate::interrupt::$irq {} };