2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
24 #include "common/utils.h"
26 // allow conditional definition of DMA related members
27 #if defined(USE_TIMER_DMA)
28 # define DEF_TIM_DMA_COND(...) __VA_ARGS__
30 # define DEF_TIM_DMA_COND(...)
33 #if defined(USE_TIMER_MGMT)
34 #define TIMER_GET_IO_TAG(pin) DEFIO_TAG_E(pin)
36 #define TIMER_GET_IO_TAG(pin) DEFIO_TAG(pin)
39 // map to base channel (strip N from channel); works only when channel N exists
40 #define DEF_TIM_TCH2BTCH(timch) CONCAT(B, timch)
41 #define BTCH_TIM1_CH1N BTCH_TIM1_CH1
42 #define BTCH_TIM1_CH2N BTCH_TIM1_CH2
43 #define BTCH_TIM1_CH3N BTCH_TIM1_CH3
45 #define BTCH_TIM1_CH4N BTCH_TIM1_CH4
48 #define BTCH_TIM8_CH1N BTCH_TIM8_CH1
49 #define BTCH_TIM8_CH2N BTCH_TIM8_CH2
50 #define BTCH_TIM8_CH3N BTCH_TIM8_CH3
52 #define BTCH_TIM8_CH4N BTCH_TIM8_CH4
55 #define BTCH_TIM20_CH1N BTCH_TIM20_CH1
56 #define BTCH_TIM20_CH2N BTCH_TIM20_CH2
57 #define BTCH_TIM20_CH3N BTCH_TIM20_CH3
59 #define BTCH_TIM13_CH1N BTCH_TIM13_CH1
60 #define BTCH_TIM14_CH1N BTCH_TIM14_CH1
61 #define BTCH_TIM15_CH1N BTCH_TIM15_CH1
62 #define BTCH_TIM16_CH1N BTCH_TIM16_CH1
63 #define BTCH_TIM17_CH1N BTCH_TIM17_CH1
65 // channel table D(chan_n, n_type)
66 #define DEF_TIM_CH_GET(ch) CONCAT2(DEF_TIM_CH__, ch)
67 #define DEF_TIM_CH__CH_CH1 D(1, 0)
68 #define DEF_TIM_CH__CH_CH2 D(2, 0)
69 #define DEF_TIM_CH__CH_CH3 D(3, 0)
70 #define DEF_TIM_CH__CH_CH4 D(4, 0)
71 #define DEF_TIM_CH__CH_CH1N D(1, 1)
72 #define DEF_TIM_CH__CH_CH2N D(2, 1)
73 #define DEF_TIM_CH__CH_CH3N D(3, 1)
75 #define DEF_TIM_CH__CH_CH4N D(4, 1)
78 // timer table D(tim_n)
79 #define DEF_TIM_TIM_GET(tim) CONCAT2(DEF_TIM_TIM__, tim)
80 #define DEF_TIM_TIM__TIM_TIM1 D(1)
81 #define DEF_TIM_TIM__TIM_TIM2 D(2)
82 #define DEF_TIM_TIM__TIM_TIM3 D(3)
83 #define DEF_TIM_TIM__TIM_TIM4 D(4)
84 #define DEF_TIM_TIM__TIM_TIM5 D(5)
85 #define DEF_TIM_TIM__TIM_TIM6 D(6)
86 #define DEF_TIM_TIM__TIM_TIM7 D(7)
87 #define DEF_TIM_TIM__TIM_TIM8 D(8)
88 #define DEF_TIM_TIM__TIM_TIM9 D(9)
89 #define DEF_TIM_TIM__TIM_TIM10 D(10)
90 #define DEF_TIM_TIM__TIM_TIM11 D(11)
91 #define DEF_TIM_TIM__TIM_TIM12 D(12)
92 #define DEF_TIM_TIM__TIM_TIM13 D(13)
93 #define DEF_TIM_TIM__TIM_TIM14 D(14)
94 #define DEF_TIM_TIM__TIM_TIM15 D(15)
95 #define DEF_TIM_TIM__TIM_TIM16 D(16)
96 #define DEF_TIM_TIM__TIM_TIM17 D(17)
97 #define DEF_TIM_TIM__TIM_TIM18 D(18)
98 #define DEF_TIM_TIM__TIM_TIM19 D(19)
99 #define DEF_TIM_TIM__TIM_TIM20 D(20)
100 #define DEF_TIM_TIM__TIM_TIM21 D(21)
101 #define DEF_TIM_TIM__TIM_TIM22 D(22)
103 // get record from DMA table
104 // DMA table is identical for all targets for consistency, only variant 0 is defined on F1,F3
105 // DMA table entry for TIMx Channel y, with two variants:
106 // #define DEF_TIM_DMA__BTCH_TIMx_CHy D(var0),D(var1)
107 // Parameters in D(...) are target-specific
108 // DMA table for channel without DMA
109 // #define DEF_TIM_DMA__BTCH_TIMx_CHy NONE
110 // N channels are converted to corresponding base channel first
112 // Create accessor macro and call it with entry from table
113 // DMA_VARIANT_MISSING are used to satisfy variable arguments (-Wpedantic) and to get better error message (undefined symbol instead of preprocessor error)
114 #define DEF_TIM_DMA_GET(variant, timch) PP_CALL(CONCAT(DEF_TIM_DMA_GET_VARIANT__, variant), CONCAT(DEF_TIM_DMA__, DEF_TIM_TCH2BTCH(timch)), DMA_VARIANT_MISSING, DMA_VARIANT_MISSING, ERROR)
116 #define DEF_TIM_DMA_GET_VARIANT__0(_0, ...) _0
117 #define DEF_TIM_DMA_GET_VARIANT__1(_0, _1, ...) _1
118 #define DEF_TIM_DMA_GET_VARIANT__2(_0, _1, _2, ...) _2
119 #define DEF_TIM_DMA_GET_VARIANT__3(_0, _1, _2, _3, ...) _3
120 #define DEF_TIM_DMA_GET_VARIANT__4(_0, _1, _2, _3, _4, ...) _4
121 #define DEF_TIM_DMA_GET_VARIANT__5(_0, _1, _2, _3, _4, _5, ...) _5
122 #define DEF_TIM_DMA_GET_VARIANT__6(_0, _1, _2, _3, _4, _5, _6, ...) _6
123 #define DEF_TIM_DMA_GET_VARIANT__7(_0, _1, _2, _3, _4, _5, _6, _7, ...) _7
124 #define DEF_TIM_DMA_GET_VARIANT__8(_0, _1, _2, _3, _4, _5, _6, _7, _8, ...) _8
125 #define DEF_TIM_DMA_GET_VARIANT__9(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) _9
126 #define DEF_TIM_DMA_GET_VARIANT__10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, ...) _10
127 #define DEF_TIM_DMA_GET_VARIANT__11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) _11
128 #define DEF_TIM_DMA_GET_VARIANT__12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, ...) _12
129 #define DEF_TIM_DMA_GET_VARIANT__13(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, ...) _13
130 #define DEF_TIM_DMA_GET_VARIANT__14(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, ...) _14
131 #define DEF_TIM_DMA_GET_VARIANT__15(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) _15
133 // symbolic names for DMA variants
138 // get record from AF table
139 // Parameters in D(...) are target-specific
140 #define DEF_TIM_AF_GET(timch, pin) CONCAT4(DEF_TIM_AF__, pin, __, timch)
142 // define output type (N-channel)
143 #define DEF_TIM_OUTPUT(ch) CONCAT(DEF_TIM_OUTPUT__, DEF_TIM_CH_GET(ch))
144 #define DEF_TIM_OUTPUT__D(chan_n, n_channel) PP_IIF(n_channel, TIMER_OUTPUT_N_CHANNEL, TIMER_OUTPUT_NONE)
148 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt) { \
150 TIMER_GET_IO_TAG(pin), \
151 DEF_TIM_CHANNEL(CH_ ## chan), \
153 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
154 DEF_TIM_AF(TIM_ ## tim) \
155 DEF_TIM_DMA_COND(/* add comma */ , \
156 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
157 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan) \
159 DEF_TIM_DMA_COND(/* add comma */ , \
160 DEF_TIM_DMA_STREAM(0, TCH_## tim ## _UP), \
161 DEF_TIM_DMA_CHANNEL(0, TCH_## tim ## _UP), \
162 DEF_TIM_DMA_HANDLER(0, TCH_## tim ## _UP) \
167 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
168 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_Channel_ ## chan_n
170 #define DEF_TIM_AF(tim) CONCAT(DEF_TIM_AF__, DEF_TIM_TIM_GET(tim))
171 #define DEF_TIM_AF__D(tim_n) GPIO_AF_TIM ## tim_n
173 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
174 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
175 #define DEF_TIM_DMA_CHANNEL__D(dma_n, stream_n, chan_n) DMA_Channel_ ## chan_n
176 #define DEF_TIM_DMA_CHANNEL__NONE DMA_Channel_0
178 #define DEF_TIM_DMA_STREAM(variant, timch) \
179 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
180 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n, chan_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
181 #define DEF_TIM_DMA_STREAM__NONE NULL
183 #define DEF_TIM_DMA_HANDLER(variant, timch) \
184 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
185 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n, chan_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
186 #define DEF_TIM_DMA_HANDLER__NONE 0
189 /* F4 Stream Mappings */
190 // D(DMAx, Stream, Channel)
191 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(2, 6, 0),D(2, 1, 6),D(2, 3, 6)
192 #define DEF_TIM_DMA__BTCH_TIM1_CH2 D(2, 6, 0),D(2, 2, 6)
193 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(2, 6, 0),D(2, 6, 6)
194 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(2, 4, 6)
196 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5, 3)
197 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 6, 3)
198 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1, 3)
199 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7, 3),D(1, 6, 3)
201 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 4, 5)
202 #define DEF_TIM_DMA__BTCH_TIM3_CH2 D(1, 5, 5)
203 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 7, 5)
204 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 2, 5)
206 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 0, 2)
207 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 3, 2)
208 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 7, 2)
210 #define DEF_TIM_DMA__BTCH_TIM5_CH1 D(1, 2, 6)
211 #define DEF_TIM_DMA__BTCH_TIM5_CH2 D(1, 4, 6)
212 #define DEF_TIM_DMA__BTCH_TIM5_CH3 D(1, 0, 6)
213 #define DEF_TIM_DMA__BTCH_TIM5_CH4 D(1, 1, 6),D(1, 3, 6)
215 #define DEF_TIM_DMA__BTCH_TIM8_CH1 D(2, 2, 0),D(2, 2, 7)
216 #define DEF_TIM_DMA__BTCH_TIM8_CH2 D(2, 2, 0),D(2, 3, 7)
217 #define DEF_TIM_DMA__BTCH_TIM8_CH3 D(2, 2, 0),D(2, 4, 7)
218 #define DEF_TIM_DMA__BTCH_TIM8_CH4 D(2, 7, 7)
220 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
222 #define DEF_TIM_DMA__BTCH_TIM9_CH1 NONE
223 #define DEF_TIM_DMA__BTCH_TIM9_CH2 NONE
225 #define DEF_TIM_DMA__BTCH_TIM10_CH1 NONE
227 #define DEF_TIM_DMA__BTCH_TIM11_CH1 NONE
229 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
230 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
232 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
234 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
237 #define DEF_TIM_DMA__BTCH_TIM1_UP D(2, 5, 6)
238 #define DEF_TIM_DMA__BTCH_TIM2_UP D(1, 7, 3)
239 #define DEF_TIM_DMA__BTCH_TIM3_UP D(1, 2, 5)
240 #define DEF_TIM_DMA__BTCH_TIM4_UP D(1, 6, 2)
241 #define DEF_TIM_DMA__BTCH_TIM5_UP D(1, 0, 6)
242 #define DEF_TIM_DMA__BTCH_TIM6_UP D(1, 1, 7)
243 #define DEF_TIM_DMA__BTCH_TIM7_UP D(1, 4, 1)
244 #define DEF_TIM_DMA__BTCH_TIM8_UP D(2, 1, 7)
245 #define DEF_TIM_DMA__BTCH_TIM9_UP NONE
246 #define DEF_TIM_DMA__BTCH_TIM10_UP NONE
247 #define DEF_TIM_DMA__BTCH_TIM11_UP NONE
248 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
249 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
250 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
252 #elif defined(STM32F7)
253 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt) { \
255 TIMER_GET_IO_TAG(pin), \
256 DEF_TIM_CHANNEL(CH_ ## chan), \
258 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
259 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
260 DEF_TIM_DMA_COND(/* add comma */ , \
261 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
262 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan) \
264 DEF_TIM_DMA_COND(/* add comma */ , \
265 DEF_TIM_DMA_STREAM(0, TCH_## tim ## _UP), \
266 DEF_TIM_DMA_CHANNEL(0, TCH_## tim ## _UP), \
267 DEF_TIM_DMA_HANDLER(0, TCH_## tim ## _UP) \
272 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
273 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
275 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
276 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
278 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
279 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
280 #define DEF_TIM_DMA_CHANNEL__D(dma_n, stream_n, chan_n) DMA_CHANNEL_ ## chan_n
281 #define DEF_TIM_DMA_CHANNEL__NONE DMA_CHANNEL_0
283 #define DEF_TIM_DMA_STREAM(variant, timch) \
284 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
285 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n, chan_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
286 #define DEF_TIM_DMA_STREAM__NONE NULL
288 #define DEF_TIM_DMA_HANDLER(variant, timch) \
289 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
290 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n, chan_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
291 #define DEF_TIM_DMA_HANDLER__NONE 0
293 /* F7 Stream Mappings */
294 // D(DMAx, Stream, Channel)
295 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(2, 6, 0),D(2, 1, 6),D(2, 3, 6)
296 #define DEF_TIM_DMA__BTCH_TIM1_CH2 D(2, 6, 0),D(2, 2, 6)
297 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(2, 6, 0),D(2, 6, 6)
298 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(2, 4, 6)
300 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5, 3)
301 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 6, 3)
302 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1, 3)
303 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7, 3),D(1, 6, 3)
305 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 4, 5)
306 #define DEF_TIM_DMA__BTCH_TIM3_CH2 D(1, 5, 5)
307 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 7, 5)
308 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 2, 5)
310 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 0, 2)
311 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 3, 2)
312 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 7, 2)
314 #define DEF_TIM_DMA__BTCH_TIM5_CH1 D(1, 2, 6)
315 #define DEF_TIM_DMA__BTCH_TIM5_CH2 D(1, 4, 6)
316 #define DEF_TIM_DMA__BTCH_TIM5_CH3 D(1, 0, 6)
317 #define DEF_TIM_DMA__BTCH_TIM5_CH4 D(1, 1, 6),D(1, 3, 6)
319 #define DEF_TIM_DMA__BTCH_TIM8_CH1 D(2, 2, 0),D(2, 2, 7)
320 #define DEF_TIM_DMA__BTCH_TIM8_CH2 D(2, 2, 0),D(2, 3, 7)
321 #define DEF_TIM_DMA__BTCH_TIM8_CH3 D(2, 2, 0),D(2, 4, 7)
322 #define DEF_TIM_DMA__BTCH_TIM8_CH4 D(2, 7, 7)
324 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
326 #define DEF_TIM_DMA__BTCH_TIM9_CH1 NONE
327 #define DEF_TIM_DMA__BTCH_TIM9_CH2 NONE
329 #define DEF_TIM_DMA__BTCH_TIM10_CH1 NONE
331 #define DEF_TIM_DMA__BTCH_TIM11_CH1 NONE
333 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
334 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
336 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
338 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
341 #define DEF_TIM_DMA__BTCH_TIM1_UP D(2, 5, 6)
342 #define DEF_TIM_DMA__BTCH_TIM2_UP D(1, 7, 3)
343 #define DEF_TIM_DMA__BTCH_TIM3_UP D(1, 2, 5)
344 #define DEF_TIM_DMA__BTCH_TIM4_UP D(1, 6, 2)
345 #define DEF_TIM_DMA__BTCH_TIM5_UP D(1, 0, 6)
346 #define DEF_TIM_DMA__BTCH_TIM6_UP D(1, 1, 7)
347 #define DEF_TIM_DMA__BTCH_TIM7_UP D(1, 4, 1)
348 #define DEF_TIM_DMA__BTCH_TIM8_UP D(2, 1, 7)
349 #define DEF_TIM_DMA__BTCH_TIM9_UP NONE
350 #define DEF_TIM_DMA__BTCH_TIM10_UP NONE
351 #define DEF_TIM_DMA__BTCH_TIM11_UP NONE
352 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
353 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
354 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
359 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(1, 1)
360 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(1, 1)
361 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(1, 1)
362 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(1, 1)
363 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
364 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
365 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
366 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
369 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
370 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
371 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
372 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
373 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
374 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(1, 1)
375 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(1, 1)
376 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(1, 1)
377 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(1, 1)
378 #define DEF_TIM_AF__PA11__TCH_TIM1_CH1N D(1, 1)
379 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
381 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
382 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
383 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
384 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
385 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
386 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
388 #define DEF_TIM_AF__PA2__TCH_TIM9_CH1 D(3, 9)
389 #define DEF_TIM_AF__PA3__TCH_TIM9_CH2 D(3, 9)
390 #define DEF_TIM_AF__PA5__TCH_TIM8_CH1N D(3, 8)
391 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(3, 8)
393 #define DEF_TIM_AF__PA6__TCH_TIM13_CH1 D(9, 13)
394 #define DEF_TIM_AF__PA7__TCH_TIM14_CH1 D(9, 14)
397 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(1, 1)
398 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(1, 1)
399 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
400 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
401 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
402 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(1, 1)
403 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(1, 1)
404 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(1, 1)
406 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
407 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
408 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
409 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
410 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
411 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
412 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
413 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
415 #define DEF_TIM_AF__PB0__TCH_TIM8_CH2N D(3, 8)
416 #define DEF_TIM_AF__PB1__TCH_TIM8_CH3N D(3, 8)
417 #define DEF_TIM_AF__PB8__TCH_TIM10_CH1 D(3, 10)
418 #define DEF_TIM_AF__PB9__TCH_TIM11_CH1 D(3, 11)
419 #define DEF_TIM_AF__PB14__TCH_TIM8_CH2N D(3, 8)
420 #define DEF_TIM_AF__PB15__TCH_TIM8_CH3N D(3, 8)
422 #define DEF_TIM_AF__PB14__TCH_TIM12_CH1 D(9, 12)
423 #define DEF_TIM_AF__PB15__TCH_TIM12_CH2 D(9, 12)
426 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
427 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
428 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
429 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
431 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(3, 8)
432 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(3, 8)
433 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(3, 8)
434 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(3, 8)
437 #define DEF_TIM_AF__PD12__TCH_TIM4_CH1 D(2, 4)
438 #define DEF_TIM_AF__PD13__TCH_TIM4_CH2 D(2, 4)
439 #define DEF_TIM_AF__PD14__TCH_TIM4_CH3 D(2, 4)
440 #define DEF_TIM_AF__PD15__TCH_TIM4_CH4 D(2, 4)
443 #define DEF_TIM_AF__PE8__TCH_TIM1_CH1N D(1, 1)
444 #define DEF_TIM_AF__PE9__TCH_TIM1_CH1 D(1, 1)
445 #define DEF_TIM_AF__PE10__TCH_TIM1_CH2N D(1, 1)
446 #define DEF_TIM_AF__PE11__TCH_TIM1_CH2 D(1, 1)
447 #define DEF_TIM_AF__PE12__TCH_TIM1_CH3N D(1, 1)
448 #define DEF_TIM_AF__PE13__TCH_TIM1_CH3 D(1, 1)
449 #define DEF_TIM_AF__PE14__TCH_TIM1_CH4 D(1, 1)
451 #define DEF_TIM_AF__PE5__TCH_TIM9_CH1 D(3, 9)
452 #define DEF_TIM_AF__PE6__TCH_TIM9_CH2 D(3, 9)
455 #define DEF_TIM_AF__PF6__TCH_TIM10_CH1 D(3, 10)
456 #define DEF_TIM_AF__PF7__TCH_TIM11_CH1 D(3, 11)
459 #define DEF_TIM_AF__PH10__TCH_TIM5_CH1 D(2, 5)
460 #define DEF_TIM_AF__PH11__TCH_TIM5_CH2 D(2, 5)
461 #define DEF_TIM_AF__PH12__TCH_TIM5_CH3 D(2, 5)
463 #define DEF_TIM_AF__PH13__TCH_TIM8_CH1N D(3, 8)
464 #define DEF_TIM_AF__PH14__TCH_TIM8_CH2N D(3, 8)
465 #define DEF_TIM_AF__PH15__TCH_TIM8_CH3N D(3, 8)
467 #define DEF_TIM_AF__PH6__TCH_TIM12_CH1 D(9, 12)
468 #define DEF_TIM_AF__PH9__TCH_TIM12_CH2 D(9, 12)
471 #define DEF_TIM_AF__PI0__TCH_TIM5_CH4 D(2, 5)
473 #define DEF_TIM_AF__PI2__TCH_TIM8_CH4 D(3, 8)
474 #define DEF_TIM_AF__PI5__TCH_TIM8_CH1 D(3, 8)
475 #define DEF_TIM_AF__PI6__TCH_TIM8_CH2 D(3, 8)
476 #define DEF_TIM_AF__PI7__TCH_TIM8_CH3 D(3, 8)
478 #elif defined(STM32H7)
479 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt, upopt) { \
481 TIMER_GET_IO_TAG(pin), \
482 DEF_TIM_CHANNEL(CH_ ## chan), \
484 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
485 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
486 DEF_TIM_DMA_COND(/* add comma */ , \
487 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
488 DEF_TIM_DMA_REQUEST(TCH_## tim ## _ ## chan) \
490 DEF_TIM_DMA_COND(/* add comma */ , \
491 DEF_TIM_DMA_STREAM(upopt, TCH_## tim ## _UP), \
492 DEF_TIM_DMA_REQUEST(TCH_## tim ## _UP), \
493 DEF_TIM_DMA_HANDLER(upopt, TCH_## tim ## _UP) \
498 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
499 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
501 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
502 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
504 #define DEF_TIM_DMA_STREAM(variant, timch) \
505 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
506 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
507 #define DEF_TIM_DMA_STREAM__NONE NULL
509 // XXX This is awful. There must be some smart way of doing this ...
510 #define DEF_TIM_DMA_REQUEST(timch) \
511 CONCAT(DEF_TIM_DMA_REQ__, DEF_TIM_TCH2BTCH(timch))
513 #define DEF_TIM_DMA_HANDLER(variant, timch) \
514 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
515 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
516 #define DEF_TIM_DMA_HANDLER__NONE 0
518 /* H7 Stream Mappings */
521 // H7 has DMAMUX that allow arbitrary assignment of peripherals to streams.
523 #define DEF_TIM_DMA_FULL \
524 D(1, 0), D(1, 1), D(1, 2), D(1, 3), D(1, 4), D(1, 5), D(1, 6), D(1, 7), \
525 D(2, 0), D(2, 1), D(2, 2), D(2, 3), D(2, 4), D(2, 5), D(2, 6), D(2, 7)
527 #define DEF_TIM_DMA__BTCH_TIM1_CH1 DEF_TIM_DMA_FULL
528 #define DEF_TIM_DMA__BTCH_TIM1_CH2 DEF_TIM_DMA_FULL
529 #define DEF_TIM_DMA__BTCH_TIM1_CH3 DEF_TIM_DMA_FULL
530 #define DEF_TIM_DMA__BTCH_TIM1_CH4 DEF_TIM_DMA_FULL
532 #define DEF_TIM_DMA__BTCH_TIM2_CH1 DEF_TIM_DMA_FULL
533 #define DEF_TIM_DMA__BTCH_TIM2_CH2 DEF_TIM_DMA_FULL
534 #define DEF_TIM_DMA__BTCH_TIM2_CH3 DEF_TIM_DMA_FULL
535 #define DEF_TIM_DMA__BTCH_TIM2_CH4 DEF_TIM_DMA_FULL
537 #define DEF_TIM_DMA__BTCH_TIM3_CH1 DEF_TIM_DMA_FULL
538 #define DEF_TIM_DMA__BTCH_TIM3_CH2 DEF_TIM_DMA_FULL
539 #define DEF_TIM_DMA__BTCH_TIM3_CH3 DEF_TIM_DMA_FULL
540 #define DEF_TIM_DMA__BTCH_TIM3_CH4 DEF_TIM_DMA_FULL
542 #define DEF_TIM_DMA__BTCH_TIM4_CH1 DEF_TIM_DMA_FULL
543 #define DEF_TIM_DMA__BTCH_TIM4_CH2 DEF_TIM_DMA_FULL
544 #define DEF_TIM_DMA__BTCH_TIM4_CH3 DEF_TIM_DMA_FULL
545 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
547 #define DEF_TIM_DMA__BTCH_TIM5_CH1 DEF_TIM_DMA_FULL
548 #define DEF_TIM_DMA__BTCH_TIM5_CH2 DEF_TIM_DMA_FULL
549 #define DEF_TIM_DMA__BTCH_TIM5_CH3 DEF_TIM_DMA_FULL
550 #define DEF_TIM_DMA__BTCH_TIM5_CH4 DEF_TIM_DMA_FULL
552 #define DEF_TIM_DMA__BTCH_TIM8_CH1 DEF_TIM_DMA_FULL
553 #define DEF_TIM_DMA__BTCH_TIM8_CH2 DEF_TIM_DMA_FULL
554 #define DEF_TIM_DMA__BTCH_TIM8_CH3 DEF_TIM_DMA_FULL
555 #define DEF_TIM_DMA__BTCH_TIM8_CH4 DEF_TIM_DMA_FULL
557 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
558 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
560 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
562 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
564 #define DEF_TIM_DMA__BTCH_TIM15_CH1 DEF_TIM_DMA_FULL
565 #define DEF_TIM_DMA__BTCH_TIM15_CH2 NONE
567 #define DEF_TIM_DMA__BTCH_TIM16_CH1 DEF_TIM_DMA_FULL
569 #define DEF_TIM_DMA__BTCH_TIM17_CH1 DEF_TIM_DMA_FULL
571 #if defined(STM32H723xx) || defined(STM32H725xx)
572 #define DEF_TIM_DMA__BTCH_TIM23_CH1 DEF_TIM_DMA_FULL
573 #define DEF_TIM_DMA__BTCH_TIM23_CH2 DEF_TIM_DMA_FULL
574 #define DEF_TIM_DMA__BTCH_TIM23_CH3 DEF_TIM_DMA_FULL
575 #define DEF_TIM_DMA__BTCH_TIM23_CH4 DEF_TIM_DMA_FULL
577 #define DEF_TIM_DMA__BTCH_TIM24_CH1 DEF_TIM_DMA_FULL
578 #define DEF_TIM_DMA__BTCH_TIM24_CH2 DEF_TIM_DMA_FULL
579 #define DEF_TIM_DMA__BTCH_TIM24_CH3 DEF_TIM_DMA_FULL
580 #define DEF_TIM_DMA__BTCH_TIM24_CH4 DEF_TIM_DMA_FULL
584 #define DEF_TIM_DMA__BTCH_TIM1_UP DEF_TIM_DMA_FULL
585 #define DEF_TIM_DMA__BTCH_TIM2_UP DEF_TIM_DMA_FULL
586 #define DEF_TIM_DMA__BTCH_TIM3_UP DEF_TIM_DMA_FULL
587 #define DEF_TIM_DMA__BTCH_TIM4_UP DEF_TIM_DMA_FULL
588 #define DEF_TIM_DMA__BTCH_TIM5_UP DEF_TIM_DMA_FULL
589 #define DEF_TIM_DMA__BTCH_TIM6_UP DEF_TIM_DMA_FULL
590 #define DEF_TIM_DMA__BTCH_TIM7_UP DEF_TIM_DMA_FULL
591 #define DEF_TIM_DMA__BTCH_TIM8_UP DEF_TIM_DMA_FULL
592 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
593 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
594 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
595 #define DEF_TIM_DMA__BTCH_TIM15_UP DEF_TIM_DMA_FULL
596 #define DEF_TIM_DMA__BTCH_TIM16_UP DEF_TIM_DMA_FULL
597 #define DEF_TIM_DMA__BTCH_TIM17_UP DEF_TIM_DMA_FULL
599 #if defined(STM32H723xx) || defined(STM32H725xx)
600 #define DEF_TIM_DMA__BTCH_TIM23_UP DEF_TIM_DMA_FULL
601 #define DEF_TIM_DMA__BTCH_TIM24_UP DEF_TIM_DMA_FULL
604 // TIMx_CHy request table
606 // This is not defined in stm32h7xx_hal_timer.h
607 #define DMA_REQUEST_NONE 255
609 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH1 DMA_REQUEST_TIM1_CH1
610 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH2 DMA_REQUEST_TIM1_CH2
611 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH3 DMA_REQUEST_TIM1_CH3
612 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH4 DMA_REQUEST_TIM1_CH4
614 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH1 DMA_REQUEST_TIM2_CH1
615 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH2 DMA_REQUEST_TIM2_CH2
616 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH3 DMA_REQUEST_TIM2_CH3
617 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH4 DMA_REQUEST_TIM2_CH4
619 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH1 DMA_REQUEST_TIM3_CH1
620 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH2 DMA_REQUEST_TIM3_CH2
621 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH3 DMA_REQUEST_TIM3_CH3
622 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH4 DMA_REQUEST_TIM3_CH4
624 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH1 DMA_REQUEST_TIM4_CH1
625 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH2 DMA_REQUEST_TIM4_CH2
626 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH3 DMA_REQUEST_TIM4_CH3
627 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH4 DMA_REQUEST_NONE
629 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH1 DMA_REQUEST_TIM5_CH1
630 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH2 DMA_REQUEST_TIM5_CH2
631 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH3 DMA_REQUEST_TIM5_CH3
632 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH4 DMA_REQUEST_TIM5_CH4
634 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH1 DMA_REQUEST_TIM8_CH1
635 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH2 DMA_REQUEST_TIM8_CH2
636 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH3 DMA_REQUEST_TIM8_CH3
637 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH4 DMA_REQUEST_TIM8_CH4
639 #define DEF_TIM_DMA_REQ__BTCH_TIM12_CH1 DMA_REQUEST_NONE
640 #define DEF_TIM_DMA_REQ__BTCH_TIM12_CH2 DMA_REQUEST_NONE
642 #define DEF_TIM_DMA_REQ__BTCH_TIM13_CH1 DMA_REQUEST_NONE
644 #define DEF_TIM_DMA_REQ__BTCH_TIM14_CH1 DMA_REQUEST_NONE
646 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH1 DMA_REQUEST_TIM15_CH1
647 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH2 DMA_REQUEST_NONE
649 #define DEF_TIM_DMA_REQ__BTCH_TIM16_CH1 DMA_REQUEST_TIM16_CH1
651 #define DEF_TIM_DMA_REQ__BTCH_TIM17_CH1 DMA_REQUEST_TIM17_CH1
653 #if defined(STM32H723xx) || defined(STM32H725xx)
654 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH1 DMA_REQUEST_TIM23_CH1
655 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH2 DMA_REQUEST_TIM23_CH2
656 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH3 DMA_REQUEST_TIM23_CH3
657 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH4 DMA_REQUEST_TIM23_CH4
659 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH1 DMA_REQUEST_TIM24_CH1
660 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH2 DMA_REQUEST_TIM24_CH2
661 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH3 DMA_REQUEST_TIM24_CH3
662 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH4 DMA_REQUEST_TIM24_CH4
665 // TIM_UP request table
666 #define DEF_TIM_DMA_REQ__BTCH_TIM1_UP DMA_REQUEST_TIM1_UP
667 #define DEF_TIM_DMA_REQ__BTCH_TIM2_UP DMA_REQUEST_TIM2_UP
668 #define DEF_TIM_DMA_REQ__BTCH_TIM3_UP DMA_REQUEST_TIM3_UP
669 #define DEF_TIM_DMA_REQ__BTCH_TIM4_UP DMA_REQUEST_TIM4_UP
670 #define DEF_TIM_DMA_REQ__BTCH_TIM5_UP DMA_REQUEST_TIM5_UP
671 #define DEF_TIM_DMA_REQ__BTCH_TIM6_UP DMA_REQUEST_TIM6_UP
672 #define DEF_TIM_DMA_REQ__BTCH_TIM7_UP DMA_REQUEST_TIM7_UP
673 #define DEF_TIM_DMA_REQ__BTCH_TIM8_UP DMA_REQUEST_TIM8_UP
674 #define DEF_TIM_DMA_REQ__BTCH_TIM12_UP DMA_REQUEST_NONE
675 #define DEF_TIM_DMA_REQ__BTCH_TIM13_UP DMA_REQUEST_NONE
676 #define DEF_TIM_DMA_REQ__BTCH_TIM14_UP DMA_REQUEST_NONE
677 #define DEF_TIM_DMA_REQ__BTCH_TIM15_UP DMA_REQUEST_TIM15_UP
678 #define DEF_TIM_DMA_REQ__BTCH_TIM16_UP DMA_REQUEST_TIM16_UP
679 #define DEF_TIM_DMA_REQ__BTCH_TIM17_UP DMA_REQUEST_TIM17_UP
681 #if defined(STM32H723xx) || defined(STM32H725xx)
682 #define DEF_TIM_DMA_REQ__BTCH_TIM23_UP DMA_REQUEST_TIM23_UP
683 #define DEF_TIM_DMA_REQ__BTCH_TIM24_UP DMA_REQUEST_TIM24_UP
689 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(1, 1)
690 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(1, 1)
691 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(1, 1)
692 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(1, 1)
693 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
694 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
695 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
696 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
699 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
700 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
701 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
702 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
703 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
704 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(1, 1)
705 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(1, 1)
706 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(1, 1)
707 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(1, 1)
708 #define DEF_TIM_AF__PA11__TCH_TIM1_CH4 D(1, 1)
709 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
711 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
712 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
713 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
714 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
715 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
716 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
718 #define DEF_TIM_AF__PA5__TCH_TIM8_CH1N D(3, 8)
719 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(3, 8)
721 #define DEF_TIM_AF__PA6__TCH_TIM13_CH1 D(9, 13)
722 #define DEF_TIM_AF__PA7__TCH_TIM14_CH1 D(9, 14)
724 #define DEF_TIM_AF__PA1__TCH_TIM15_CH1N D(4, 15)
725 #define DEF_TIM_AF__PA2__TCH_TIM15_CH1 D(4, 15)
726 #define DEF_TIM_AF__PA3__TCH_TIM15_CH2 D(4, 15)
729 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(1, 1)
730 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(1, 1)
731 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
732 #define DEF_TIM_AF__PB6__TCH_TIM16_CH1N D(1, 16)
733 #define DEF_TIM_AF__PB7__TCH_TIM17_CH1N D(1, 17)
734 #define DEF_TIM_AF__PB8__TCH_TIM16_CH1 D(1, 16)
735 #define DEF_TIM_AF__PB9__TCH_TIM17_CH1 D(1, 17)
736 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
737 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
738 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(1, 1)
739 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(1, 1)
740 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(1, 1)
742 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
743 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
744 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
745 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
746 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
747 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
748 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
749 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
751 #define DEF_TIM_AF__PB14__TCH_TIM12_CH1 D(2, 12)
752 #define DEF_TIM_AF__PB15__TCH_TIM12_CH2 D(2, 12)
755 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
756 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
757 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
758 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
760 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(3, 8)
761 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(3, 8)
762 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(3, 8)
763 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(3, 8)
766 #define DEF_TIM_AF__PD12__TCH_TIM4_CH1 D(2, 4)
767 #define DEF_TIM_AF__PD13__TCH_TIM4_CH2 D(2, 4)
768 #define DEF_TIM_AF__PD14__TCH_TIM4_CH3 D(2, 4)
769 #define DEF_TIM_AF__PD15__TCH_TIM4_CH4 D(2, 4)
772 #define DEF_TIM_AF__PE8__TCH_TIM1_CH1N D(1, 1)
773 #define DEF_TIM_AF__PE9__TCH_TIM1_CH1 D(1, 1)
774 #define DEF_TIM_AF__PE10__TCH_TIM1_CH2N D(1, 1)
775 #define DEF_TIM_AF__PE11__TCH_TIM1_CH2 D(1, 1)
776 #define DEF_TIM_AF__PE12__TCH_TIM1_CH3N D(1, 1)
777 #define DEF_TIM_AF__PE13__TCH_TIM1_CH3 D(1, 1)
778 #define DEF_TIM_AF__PE14__TCH_TIM1_CH4 D(1, 1)
780 #define DEF_TIM_AF__PE4__TCH_TIM15_CH1N D(4, 15)
781 #define DEF_TIM_AF__PE5__TCH_TIM15_CH1 D(4, 15)
782 #define DEF_TIM_AF__PE6__TCH_TIM15_CH2 D(4, 15)
785 #define DEF_TIM_AF__PF6__TCH_TIM16_CH1 D(1, 16)
786 #define DEF_TIM_AF__PF7__TCH_TIM17_CH1 D(1, 17)
787 #define DEF_TIM_AF__PF8__TCH_TIM16_CH1N D(1, 16)
788 #define DEF_TIM_AF__PF9__TCH_TIM17_CH1N D(1, 17)
790 #define DEF_TIM_AF__PF8__TCH_TIM13_CH1N D(9, 13)
791 #define DEF_TIM_AF__PF9__TCH_TIM14_CH1N D(9, 14)
793 #if defined(STM32H723xx) || defined(STM32H725xx)
794 #define DEF_TIM_AF__PF0__TCH_TIM23_CH1 D(13, 23)
795 #define DEF_TIM_AF__PF1__TCH_TIM23_CH2 D(13, 23)
796 #define DEF_TIM_AF__PF2__TCH_TIM23_CH3 D(13, 23)
797 #define DEF_TIM_AF__PF3__TCH_TIM23_CH4 D(13, 23)
798 #define DEF_TIM_AF__PF6__TCH_TIM23_CH1 D(13, 23)
799 #define DEF_TIM_AF__PF7__TCH_TIM23_CH2 D(13, 23)
800 #define DEF_TIM_AF__PF8__TCH_TIM23_CH3 D(13, 23)
801 #define DEF_TIM_AF__PF9__TCH_TIM23_CH4 D(13, 23)
803 #define DEF_TIM_AF__PF11__TCH_TIM24_CH1 D(14, 24)
804 #define DEF_TIM_AF__PF12__TCH_TIM24_CH2 D(14, 24)
805 #define DEF_TIM_AF__PF13__TCH_TIM24_CH3 D(14, 24)
806 #define DEF_TIM_AF__PF14__TCH_TIM24_CH4 D(14, 24)
810 #define DEF_TIM_AF__PH6__TCH_TIM12_CH1 D(2, 12)
811 #define DEF_TIM_AF__PH9__TCH_TIM12_CH2 D(2, 12)
812 #define DEF_TIM_AF__PH10__TCH_TIM5_CH1 D(2, 5)
813 #define DEF_TIM_AF__PH11__TCH_TIM5_CH2 D(2, 5)
814 #define DEF_TIM_AF__PH12__TCH_TIM5_CH3 D(2, 5)
815 #define DEF_TIM_AF__PH13__TCH_TIM8_CH1N D(3, 8)
816 #define DEF_TIM_AF__PH14__TCH_TIM8_CH2N D(3, 8)
817 #define DEF_TIM_AF__PH15__TCH_TIM8_CH3N D(3, 8)
820 #define DEF_TIM_AF__PI0__TCH_TIM5_CH4 D(2, 5)
822 #define DEF_TIM_AF__PI2__TCH_TIM8_CH4 D(3, 8)
823 #define DEF_TIM_AF__PI5__TCH_TIM8_CH1 D(3, 8)
824 #define DEF_TIM_AF__PI6__TCH_TIM8_CH2 D(3, 8)
825 #define DEF_TIM_AF__PI7__TCH_TIM8_CH3 D(3, 8)
827 #elif defined(STM32G4)
829 // Missing from FW1.0.0 library?
830 #define GPIO_AF12_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */
832 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt, upopt) { \
834 TIMER_GET_IO_TAG(pin), \
835 DEF_TIM_CHANNEL(CH_ ## chan), \
837 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
838 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
839 DEF_TIM_DMA_COND(/* add comma */ , \
840 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan), \
841 DEF_TIM_DMA_REQUEST(TCH_## tim ## _ ## chan) \
843 DEF_TIM_DMA_COND(/* add comma */ , \
844 DEF_TIM_DMA_CHANNEL(upopt, TCH_## tim ## _UP), \
845 DEF_TIM_DMA_REQUEST(TCH_## tim ## _UP), \
846 DEF_TIM_DMA_HANDLER(upopt, TCH_## tim ## _UP) \
851 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
852 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
854 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
855 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
857 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
858 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
859 #define DEF_TIM_DMA_CHANNEL__D(dma_n, channel_n) (dmaResource_t *)DMA ## dma_n ## _Channel ## channel_n
860 #define DEF_TIM_DMA_CHANNEL__NONE NULL
862 // XXX This is awful. There must be some smart way of doing this ...
863 #define DEF_TIM_DMA_REQUEST(timch) \
864 CONCAT(DEF_TIM_DMA_REQ__, DEF_TIM_TCH2BTCH(timch))
866 #define DEF_TIM_DMA_HANDLER(variant, timch) \
867 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
868 #define DEF_TIM_DMA_HANDLER__D(dma_n, channel_n) DMA ## dma_n ## _CH ## channel_n ## _HANDLER
869 #define DEF_TIM_DMA_HANDLER__NONE 0
871 /* G4 Channel Mappings */
874 // G4 has DMAMUX that allow arbitrary assignment of peripherals to streams.
876 #define DEF_TIM_DMA_FULL \
877 D(1, 1), D(1, 2), D(1, 3), D(1, 4), D(1, 5), D(1, 6), D(1, 7), D(1, 8), \
878 D(2, 1), D(2, 2), D(2, 3), D(2, 4), D(2, 5), D(2, 6), D(2, 7), D(2, 8)
880 #define DEF_TIM_DMA__BTCH_TIM1_CH1 DEF_TIM_DMA_FULL
881 #define DEF_TIM_DMA__BTCH_TIM1_CH2 DEF_TIM_DMA_FULL
882 #define DEF_TIM_DMA__BTCH_TIM1_CH3 DEF_TIM_DMA_FULL
883 #define DEF_TIM_DMA__BTCH_TIM1_CH4 DEF_TIM_DMA_FULL
885 #define DEF_TIM_DMA__BTCH_TIM2_CH1 DEF_TIM_DMA_FULL
886 #define DEF_TIM_DMA__BTCH_TIM2_CH2 DEF_TIM_DMA_FULL
887 #define DEF_TIM_DMA__BTCH_TIM2_CH3 DEF_TIM_DMA_FULL
888 #define DEF_TIM_DMA__BTCH_TIM2_CH4 DEF_TIM_DMA_FULL
890 #define DEF_TIM_DMA__BTCH_TIM3_CH1 DEF_TIM_DMA_FULL
891 #define DEF_TIM_DMA__BTCH_TIM3_CH2 DEF_TIM_DMA_FULL
892 #define DEF_TIM_DMA__BTCH_TIM3_CH3 DEF_TIM_DMA_FULL
893 #define DEF_TIM_DMA__BTCH_TIM3_CH4 DEF_TIM_DMA_FULL
895 #define DEF_TIM_DMA__BTCH_TIM4_CH1 DEF_TIM_DMA_FULL
896 #define DEF_TIM_DMA__BTCH_TIM4_CH2 DEF_TIM_DMA_FULL
897 #define DEF_TIM_DMA__BTCH_TIM4_CH3 DEF_TIM_DMA_FULL
898 #define DEF_TIM_DMA__BTCH_TIM4_CH4 DEF_TIM_DMA_FULL
900 #define DEF_TIM_DMA__BTCH_TIM5_CH1 DEF_TIM_DMA_FULL
901 #define DEF_TIM_DMA__BTCH_TIM5_CH2 DEF_TIM_DMA_FULL
902 #define DEF_TIM_DMA__BTCH_TIM5_CH3 DEF_TIM_DMA_FULL
903 #define DEF_TIM_DMA__BTCH_TIM5_CH4 DEF_TIM_DMA_FULL
905 #define DEF_TIM_DMA__BTCH_TIM8_CH1 DEF_TIM_DMA_FULL
906 #define DEF_TIM_DMA__BTCH_TIM8_CH2 DEF_TIM_DMA_FULL
907 #define DEF_TIM_DMA__BTCH_TIM8_CH3 DEF_TIM_DMA_FULL
908 #define DEF_TIM_DMA__BTCH_TIM8_CH4 DEF_TIM_DMA_FULL
910 #define DEF_TIM_DMA__BTCH_TIM15_CH1 DEF_TIM_DMA_FULL
911 #define DEF_TIM_DMA__BTCH_TIM15_CH2 NONE
913 #define DEF_TIM_DMA__BTCH_TIM16_CH1 DEF_TIM_DMA_FULL
915 #define DEF_TIM_DMA__BTCH_TIM17_CH1 DEF_TIM_DMA_FULL
917 #define DEF_TIM_DMA__BTCH_TIM20_CH1 DEF_TIM_DMA_FULL
918 #define DEF_TIM_DMA__BTCH_TIM20_CH2 DEF_TIM_DMA_FULL
919 #define DEF_TIM_DMA__BTCH_TIM20_CH3 DEF_TIM_DMA_FULL
920 #define DEF_TIM_DMA__BTCH_TIM20_CH4 DEF_TIM_DMA_FULL
923 #define DEF_TIM_DMA__BTCH_TIM1_UP DEF_TIM_DMA_FULL
924 #define DEF_TIM_DMA__BTCH_TIM2_UP DEF_TIM_DMA_FULL
925 #define DEF_TIM_DMA__BTCH_TIM3_UP DEF_TIM_DMA_FULL
926 #define DEF_TIM_DMA__BTCH_TIM4_UP DEF_TIM_DMA_FULL
927 #define DEF_TIM_DMA__BTCH_TIM5_UP DEF_TIM_DMA_FULL
928 #define DEF_TIM_DMA__BTCH_TIM6_UP DEF_TIM_DMA_FULL
929 #define DEF_TIM_DMA__BTCH_TIM7_UP DEF_TIM_DMA_FULL
930 #define DEF_TIM_DMA__BTCH_TIM8_UP DEF_TIM_DMA_FULL
931 #define DEF_TIM_DMA__BTCH_TIM15_UP DEF_TIM_DMA_FULL
932 #define DEF_TIM_DMA__BTCH_TIM16_UP DEF_TIM_DMA_FULL
933 #define DEF_TIM_DMA__BTCH_TIM17_UP DEF_TIM_DMA_FULL
934 #define DEF_TIM_DMA__BTCH_TIM20_UP DEF_TIM_DMA_FULL
936 // TIMx_CHy request table
938 // This is not defined in stm32g7xx_hal_timer.h
939 #define DMA_REQUEST_NONE 255
941 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH1 DMA_REQUEST_TIM1_CH1
942 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH2 DMA_REQUEST_TIM1_CH2
943 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH3 DMA_REQUEST_TIM1_CH3
944 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH4 DMA_REQUEST_TIM1_CH4
946 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH1 DMA_REQUEST_TIM2_CH1
947 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH2 DMA_REQUEST_TIM2_CH2
948 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH3 DMA_REQUEST_TIM2_CH3
949 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH4 DMA_REQUEST_TIM2_CH4
951 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH1 DMA_REQUEST_TIM3_CH1
952 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH2 DMA_REQUEST_TIM3_CH2
953 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH3 DMA_REQUEST_TIM3_CH3
954 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH4 DMA_REQUEST_TIM3_CH4
956 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH1 DMA_REQUEST_TIM4_CH1
957 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH2 DMA_REQUEST_TIM4_CH2
958 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH3 DMA_REQUEST_TIM4_CH3
959 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH4 DMA_REQUEST_TIM4_CH4
961 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH1 DMA_REQUEST_TIM5_CH1
962 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH2 DMA_REQUEST_TIM5_CH2
963 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH3 DMA_REQUEST_TIM5_CH3
964 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH4 DMA_REQUEST_TIM5_CH4
966 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH1 DMA_REQUEST_TIM8_CH1
967 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH2 DMA_REQUEST_TIM8_CH2
968 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH3 DMA_REQUEST_TIM8_CH3
969 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH4 DMA_REQUEST_TIM8_CH4
971 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH1 DMA_REQUEST_TIM15_CH1
972 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH2 DMA_REQUEST_NONE
974 #define DEF_TIM_DMA_REQ__BTCH_TIM16_CH1 DMA_REQUEST_TIM16_CH1
976 #define DEF_TIM_DMA_REQ__BTCH_TIM17_CH1 DMA_REQUEST_TIM17_CH1
978 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH1 DMA_REQUEST_TIM20_CH1
979 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH2 DMA_REQUEST_TIM20_CH2
980 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH3 DMA_REQUEST_TIM20_CH3
981 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH4 DMA_REQUEST_TIM20_CH4
983 // TIM_UP request table
984 #define DEF_TIM_DMA_REQ__BTCH_TIM1_UP DMA_REQUEST_TIM1_UP
985 #define DEF_TIM_DMA_REQ__BTCH_TIM2_UP DMA_REQUEST_TIM2_UP
986 #define DEF_TIM_DMA_REQ__BTCH_TIM3_UP DMA_REQUEST_TIM3_UP
987 #define DEF_TIM_DMA_REQ__BTCH_TIM4_UP DMA_REQUEST_TIM4_UP
988 #define DEF_TIM_DMA_REQ__BTCH_TIM5_UP DMA_REQUEST_TIM5_UP
989 #define DEF_TIM_DMA_REQ__BTCH_TIM6_UP DMA_REQUEST_TIM6_UP
990 #define DEF_TIM_DMA_REQ__BTCH_TIM7_UP DMA_REQUEST_TIM7_UP
991 #define DEF_TIM_DMA_REQ__BTCH_TIM8_UP DMA_REQUEST_TIM8_UP
992 #define DEF_TIM_DMA_REQ__BTCH_TIM15_UP DMA_REQUEST_TIM15_UP
993 #define DEF_TIM_DMA_REQ__BTCH_TIM16_UP DMA_REQUEST_TIM16_UP
994 #define DEF_TIM_DMA_REQ__BTCH_TIM17_UP DMA_REQUEST_TIM17_UP
995 #define DEF_TIM_DMA_REQ__BTCH_TIM20_UP DMA_REQUEST_TIM20_UP
1000 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(6, 1)
1001 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(6, 1)
1002 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(6, 1)
1003 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(6, 1)
1004 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
1005 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
1006 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
1007 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
1010 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
1011 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
1012 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
1013 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
1014 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
1015 #define DEF_TIM_AF__PA6__TCH_TIM16_CH1 D(1, 16)
1016 #define DEF_TIM_AF__PA7__TCH_TIM17_CH1 D(1, 17)
1017 #define DEF_TIM_AF__PA12__TCH_TIM16_CH1 D(1, 16)
1018 #define DEF_TIM_AF__PA13__TCH_TIM16_CH1N D(1, 16)
1019 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
1021 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
1022 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
1023 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
1024 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
1025 #define DEF_TIM_AF__PA4__TCH_TIM3_CH2 D(2, 3)
1026 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
1027 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
1028 #define DEF_TIM_AF__PA15__TCH_TIM8_CH1 D(2, 8)
1030 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(4, 8)
1032 #define DEF_TIM_AF__PA14__TCH_TIM8_CH2 D(5, 8)
1034 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(6, 1)
1035 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(6, 1)
1036 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(6, 1)
1037 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(6, 1)
1038 #define DEF_TIM_AF__PA11__TCH_TIM1_CH1N D(6, 1)
1039 #define DEF_TIM_AF__PA12__TCH_TIM1_CH2N D(6, 1)
1041 #define DEF_TIM_AF__PA1__TCH_TIM15_CH1N D(9, 15)
1042 #define DEF_TIM_AF__PA2__TCH_TIM15_CH1 D(9, 15)
1043 #define DEF_TIM_AF__PA3__TCH_TIM15_CH2 D(9, 15)
1045 #define DEF_TIM_AF__PA9__TCH_TIM2_CH3 D(10, 2)
1046 #define DEF_TIM_AF__PA10__TCH_TIM2_CH4 D(10, 2)
1047 #define DEF_TIM_AF__PA11__TCH_TIM4_CH1 D(10, 4)
1048 #define DEF_TIM_AF__PA12__TCH_TIM4_CH2 D(10, 4)
1049 #define DEF_TIM_AF__PA13__TCH_TIM4_CH3 D(10, 4)
1051 #define DEF_TIM_AF__PA11__TCH_TIM1_CH4 D(11, 1)
1054 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
1055 #define DEF_TIM_AF__PB4__TCH_TIM16_CH1 D(1, 16)
1056 #define DEF_TIM_AF__PB6__TCH_TIM16_CH1N D(1, 16)
1057 #define DEF_TIM_AF__PB7__TCH_TIM17_CH1N D(1, 17)
1058 #define DEF_TIM_AF__PB8__TCH_TIM16_CH1 D(1, 16)
1059 #define DEF_TIM_AF__PB9__TCH_TIM17_CH1 D(1, 17)
1060 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
1061 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
1062 #define DEF_TIM_AF__PB14__TCH_TIM15_CH1 D(1, 15)
1063 #define DEF_TIM_AF__PB15__TCH_TIM15_CH2 D(1, 15)
1065 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
1066 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
1067 #define DEF_TIM_AF__PB2__TCH_TIM5_CH1 D(2, 5)
1068 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
1069 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
1070 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
1071 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
1072 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
1073 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
1074 #define DEF_TIM_AF__PB15__TCH_TIM15_CH1N D(2, 15)
1076 #define DEF_TIM_AF__PB2__TCH_TIM20_CH1 D(3, 20)
1077 #define DEF_TIM_AF__PB5__TCH_TIM8_CH3N D(3, 8)
1079 #define DEF_TIM_AF__PB0__TCH_TIM8_CH2N D(4, 8)
1080 #define DEF_TIM_AF__PB1__TCH_TIM8_CH3N D(4, 8)
1081 #define DEF_TIM_AF__PB3__TCH_TIM8_CH1N D(4, 8)
1082 #define DEF_TIM_AF__PB4__TCH_TIM8_CH2N D(4, 8)
1083 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(4, 1)
1085 #define DEF_TIM_AF__PB6__TCH_TIM8_CH1 D(5, 8)
1087 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(6, 1)
1088 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(6, 1)
1089 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(6, 1)
1090 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(6, 1)
1092 #define DEF_TIM_AF__PB5__TCH_TIM17_CH1 D(10, 17)
1093 #define DEF_TIM_AF__PB7__TCH_TIM3_CH4 D(10, 3)
1094 #define DEF_TIM_AF__PB8__TCH_TIM8_CH2 D(10, 8)
1095 #define DEF_TIM_AF__PB9__TCH_TIM8_CH3 D(10, 8)
1097 #define DEF_TIM_AF__PB9__TCH_TIM1_CH3N D(12, 1)
1100 #define DEF_TIM_AF__PC12__TCH_TIM5_CH2 D(1, 5)
1102 #define DEF_TIM_AF__PC0__TCH_TIM1_CH1 D(2, 1)
1103 #define DEF_TIM_AF__PC1__TCH_TIM1_CH2 D(2, 1)
1104 #define DEF_TIM_AF__PC2__TCH_TIM1_CH3 D(2, 1)
1105 #define DEF_TIM_AF__PC3__TCH_TIM1_CH4 D(2, 1)
1106 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
1107 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
1108 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
1109 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
1111 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(4, 8)
1112 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(4, 8)
1113 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(4, 8)
1114 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(4, 8)
1115 #define DEF_TIM_AF__PC10__TCH_TIM8_CH1N D(4, 8)
1116 #define DEF_TIM_AF__PC11__TCH_TIM8_CH2N D(4, 8)
1117 #define DEF_TIM_AF__PC12__TCH_TIM8_CH3N D(4, 8)
1118 #define DEF_TIM_AF__PC13__TCH_TIM1_CH1N D(4, 1)
1120 #define DEF_TIM_AF__PC2__TCH_TIM20_CH2 D(6, 20)
1121 #define DEF_TIM_AF__PC5__TCH_TIM1_CH4N D(6, 1)
1122 #define DEF_TIM_AF__PC8__TCH_TIM20_CH3 D(6, 20)
1123 #define DEF_TIM_AF__PC13__TCH_TIM8_CH4N D(6, 8)