Skip to content

Commit 42a078d

Browse files
committed
simplify pins_impl macro
1 parent b47449d commit 42a078d

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

src/timer/pwm.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,33 +155,38 @@ pub trait Pins<TIM>: sealed::Split {
155155
}
156156

157157
macro_rules! pins_impl {
158-
( $( ( $($Otype:ident),+ ), ( $($ENCHX:ident),+ ), ( $($COMP:ident),+ ); )+ ) => {
158+
( $( $(($Otype:ident, $ENCHX:ident, $COMP:ident)),+; )+ ) => {
159159
$(
160160
#[allow(unused_parens)]
161-
impl<TIM, $($Otype,)+ $(const $COMP: bool,)+> Pins<TIM> for ($(ChannelBuilder<TIM, $ENCHX, $COMP, $Otype>),+) {
162-
$(const $ENCHX: bool = true;)+
163-
$(const $COMP: bool = $COMP;)+
161+
impl<TIM, $($Otype, const $COMP: bool,)+> Pins<TIM> for ($(ChannelBuilder<TIM, $ENCHX, $COMP, $Otype>),+) {
162+
$(
163+
const $ENCHX: bool = true;
164+
const $COMP: bool = $COMP;
165+
)+
164166
}
165167
)+
166168
};
167169
}
168170

169171
pins_impl!(
170-
(P1, P2, P3, P4), (C1, C2, C3, C4), (NC1, NC2, NC3, NC4);
171-
(P2, P3, P4), (C2, C3, C4), (NC2, NC3, NC4);
172-
(P1, P3, P4), (C1, C3, C4), (NC1, NC3, NC4);
173-
(P1, P2, P4), (C1, C2, C4), (NC1, NC2, NC4);
174-
(P1, P2, P3), (C1, C2, C3), (NC1, NC2, NC3);
175-
(P3, P4), (C3, C4), (NC3, NC4);
176-
(P2, P4), (C2, C4), (NC2, NC4);
177-
(P2, P3), (C2, C3), (NC2, NC3);
178-
(P1, P4), (C1, C4), (NC1, NC4);
179-
(P1, P3), (C1, C3), (NC1, NC3);
180-
(P1, P2), (C1, C2), (NC1, NC2);
181-
(P1), (C1), (NC1);
182-
(P2), (C2), (NC2);
183-
(P3), (C3), (NC3);
184-
(P4), (C4), (NC4);
172+
(O1, C1, NC1), (O2, C2, NC2), (O3, C3, NC3), (O4, C4, NC4);
173+
174+
(O2, C2, NC2), (O3, C3, NC3), (O4, C4, NC4);
175+
(O1, C1, NC1), (O3, C3, NC3), (O4, C4, NC4);
176+
(O1, C1, NC1), (O2, C2, NC2), (O4, C4, NC4);
177+
(O1, C1, NC1), (O2, C2, NC2), (O3, C3, NC3);
178+
179+
(O3, C3, NC3), (O4, C4, NC4);
180+
(O2, C2, NC2), (O4, C4, NC4);
181+
(O2, C2, NC2), (O3, C3, NC3);
182+
(O1, C1, NC1), (O4, C4, NC4);
183+
(O1, C1, NC1), (O3, C3, NC3);
184+
(O1, C1, NC1), (O2, C2, NC2);
185+
186+
(O1, C1, NC1);
187+
(O2, C2, NC2);
188+
(O3, C3, NC3);
189+
(O4, C4, NC4);
185190
);
186191

187192
pub struct PwmChannel<TIM, const C: u8, const COMP: bool = false> {

0 commit comments

Comments
 (0)