Skip to content

Commit

Permalink
beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 9, 2024
1 parent 36aecc8 commit 587dbad
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 65 deletions.
10 changes: 5 additions & 5 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub mod can1 {

remap! {
pac::CAN1: [
PA12, PA11 => 0;
PB9, PB8 => 2;
Tx: PA12, Rx: PA11 => 0;
Tx: PB9, Rx: PB8 => 2;
]
}
}
Expand All @@ -58,14 +58,14 @@ pub mod can2 {

remap! {
pac::CAN2: [
PB6, PB5 => 0;
PB13, PB12 => 1;
Tx: PB6, Rx: PB5 => 0;
Tx: PB13, Rx: PB12 => 1;
]
}
}

macro_rules! remap {
($PER:ty: [$($TX:ident, $RX:ident => $remap:literal;)+]) => {
($PER:ty: [$(Tx: $TX:ident, Rx: $RX:ident => $remap:literal;)+]) => {
pub enum Tx {
$(
$TX(gpio::$TX<Alternate>),
Expand Down
8 changes: 4 additions & 4 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ pub mod i2c1 {

remap! {
pac::I2C1: [
PB6, PB7 => MAPR: 0;
PB8, PB9 => MAPR: 1;
Scl: PB6, Sda: PB7 => MAPR: 0;
Scl: PB8, Sda: PB9 => MAPR: 1;
]
}
}
Expand All @@ -115,14 +115,14 @@ pub mod i2c2 {

remap! {
pac::I2C2: [
PB10, PB11;
Scl: PB10, Sda: PB11;
]
}
}

macro_rules! remap {
($PER:ty: [
$($SCL:ident, $SDA:ident $( => $MAPR:ident: $remap:literal)?;)+
$(Scl: $SCL:ident, Sda: $SDA:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
pub enum Scl {
$(
Expand Down
16 changes: 8 additions & 8 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub mod usart1 {

remap! {
pac::USART1: [
PA9, PA10 => 0;
PB6, PB7 => 1;
Tx: PA9, Rx: PA10 => 0;
Tx: PB6, Rx: PB7 => 1;
]
}
}
Expand All @@ -112,8 +112,8 @@ pub mod usart2 {

remap! {
pac::USART2: [
PA2, PA3 => 0;
PD5, PD6 => 1;
Tx: PA2, Rx: PA3 => 0;
Tx: PD5, Rx: PD6 => 1;
]
}
}
Expand All @@ -123,15 +123,15 @@ pub mod usart3 {

remap! {
pac::USART3: [
PB10, PB11 => 0;
PC10, PC11 => 1;
PD8, PD9 => 3;
Tx: PB10, Rx: PB11 => 0;
Tx: PC10, Rx: PC11 => 1;
Tx: PD8, Rx: PD9 => 3;
]
}
}

macro_rules! remap {
($PER:ty: [$($TX:ident, $RX:ident => $remap:literal;)+]) => {
($PER:ty: [$(Tx: $TX:ident, Rx: $RX:ident => $remap:literal;)+]) => {
pub enum Tx<Otype> {
$(
$TX(gpio::$TX<Alternate<Otype>>),
Expand Down
14 changes: 7 additions & 7 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ pub mod spi1 {

remap! {
pac::SPI1: [
PA5, PA6, PA7 => MAPR: 0;
PB3, PB4, PB5 => MAPR: 1;
Sck: PA5, Miso: PA6, Mosi: PA7 => MAPR: 0;
Sck: PB3, Miso: PB4, Mosi: PB5 => MAPR: 1;
]
}
}
Expand All @@ -135,7 +135,7 @@ pub mod spi2 {

remap! {
pac::SPI2: [
PB13, PB14, PB15;
Sck: PB13, Miso: PB14, Mosi: PB15;
]
}
}
Expand All @@ -146,21 +146,21 @@ pub mod spi3 {
#[cfg(not(feature = "connectivity"))]
remap! {
pac::SPI3: [
PB3, PB4, PB5;
Sck: PB3, Miso: PB4, Mosi: PB5;
]
}
#[cfg(feature = "connectivity")]
remap! {
pac::SPI3: [
PB3, PB4, PB5 => MAPR: 0;
PC10, PC11, PC12 => MAPR: 1;
Sck: PB3, Miso: PB4, Mosi: PB5 => MAPR: 0;
Sck: PC10, Miso: PC11, Mosi: PC12 => MAPR: 1;
]
}
}

macro_rules! remap {
($PER:ty: [
$($SCK:ident, $MISO:ident, $MOSI:ident $( => $MAPR:ident: $remap:literal)?;)+
$(Sck: $SCK:ident, Miso: $MISO:ident, Mosi: $MOSI:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
pub enum Sck {
$(
Expand Down
82 changes: 41 additions & 41 deletions src/timer/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ pub mod tim1 {

remap4! {
pac::TIM1: [
PA8, PA9, PA10, PA11 => MAPR: 0;
PE9, PE11, PE13, PE14 => MAPR: 3;
C1: PA8, C2: PA9, C3: PA10, C4: PA11 => MAPR: 0;
C1: PE9, C2: PE11, C3: PE13, C4: PE14 => MAPR: 3;
]
}
remap12! {
pac::TIM1: [
PA8, PA9 => MAPR: 0;
PE9, PE11 => MAPR: 3;
C1: PA8, C2: PA9 => MAPR: 0;
C1: PE9, C2: PE11 => MAPR: 3;
]
}
remap_input! {
pac::TIM1: [
PA8, PA9 => MAPR: 0;
PE9, PE11 => MAPR: 3;
C1: PA8, C2: PA9 => MAPR: 0;
C1: PE9, C2: PE11 => MAPR: 3;
]
}
remap34! {
pac::TIM1: [
PA10, PA11 => MAPR: 0;
PE13, PE14 => MAPR: 3;
C3: PA10, C4: PA11 => MAPR: 0;
C3: PE13, C4: PE14 => MAPR: 3;
]
}

Expand All @@ -109,28 +109,28 @@ pub mod tim2 {

remap4! {
pac::TIM2: [
PA0, PA1, PA2, PA3 => MAPR: 0;
PA15, PB3, PA2, PA3 => MAPR: 1;
PA0, PA1, PB10, PB11 => MAPR: 2;
PA15, PB3, PB10, PB11 => MAPR: 3;
C1: PA0, C2: PA1, C3: PA2, C4: PA3 => MAPR: 0;
C1: PA15, C2: PB3, C3: PA2, C4: PA3 => MAPR: 1;
C1: PA0, C2: PA1, C3: PB10, C4: PB11 => MAPR: 2;
C1: PA15, C2: PB3, C3: PB10, C4: PB11 => MAPR: 3;
]
}
remap12! {
pac::TIM2: [
PA0, PA1 => MAPR: 0;
PA15, PB3 => MAPR: 1;
C1: PA0, C2: PA1 => MAPR: 0;
C1: PA15, C2: PB3 => MAPR: 1;
]
}
remap_input! {
pac::TIM2: [
PA0, PA1 => MAPR: 0;
PA15, PB3 => MAPR: 1;
C1: PA0, C2: PA1 => MAPR: 0;
C1: PA15, C2: PB3 => MAPR: 1;
]
}
remap34! {
pac::TIM2: [
PA2, PA3 => MAPR: 0;
PB10, PB11 => MAPR: 2;
C3: PA2, C4: PA3 => MAPR: 0;
C3: PB10, C4: PB11 => MAPR: 2;
]
}

Expand All @@ -151,29 +151,29 @@ pub mod tim3 {

remap4! {
pac::TIM3: [
PA6, PA7, PB0, PB1 => MAPR: 0;
PB4, PB5, PB0, PB1 => MAPR: 2;
PC6, PC7, PC8, PC9 => MAPR: 3;
C1: PA6, C2: PA7, C3: PB0, C4: PB1 => MAPR: 0;
C1: PB4, C2: PB5, C3: PB0, C4: PB1 => MAPR: 2;
C1: PC6, C2: PC7, C3: PC8, C4: PC9 => MAPR: 3;
]
}
remap12! {
pac::TIM3: [
PA6, PA7 => MAPR: 0;
PB4, PB5 => MAPR: 2;
PC6, PC7 => MAPR: 3;
C1: PA6, C2: PA7 => MAPR: 0;
C1: PB4, C2: PB5 => MAPR: 2;
C1: PC6, C2: PC7 => MAPR: 3;
]
}
remap_input! {
pac::TIM3: [
PA6, PA7 => MAPR: 0;
PB4, PB5 => MAPR: 2;
PC6, PC7 => MAPR: 3;
C1: PA6, C2: PA7 => MAPR: 0;
C1: PB4, C2: PB5 => MAPR: 2;
C1: PC6, C2: PC7 => MAPR: 3;
]
}
remap34! {
pac::TIM3: [
PB0, PB1 => MAPR: 0;
PC8, PC9 => MAPR: 3;
C3: PB0, C4: PB1 => MAPR: 0;
C3: PC8, C4: PC9 => MAPR: 3;
]
}

Expand All @@ -195,26 +195,26 @@ pub mod tim4 {

remap4! {
pac::TIM4: [
PB6, PB7, PB8, PB9 => MAPR: 0;
PD12, PD13, PD14, PD15 => MAPR: 1;
C1: PB6, C2: PB7, C3: PB8, C4: PB9 => MAPR: 0;
C1: PD12, C2: PD13, C3: PD14, C4: PD15 => MAPR: 1;
]
}
remap12! {
pac::TIM4: [
PB6, PB7 => MAPR: 0;
PD12, PD13 => MAPR: 1;
C1: PB6, C2: PB7 => MAPR: 0;
C1: PD12, C2: PD13 => MAPR: 1;
]
}
remap_input! {
pac::TIM4: [
PB6, PB7 => MAPR: 0;
PD12, PD13 => MAPR: 1;
C1: PB6, C2: PB7 => MAPR: 0;
C1: PD12, C2: PD13 => MAPR: 1;
]
}
remap34! {
pac::TIM4: [
PB8, PB9 => MAPR: 0;
PD14, PD15 => MAPR: 1;
C3: PB8, C4: PB9 => MAPR: 0;
C3: PD14, C4: PD15 => MAPR: 1;
]
}

Expand Down Expand Up @@ -257,7 +257,7 @@ use in_enums;

macro_rules! remap4 {
($TIM:ty: [
$($P1:ident, $P2:ident, $P3:ident, $P4:ident $( => $MAPR:ident: $remap:literal)?;)+
$(C1: $P1:ident, C2: $P2:ident, C3: $P3:ident, C4: $P4:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
pub type Channels1234 = Pins4<Ch1, Ch2, Ch3, Ch4>;
remap_combo! {
Expand Down Expand Up @@ -319,7 +319,7 @@ use remap4;

macro_rules! remap12 {
($TIM:ty: [
$($P1:ident, $P2:ident $( => $MAPR:ident: $remap:literal)?;)+
$(C1: $P1:ident, C2: $P2:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
pub type Channels12 = Pins2<Ch1, Ch2>;
remap_combo! {
Expand All @@ -343,7 +343,7 @@ use remap12;

macro_rules! remap34 {
($TIM:ty: [
$($P1:ident, $P2:ident $( => $MAPR:ident: $remap:literal)?;)+
$(C3: $P1:ident, C4: $P2:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
pub type Channels34 = Pins2<Ch3, Ch4>;
remap_combo! {
Expand Down Expand Up @@ -492,7 +492,7 @@ pub trait Pins<TIM> {

macro_rules! remap_input {
($TIM:ty: [
$($P0:ident, $P1:ident $( => $MAPR:ident: $remap:literal)?;)+
$(C1: $P0:ident, C2: $P1:ident $( => $MAPR:ident: $remap:literal)?;)+
]) => {
impl InputPins for $TIM {
type InCh1 = InCh1;
Expand Down

0 comments on commit 587dbad

Please sign in to comment.