diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index f77e6860..abda196a 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs @@ -51,24 +51,24 @@ crate::pac::peripherals!( }; ); -crate::pac::peripheral_pins!( - ($inst:ident, i2c, I2C, $pin:ident, SDA, $af:expr) => { - impl SdaPin for peripherals::$pin {} +macro_rules! impl_pin { + ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { + impl $signal for peripherals::$pin {} - impl sealed::SdaPin for peripherals::$pin { + impl sealed::$signal for peripherals::$pin { fn af_num(&self) -> u8 { $af } } }; +} + +crate::pac::peripheral_pins!( + ($inst:ident, i2c, I2C, $pin:ident, SDA, $af:expr) => { + impl_pin!($inst, $pin, SdaPin, $af); + }; ($inst:ident, i2c, I2C, $pin:ident, SCL, $af:expr) => { - impl SclPin for peripherals::$pin {} - - impl sealed::SclPin for peripherals::$pin { - fn af_num(&self) -> u8 { - $af - } - } + impl_pin!($inst, $pin, SclPin, $af); }; );