From 3dd497c1e63bdf03c064ca58ef15cda51eb17146 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Thu, 3 Jun 2021 11:29:29 -0400 Subject: [PATCH] Refactor some I2c signal pin macro. --- embassy-stm32/src/i2c/mod.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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); }; );