From fde2dba309c4b6c74f1ffa645040b3b19b7965fb Mon Sep 17 00:00:00 2001 From: David Sawatzke Date: Tue, 1 Jan 2019 15:50:55 +0100 Subject: [PATCH 1/4] Move pin af definitions to a universal pin_mappings file For SPI & UART --- src/lib.rs | 2 + src/pin_mappings.rs | 111 +++++++++++++++++++++++++++++++ src/serial.rs | 159 -------------------------------------------- src/spi.rs | 110 ------------------------------ 4 files changed, 113 insertions(+), 269 deletions(-) create mode 100644 src/pin_mappings.rs diff --git a/src/lib.rs b/src/lib.rs index 510e1b4..e616ecc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,8 @@ pub mod gpio; #[cfg(feature = "device-selected")] pub mod i2c; #[cfg(feature = "device-selected")] +pub mod pin_mappings; +#[cfg(feature = "device-selected")] pub mod prelude; #[cfg(feature = "device-selected")] pub mod rcc; diff --git a/src/pin_mappings.rs b/src/pin_mappings.rs new file mode 100644 index 0000000..3d7a2a5 --- /dev/null +++ b/src/pin_mappings.rs @@ -0,0 +1,111 @@ +#[cfg(feature = "device-selected")] +use crate::gpio::gpioa::*; +#[cfg(feature = "device-selected")] +use crate::gpio::gpiob::*; +#[allow(unused)] +#[cfg(feature = "device-selected")] +use crate::gpio::gpioc::*; +#[cfg(feature = "stm32f030xc")] +use crate::gpio::gpiod::*; +#[allow(unused)] +use crate::gpio::{Alternate, AF0, AF1, AF2, AF4, AF5}; +use crate::serial::*; +use crate::spi::*; +#[cfg(feature = "device-selected")] +use crate::stm32::*; + +macro_rules! pins { + ($($PIN:ident => { + $($AF:ty: $TRAIT:ty),+ + }),+) => { + $( + $( + impl $TRAIT for $PIN> {} + )+ + )+ + } +} + +#[cfg(feature = "device-selected")] +pins! { + PA5 => {AF0: SckPin}, + PA6 => {AF0: MisoPin}, + PA7 => {AF0: MosiPin}, + PA9 => {AF1: TxPin}, + PA10 => {AF1: RxPin}, + PB3 => {AF0: SckPin}, + PB4 => {AF0: MisoPin}, + PB5 => {AF0: MosiPin}, + PB6 => {AF0: TxPin}, + PB7 => {AF0: RxPin} +} + +#[cfg(feature = "stm32f030x6")] +pins! { + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin}, + PB13 => {AF0: SckPin}, + PB14 => {AF0: MisoPin}, + PB15 => {AF0: MosiPin} +} + +#[cfg(any( + feature = "stm32f030x8", + feature = "stm32f030xc", + feature = "stm32f042", + feature = "stm32f070", +))] +pins! { + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin} +} + +#[cfg(any(feature = "stm32f030xc", feature = "stm32f070xb"))] +pins! { + PA0 => {AF4: TxPin}, + PA1 => {AF4: RxPin}, + PB10 => { + AF4: TxPin, + AF5: SckPin + }, + PB11 => {AF4: RxPin}, + PC2 => {AF1: MisoPin}, + PC3 => {AF1: MosiPin}, + PC4 => {AF1: TxPin}, + PC5 => {AF1: RxPin}, + PC10 => { + AF0: TxPin, + AF1: TxPin + }, + PC11 => { + AF0: RxPin, + AF1: RxPin + } +} + +#[cfg(feature = "stm32f030xc")] +pins! { + PA4 => {AF5: TxPin}, + PA5 => {AF5: RxPin}, + PB3 => {AF4: TxPin}, + PB4 => {AF4: RxPin}, + PC0 => {AF2: TxPin}, + PC1 => {AF2: RxPin}, + PC12 => {AF2: RxPin}, + PD2 => {AF2: TxPin} +} + +#[cfg(any( + feature = "stm32f030x8", + feature = "stm32f030xc", + feature = "stm32f070xb" +))] +pins! { + PB13 => {AF0: SckPin}, + PB14 => {AF0: MisoPin}, + PB15 => {AF0: MosiPin} +} diff --git a/src/serial.rs b/src/serial.rs index 504bf6a..701870a 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -98,165 +98,6 @@ pub enum Event { pub trait TxPin {} pub trait RxPin {} -macro_rules! usart_pins { - ($($USART:ident => { - tx => [$($tx:ty),+ $(,)*], - rx => [$($rx:ty),+ $(,)*], - })+) => { - $( - $( - impl TxPin for $tx {} - )+ - $( - impl RxPin for $rx {} - )+ - )+ - } -} - -#[cfg(any( - feature = "stm32f030", - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -usart_pins! { - USART1 => { - tx => [gpioa::PA9>, gpiob::PB6>], - rx => [gpioa::PA10>, gpiob::PB7>], - } -} -#[cfg(any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f031", - feature = "stm32f038", -))] -usart_pins! { - USART1 => { - tx => [gpioa::PA2>, gpioa::PA14>], - rx => [gpioa::PA3>, gpioa::PA15>], - } -} - -#[cfg(any( - feature = "stm32f030x8", - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -usart_pins! { - USART2 => { - tx => [gpioa::PA2>, gpioa::PA14>], - rx => [gpioa::PA3>, gpioa::PA15>], - } -} -#[cfg(any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -usart_pins! { - USART2 => { - tx => [gpiod::PD5>], - rx => [gpiod::PD6>], - } -} - -#[cfg(any( - feature = "stm32f030xc", - feature = "stm32f070xb", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -usart_pins! { - USART3 => { - // According to the datasheet PB10 is both tx and rx, but in stm32cubemx it's only tx - tx => [gpiob::PB10>, gpioc::PC4>, gpioc::PC10>], - rx => [gpiob::PB11>, gpioc::PC5>, gpioc::PC11>], - } - USART4 => { - tx => [gpioa::PA0>, gpioc::PC10>], - rx => [gpioa::PA1>, gpioc::PC11>], - } -} -#[cfg(any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -usart_pins! { - USART3 => { - tx => [gpiod::PD8>], - rx => [gpiod::PD9>], - } -} -// TODO: The ST SVD files are missing the entire PE enable register. -// Re-enable as soon as this gets fixed. -// #[cfg(any(feature = "stm32f091", feature = "stm32f098"))] -// usart_pins! { -// USART4 => { -// tx => [gpioe::PE8>], -// rx => [gpioe::PE9>], -// } -// } - -#[cfg(any(feature = "stm32f030xc", feature = "stm32f091", feature = "stm32f098"))] -usart_pins! { - USART5 => { - tx => [gpioc::PC12>], - rx => [gpiod::PD2>], - } - USART6 => { - tx => [gpioa::PA4>, gpioc::PC0>], - rx => [gpioa::PA5>, gpioc::PC1>], - } -} -#[cfg(any(feature = "stm32f030xc", feature = "stm32f091"))] -usart_pins! { - USART5 => { - tx => [gpiob::PB3>], - rx => [gpiob::PB4>], - } -} -// TODO: The ST SVD files are missing the entire PE enable register. -// Re-enable as soon as this gets fixed. -#[cfg(any(feature = "stm32f091", feature = "stm32f098"))] -usart_pins! { - // USART5 => { - // tx => [gpioe::PE10>], - // rx => [gpioe::PE11>], - // } - USART6 => { - tx => [gpiof::PF9>], - rx => [gpiof::PF10>], - } -} - /// Serial abstraction pub struct Serial { usart: USART, diff --git a/src/spi.rs b/src/spi.rs index 7ed5c1b..96b0963 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -91,116 +91,6 @@ pub trait SckPin {} pub trait MisoPin {} pub trait MosiPin {} -macro_rules! spi_pins { - ($($SPI:ident => { - sck => [$($sck:ty),+ $(,)*], - miso => [$($miso:ty),+ $(,)*], - mosi => [$($mosi:ty),+ $(,)*], - })+) => { - $( - $( - impl SckPin for $sck {} - )+ - $( - impl MisoPin for $miso {} - )+ - $( - impl MosiPin for $mosi {} - )+ - )+ - } -} - -spi_pins! { - SPI1 => { - sck => [gpioa::PA5>, gpiob::PB3>], - miso => [gpioa::PA6>, gpiob::PB4>], - mosi => [gpioa::PA7>, gpiob::PB5>], - } -} -#[cfg(any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f031", - feature = "stm32f038", -))] -spi_pins! { - SPI1 => { - sck => [gpiob::PB13>], - miso => [gpiob::PB14>], - mosi => [gpiob::PB15>], - } -} -// TODO: The ST SVD files are missing the entire PE enable register. -// So those pins do not exist in the register definitions. -// Re-enable as soon as this gets fixed. -// #[cfg(any( -// feature = "stm32f071", -// feature = "stm32f072", -// feature = "stm32f078", -// feature = "stm32f091", -// feature = "stm32f098", -// ))] -// spi_pins! { -// SPI1 => { -// sck => [gpioe::PE13>], -// miso => [gpioe::PE14>], -// mosi => [gpioe::PE15>], -// } -// } - -#[cfg(any( - feature = "stm32f030x8", - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070xb", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -spi_pins! { - SPI2 => { - sck => [gpiob::PB13>], - miso => [gpiob::PB14>], - mosi => [gpiob::PB15>], - } -} -#[cfg(any( - feature = "stm32f030xc", - feature = "stm32f070xb", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -spi_pins! { - SPI2 => { - sck => [gpiob::PB10>], - miso => [gpioc::PC2>], - mosi => [gpioc::PC3>], - } -} -#[cfg(any( - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -spi_pins! { - SPI2 => { - sck => [gpiod::PD1>], - miso => [gpiod::PD3>], - mosi => [gpiod::PD4>], - } -} - macro_rules! spi { ($($SPI:ident: ($spi:ident, $spiXen:ident, $spiXrst:ident, $apbenr:ident, $apbrstr:ident),)+) => { $( From 221ef9092d8d73827b7b4316db4aeff66360fffe Mon Sep 17 00:00:00 2001 From: David Sawatzke Date: Tue, 1 Jan 2019 16:39:27 +0100 Subject: [PATCH 2/4] Move i2c mappings to pin_mappings --- src/i2c.rs | 128 -------------------------------------------- src/pin_mappings.rs | 66 ++++++++++++++++++++++- 2 files changed, 64 insertions(+), 130 deletions(-) diff --git a/src/i2c.rs b/src/i2c.rs index 60c738e..d7e33d4 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -17,134 +17,6 @@ pub struct I2c { pub trait SclPin {} pub trait SdaPin {} -macro_rules! i2c_pins { - ($($I2C:ident => { - scl => [$($scl:ty),+ $(,)*], - sda => [$($sda:ty),+ $(,)*], - })+) => { - $( - $( - impl SclPin for $scl {} - )+ - $( - impl SdaPin for $sda {} - )+ - )+ - } -} - -#[cfg(any( - feature = "stm32f030", - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f051", - feature = "stm32f058", - feature = "stm32f070", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -i2c_pins! { - I2C1 => { - scl => [gpiob::PB6>, gpiob::PB8>], - sda => [gpiob::PB7>, gpiob::PB9>], - } -} -#[cfg(any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f030xc", - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f070x6", - feature = "stm32f091", - feature = "stm32f098", -))] -i2c_pins! { - I2C1 => { - scl => [gpioa::PA9>], - sda => [gpioa::PA10>], - } -} -#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f048"))] -i2c_pins! { - I2C1 => { - scl => [gpioa::PA11>], - sda => [gpioa::PA12>], - } -} -#[cfg(any( - feature = "stm32f030x4", - feature = "stm32f030x6", - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f042", - feature = "stm32f048", -))] -i2c_pins! { - I2C1 => { - scl => [gpiob::PB10>], - sda => [gpiob::PB11>], - } -} -#[cfg(any(feature = "stm32f030xc", feature = "stm32f042", feature = "stm32f048"))] -i2c_pins! { - I2C1 => { - scl => [gpiob::PB13>], - sda => [gpiob::PB14>], - } -} -#[cfg(any( - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f048", - feature = "stm32f070x6", - feature = "stm32f091", - feature = "stm32f098", -))] -i2c_pins! { - I2C1 => { - scl => [gpiof::PF1>], - sda => [gpiof::PF0>], - } -} - -#[cfg(any(feature = "stm32f030x8", feature = "stm32f051", feature = "stm32f058"))] -i2c_pins! { - I2C2 => { - scl => [gpiob::PB10>], - sda => [gpiob::PB11>], - } -} -#[cfg(any( - feature = "stm32f030xc", - feature = "stm32f070xb", - feature = "stm32f071", - feature = "stm32f072", - feature = "stm32f078", - feature = "stm32f091", - feature = "stm32f098", -))] -i2c_pins! { - I2C2 => { - scl => [gpiob::PB10>, gpiob::PB13>], - sda => [gpiob::PB11>, gpiob::PB14>], - } -} -#[cfg(any(feature = "stm32f091", feature = "stm32f098"))] -i2c_pins! { - I2C2 => { - scl => [gpioa::PA11>], - sda => [gpioa::PA12>], - } -} - #[derive(Debug)] pub enum Error { OVERRUN, diff --git a/src/pin_mappings.rs b/src/pin_mappings.rs index 3d7a2a5..4d3b183 100644 --- a/src/pin_mappings.rs +++ b/src/pin_mappings.rs @@ -8,7 +8,11 @@ use crate::gpio::gpioc::*; #[cfg(feature = "stm32f030xc")] use crate::gpio::gpiod::*; #[allow(unused)] +#[cfg(feature = "device-selected")] +use crate::gpio::gpiof::*; +#[allow(unused)] use crate::gpio::{Alternate, AF0, AF1, AF2, AF4, AF5}; +use crate::i2c::*; use crate::serial::*; use crate::spi::*; #[cfg(feature = "device-selected")] @@ -36,8 +40,22 @@ pins! { PB3 => {AF0: SckPin}, PB4 => {AF0: MisoPin}, PB5 => {AF0: MosiPin}, - PB6 => {AF0: TxPin}, - PB7 => {AF0: RxPin} + PB6 => { + AF0: TxPin, + AF1: SclPin + }, + PB7 => { + AF0: RxPin, + AF1: SdaPin + }, + PB8 => {AF1: SclPin}, + PB9 => {AF1: SdaPin} +} + +#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +pins! { + PA11 => {AF5: SclPin}, + PA12 => {AF5: SdaPin} } #[cfg(feature = "stm32f030x6")] @@ -109,3 +127,47 @@ pins! { PB14 => {AF0: MisoPin}, PB15 => {AF0: MosiPin} } + +#[cfg(any( + feature = "stm32f030x6", + feature = "stm32f030xc", + feature = "stm32f042", + feature = "stm32f070x6", +))] +pins! { + PA9 => {AF4: SclPin}, + PA10 => {AF4: SdaPin} +} + +#[cfg(any( + feature = "stm32f042", + feature = "stm32f030x6", + feature = "stm32f030x8", + feature = "stm32f030xc", + feature = "stm32f070xb" +))] +pins! { + PB10 => {AF1: SclPin}, + PB11 => {AF1: SdaPin} +} + +#[cfg(any( + feature = "stm32f042", + feature = "stm32f030xc", + feature = "stm32f070x6", +))] +pins! { + PF1 => {AF1: SclPin}, + PF0 => {AF1: SdaPin} +} + +#[cfg(any( + feature = "stm32f042", + feature = "stm32f030xc", + feature = "stm32f030xc", + feature = "stm32f070xb" +))] +pins! { + PB13 => {AF5: SclPin}, + PB14 => {AF5: SdaPin} +} From be3604f962b65ba95c44a2d0aa38241fef7b2cf7 Mon Sep 17 00:00:00 2001 From: David Sawatzke Date: Tue, 1 Jan 2019 17:39:36 +0100 Subject: [PATCH 3/4] Fix the mappings a bit --- src/pin_mappings.rs | 67 +++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/pin_mappings.rs b/src/pin_mappings.rs index 4d3b183..0858775 100644 --- a/src/pin_mappings.rs +++ b/src/pin_mappings.rs @@ -5,7 +5,7 @@ use crate::gpio::gpiob::*; #[allow(unused)] #[cfg(feature = "device-selected")] use crate::gpio::gpioc::*; -#[cfg(feature = "stm32f030xc")] +#[cfg(feature = "stm32f030")] use crate::gpio::gpiod::*; #[allow(unused)] #[cfg(feature = "device-selected")] @@ -58,31 +58,7 @@ pins! { PA12 => {AF5: SdaPin} } -#[cfg(feature = "stm32f030x6")] -pins! { - PA2 => {AF1: TxPin}, - PA3 => {AF1: RxPin}, - PA14 => {AF1: TxPin}, - PA15 => {AF1: RxPin}, - PB13 => {AF0: SckPin}, - PB14 => {AF0: MisoPin}, - PB15 => {AF0: MosiPin} -} - -#[cfg(any( - feature = "stm32f030x8", - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f070", -))] -pins! { - PA2 => {AF1: TxPin}, - PA3 => {AF1: RxPin}, - PA14 => {AF1: TxPin}, - PA15 => {AF1: RxPin} -} - -#[cfg(any(feature = "stm32f030xc", feature = "stm32f070xb"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f070"))] pins! { PA0 => {AF4: TxPin}, PA1 => {AF4: RxPin}, @@ -105,7 +81,7 @@ pins! { } } -#[cfg(feature = "stm32f030xc")] +#[cfg(feature = "stm32f030")] pins! { PA4 => {AF5: TxPin}, PA5 => {AF5: RxPin}, @@ -117,6 +93,29 @@ pins! { PD2 => {AF2: TxPin} } +#[cfg(feature = "stm32f030x6")] +pins! { + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin}, + PB13 => {AF0: SckPin}, + PB14 => {AF0: MisoPin}, + PB15 => {AF0: MosiPin} +} + +#[cfg(any( + feature = "stm32f030x8", + feature = "stm32f030xc", + feature = "stm32f042", + feature = "stm32f070", +))] +pins! { + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin} +} #[cfg(any( feature = "stm32f030x8", feature = "stm32f030xc", @@ -132,7 +131,7 @@ pins! { feature = "stm32f030x6", feature = "stm32f030xc", feature = "stm32f042", - feature = "stm32f070x6", + feature = "stm32f070x6" ))] pins! { PA9 => {AF4: SclPin}, @@ -140,10 +139,8 @@ pins! { } #[cfg(any( - feature = "stm32f042", feature = "stm32f030x6", - feature = "stm32f030x8", - feature = "stm32f030xc", + feature = "stm32f042", feature = "stm32f070xb" ))] pins! { @@ -151,20 +148,24 @@ pins! { PB11 => {AF1: SdaPin} } +#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))] +pins! { + PB10 => {AF1: SclPin}, + PB11 => {AF1: SdaPin} +} #[cfg(any( feature = "stm32f042", feature = "stm32f030xc", feature = "stm32f070x6", ))] pins! { - PF1 => {AF1: SclPin}, PF0 => {AF1: SdaPin} + PF1 => {AF1: SclPin}, } #[cfg(any( feature = "stm32f042", feature = "stm32f030xc", - feature = "stm32f030xc", feature = "stm32f070xb" ))] pins! { From 70121a494b365cd5d2928d6a113dadbec9ded19c Mon Sep 17 00:00:00 2001 From: David Sawatzke Date: Tue, 1 Jan 2019 18:33:23 +0100 Subject: [PATCH 4/4] Implement specific pin bindings as subsets of families --- src/pin_mappings.rs | 135 ++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 61 deletions(-) diff --git a/src/pin_mappings.rs b/src/pin_mappings.rs index 0858775..1ea75e3 100644 --- a/src/pin_mappings.rs +++ b/src/pin_mappings.rs @@ -52,16 +52,16 @@ pins! { PB9 => {AF1: SdaPin} } -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] -pins! { - PA11 => {AF5: SclPin}, - PA12 => {AF5: SdaPin} -} - -#[cfg(any(feature = "stm32f030", feature = "stm32f070"))] +#[cfg(feature = "stm32f030")] pins! { PA0 => {AF4: TxPin}, PA1 => {AF4: RxPin}, + PA4 => {AF5: TxPin}, + PA5 => {AF5: RxPin}, + PA11 => {AF5: SclPin}, + PA12 => {AF5: SdaPin}, + PB3 => {AF4: TxPin}, + PB4 => {AF4: RxPin}, PB10 => { AF4: TxPin, AF5: SckPin @@ -78,15 +78,7 @@ pins! { PC11 => { AF0: RxPin, AF1: RxPin - } -} - -#[cfg(feature = "stm32f030")] -pins! { - PA4 => {AF5: TxPin}, - PA5 => {AF5: RxPin}, - PB3 => {AF4: TxPin}, - PB4 => {AF4: RxPin}, + }, PC0 => {AF2: TxPin}, PC1 => {AF2: RxPin}, PC12 => {AF2: RxPin}, @@ -97,78 +89,99 @@ pins! { pins! { PA2 => {AF1: TxPin}, PA3 => {AF1: RxPin}, + PA9 => {AF4: SclPin}, + PA10 => {AF4: SdaPin}, PA14 => {AF1: TxPin}, PA15 => {AF1: RxPin}, + PB10 => {AF1: SclPin}, + PB11 => {AF1: SdaPin}, PB13 => {AF0: SckPin}, PB14 => {AF0: MisoPin}, PB15 => {AF0: MosiPin} } -#[cfg(any( - feature = "stm32f030x8", - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f070", -))] +#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))] pins! { PA2 => {AF1: TxPin}, PA3 => {AF1: RxPin}, PA14 => {AF1: TxPin}, - PA15 => {AF1: RxPin} -} -#[cfg(any( - feature = "stm32f030x8", - feature = "stm32f030xc", - feature = "stm32f070xb" -))] -pins! { + PA15 => {AF1: RxPin}, + PB10 => {AF1: SclPin}, + PB11 => {AF1: SdaPin}, PB13 => {AF0: SckPin}, PB14 => {AF0: MisoPin}, PB15 => {AF0: MosiPin} } -#[cfg(any( - feature = "stm32f030x6", - feature = "stm32f030xc", - feature = "stm32f042", - feature = "stm32f070x6" -))] +#[cfg(any(feature = "stm32f030xc",))] pins! { PA9 => {AF4: SclPin}, - PA10 => {AF4: SdaPin} + PA10 => {AF4: SdaPin}, + PB13 => {AF5: SclPin}, + PB14 => {AF5: SdaPin}, + PF0 => {AF1: SdaPin}, + PF1 => {AF1: SclPin} } -#[cfg(any( - feature = "stm32f030x6", - feature = "stm32f042", - feature = "stm32f070xb" -))] +#[cfg(feature = "stm32f042")] pins! { + PA11 => {AF5: SclPin}, + PA12 => {AF5: SdaPin}, + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA9 => {AF4: SclPin}, + PA10 => {AF4: SdaPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin}, PB10 => {AF1: SclPin}, - PB11 => {AF1: SdaPin} + PB11 => {AF1: SdaPin}, + PB13 => {AF5: SclPin}, + PB14 => {AF5: SdaPin}, + PF0 => {AF1: SdaPin}, + PF1 => {AF1: SclPin} } -#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))] +#[cfg(feature = "stm32f070")] pins! { - PB10 => {AF1: SclPin}, - PB11 => {AF1: SdaPin} -} -#[cfg(any( - feature = "stm32f042", - feature = "stm32f030xc", - feature = "stm32f070x6", -))] -pins! { - PF0 => {AF1: SdaPin} - PF1 => {AF1: SclPin}, + PA0 => {AF4: TxPin}, + PA1 => {AF4: RxPin}, + PA2 => {AF1: TxPin}, + PA3 => {AF1: RxPin}, + PA14 => {AF1: TxPin}, + PA15 => {AF1: RxPin}, + PB10 => { + AF4: TxPin, + AF5: SckPin + }, + PB11 => {AF4: RxPin}, + PC2 => {AF1: MisoPin}, + PC3 => {AF1: MosiPin}, + PC4 => {AF1: TxPin}, + PC5 => {AF1: RxPin}, + PC10 => { + AF0: TxPin, + AF1: TxPin + }, + PC11 => { + AF0: RxPin, + AF1: RxPin + } } -#[cfg(any( - feature = "stm32f042", - feature = "stm32f030xc", - feature = "stm32f070xb" -))] +#[cfg(feature = "stm32f070xb")] pins! { + PB10 => {AF1: SclPin}, + PB11 => {AF1: SdaPin}, + PB13 => {AF0: SckPin}, + PB14 => {AF0: MisoPin}, PB13 => {AF5: SclPin}, - PB14 => {AF5: SdaPin} + PB14 => {AF5: SdaPin}, + PB15 => {AF0: MosiPin} +} +#[cfg(feature = "stm32f070x6")] +pins! { + PA9 => {AF4: SclPin}, + PA10 => {AF4: SdaPin}, + PF0 => {AF1: SdaPin}, + PF1 => {AF1: SclPin} }