Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / drivers / timer_def.h
blobae867f756bfbccbbc2edbb6b2e48faf1a73a8d20
1 /*
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)
8 * any later version.
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/>.
21 #pragma once
23 #include "platform.h"
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__
29 #else
30 # define DEF_TIM_DMA_COND(...)
31 #endif
33 #if defined(USE_TIMER_MGMT)
34 #define TIMER_GET_IO_TAG(pin) DEFIO_TAG_E(pin)
35 #else
36 #define TIMER_GET_IO_TAG(pin) DEFIO_TAG(pin)
37 #endif
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
44 #ifdef STM32G4
45 #define BTCH_TIM1_CH4N BTCH_TIM1_CH4
46 #endif
48 #define BTCH_TIM8_CH1N BTCH_TIM8_CH1
49 #define BTCH_TIM8_CH2N BTCH_TIM8_CH2
50 #define BTCH_TIM8_CH3N BTCH_TIM8_CH3
51 #ifdef STM32G4
52 #define BTCH_TIM8_CH4N BTCH_TIM8_CH4
53 #endif
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)
74 #ifdef STM32G4
75 #define DEF_TIM_CH__CH_CH4N D(4, 1)
76 #endif
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
134 #define DMA_VAR0 0
135 #define DMA_VAR1 1
136 #define DMA_VAR2 2
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)
146 #if defined(STM32F1)
148 #define DEF_TIM(tim, chan, pin, flags, out) { \
149 tim, \
150 TIMER_GET_IO_TAG(pin), \
151 DEF_TIM_CHANNEL(CH_ ## chan), \
152 flags, \
153 (DEF_TIM_OUTPUT(CH_ ## chan) | out) \
154 DEF_TIM_DMA_COND(/* add comma */ , \
155 DEF_TIM_DMA_CHANNEL(TCH_## tim ## _ ## chan) \
158 /**/
160 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
161 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_Channel_ ## chan_n
163 #define DEF_TIM_DMA_CHANNEL(timch) CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(0, timch))
164 #define DEF_TIM_DMA_CHANNEL__D(dma_n, chan_n) DMA ## dma_n ## _Channel ## chan_n
165 #define DEF_TIM_DMA_CHANNEL__NONE NULL
167 /* add F1 DMA mappings here */
168 // D(dma_n, channel_n)
169 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(1, 2)
170 #define DEF_TIM_DMA__BTCH_TIM1_CH2 NONE
171 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(1, 6)
172 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(1, 4)
174 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5)
175 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 7)
176 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1)
177 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7)
179 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 6)
180 #define DEF_TIM_DMA__BTCH_TIM3_CH2 NONE
181 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 2)
182 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 3)
184 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 1)
185 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 4)
186 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 5)
187 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
189 #elif defined(STM32F3)
191 #define DEF_TIM(tim, chan, pin, flags, out) { \
192 tim, \
193 TIMER_GET_IO_TAG(pin), \
194 DEF_TIM_CHANNEL(CH_ ## chan), \
195 flags, \
196 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
197 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
198 DEF_TIM_DMA_COND(/* add comma */ , \
199 DEF_TIM_DMA_CHANNEL(TCH_## tim ## _ ## chan) \
201 DEF_TIM_DMA_COND(/* add comma */ , \
202 DEF_TIM_DMA_CHANNEL(TCH_## tim ## _UP), \
203 DEF_TIM_DMA_HANDLER(TCH_## tim ## _UP) \
206 /**/
208 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
209 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_Channel_ ## chan_n
211 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
212 #define DEF_TIM_AF__D(af_n) GPIO_AF_ ## af_n
214 #define DEF_TIM_DMA_CHANNEL(timch) CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(0, timch))
215 #define DEF_TIM_DMA_CHANNEL__D(dma_n, chan_n) (dmaResource_t *)DMA ## dma_n ## _Channel ## chan_n
216 #define DEF_TIM_DMA_CHANNEL__NONE NULL
218 #define DEF_TIM_DMA_HANDLER(timch) CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(0, timch))
219 #define DEF_TIM_DMA_HANDLER__D(dma_n, chan_n) DMA ## dma_n ## _CH ## chan_n ## _HANDLER
220 #define DEF_TIM_DMA_HANDLER__NONE 0
223 /* add the DMA mappings here */
224 // D(dma_n, channel_n)
226 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(1, 2)
227 #define DEF_TIM_DMA__BTCH_TIM1_CH2 D(1, 3)
228 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(1, 4)
229 #define DEF_TIM_DMA__BTCH_TIM1_TRIG D(1, 4)
230 #define DEF_TIM_DMA__BTCH_TIM1_COM D(1, 4)
231 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(1, 6)
233 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1)
234 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5)
235 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 7)
236 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7)
238 #define DEF_TIM_DMA__BTCH_TIM3_CH2 NONE
239 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 2)
240 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 3)
241 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 6)
242 #define DEF_TIM_DMA__BTCH_TIM3_TRIG D(1, 6)
244 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 1)
245 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 4)
246 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 5)
247 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
249 #define DEF_TIM_DMA__BTCH_TIM15_CH1 D(1, 5)
250 #define DEF_TIM_DMA__BTCH_TIM15_CH2 NONE
251 #define DEF_TIM_DMA__BTCH_TIM15_UP D(1, 5)
252 #define DEF_TIM_DMA__BTCH_TIM15_TRIG D(1, 5)
253 #define DEF_TIM_DMA__BTCH_TIM15_COM D(1, 5)
255 #ifdef REMAP_TIM16_DMA
256 #define DEF_TIM_DMA__BTCH_TIM16_CH1 D(1, 6)
257 #else
258 #define DEF_TIM_DMA__BTCH_TIM16_CH1 D(1, 3)
259 #endif
261 #ifdef REMAP_TIM17_DMA
262 #define DEF_TIM_DMA__BTCH_TIM17_CH1 D(1, 7)
263 #else
264 #define DEF_TIM_DMA__BTCH_TIM17_CH1 D(1, 1)
265 #endif
267 #define DEF_TIM_DMA__BTCH_TIM8_CH3 D(2, 1)
268 #define DEF_TIM_DMA__BTCH_TIM8_CH4 D(2, 2)
269 #define DEF_TIM_DMA__BTCH_TIM8_TRIG D(2, 2)
270 #define DEF_TIM_DMA__BTCH_TIM8_COM D(2, 2)
271 #define DEF_TIM_DMA__BTCH_TIM8_CH1 D(2, 3)
272 #define DEF_TIM_DMA__BTCH_TIM8_CH2 D(2, 5)
274 // TIM_UP table
275 #define DEF_TIM_DMA__BTCH_TIM1_UP D(1, 5)
276 #define DEF_TIM_DMA__BTCH_TIM2_UP D(1, 2)
277 #define DEF_TIM_DMA__BTCH_TIM3_UP D(1, 3)
278 #define DEF_TIM_DMA__BTCH_TIM4_UP D(1, 7)
279 #define DEF_TIM_DMA__BTCH_TIM6_UP D(2, 3)
280 #define DEF_TIM_DMA__BTCH_TIM7_UP D(2, 4)
281 #define DEF_TIM_DMA__BTCH_TIM8_UP D(2, 1)
282 #define DEF_TIM_DMA__BTCH_TIM15_UP D(1, 5)
283 #ifdef REMAP_TIM16_DMA
284 #define DEF_TIM_DMA__BTCH_TIM16_UP D(1, 6)
285 #else
286 #define DEF_TIM_DMA__BTCH_TIM16_UP D(1, 3)
287 #endif
288 #ifdef REMAP_TIM17_DMA
289 #define DEF_TIM_DMA__BTCH_TIM17_UP D(1, 7)
290 #else
291 #define DEF_TIM_DMA__BTCH_TIM17_UP D(1, 1)
292 #endif
294 // AF table
296 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1)
297 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1)
298 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1)
299 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1)
300 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1)
301 #define DEF_TIM_AF__PA6__TCH_TIM16_CH1 D(1)
302 #define DEF_TIM_AF__PA7__TCH_TIM17_CH1 D(1)
303 #define DEF_TIM_AF__PA12__TCH_TIM16_CH1 D(1)
304 #define DEF_TIM_AF__PA13__TCH_TIM16_CH1N D(1)
305 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1)
307 #define DEF_TIM_AF__PA4__TCH_TIM3_CH2 D(2)
308 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2)
309 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2)
310 #define DEF_TIM_AF__PA15__TCH_TIM8_CH1 D(2)
312 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(4)
314 #define DEF_TIM_AF__PA14__TCH_TIM8_CH2 D(5)
316 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(6)
317 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(6)
318 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(6)
319 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(6)
320 #define DEF_TIM_AF__PA11__TCH_TIM1_CH1N D(6)
321 #define DEF_TIM_AF__PA12__TCH_TIM1_CH2N D(6)
323 #define DEF_TIM_AF__PA1__TCH_TIM15_CH1N D(9)
324 #define DEF_TIM_AF__PA2__TCH_TIM15_CH1 D(9)
325 #define DEF_TIM_AF__PA3__TCH_TIM15_CH2 D(9)
327 #define DEF_TIM_AF__PA9__TCH_TIM2_CH3 D(10)
328 #define DEF_TIM_AF__PA10__TCH_TIM2_CH4 D(10)
329 #define DEF_TIM_AF__PA11__TCH_TIM4_CH1 D(10)
330 #define DEF_TIM_AF__PA12__TCH_TIM4_CH2 D(10)
331 #define DEF_TIM_AF__PA13__TCH_TIM4_CH3 D(10)
332 #define DEF_TIM_AF__PA11__TCH_TIM1_CH4 D(11)
334 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1)
335 #define DEF_TIM_AF__PB4__TCH_TIM16_CH1 D(1)
336 #define DEF_TIM_AF__PB6__TCH_TIM16_CH1N D(1)
337 #define DEF_TIM_AF__PB7__TCH_TIM17_CH1N D(1)
338 #define DEF_TIM_AF__PB8__TCH_TIM16_CH1 D(1)
339 #define DEF_TIM_AF__PB9__TCH_TIM17_CH1 D(1)
340 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1)
341 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1)
342 #define DEF_TIM_AF__PB14__TCH_TIM15_CH1 D(1)
343 #define DEF_TIM_AF__PB15__TCH_TIM15_CH2 D(1)
345 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2)
346 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2)
347 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2)
348 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2)
349 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2)
350 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2)
351 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2)
352 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2)
353 #define DEF_TIM_AF__PB15__TCH_TIM15_CH1N D(2)
355 #define DEF_TIM_AF__PB5__TCH_TIM8_CH3N D(3)
357 #define DEF_TIM_AF__PB0__TCH_TIM8_CH2N D(4)
358 #define DEF_TIM_AF__PB1__TCH_TIM8_CH3N D(4)
359 #define DEF_TIM_AF__PB3__TCH_TIM8_CH1N D(4)
360 #define DEF_TIM_AF__PB4__TCH_TIM8_CH2N D(4)
361 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(4)
363 #define DEF_TIM_AF__PB6__TCH_TIM8_CH1 D(5)
365 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(6)
366 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(6)
367 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(6)
368 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(6)
370 #define DEF_TIM_AF__PB5__TCH_TIM17_CH1 D(10)
371 #define DEF_TIM_AF__PB7__TCH_TIM3_CH4 D(10)
372 #define DEF_TIM_AF__PB8__TCH_TIM8_CH2 D(10)
373 #define DEF_TIM_AF__PB9__TCH_TIM8_CH3 D(10)
375 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2)
376 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2)
377 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2)
378 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2)
380 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(4)
381 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(4)
382 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(4)
383 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(4)
385 #define DEF_TIM_AF__PC10__TCH_TIM8_CH1N D(4)
386 #define DEF_TIM_AF__PC11__TCH_TIM8_CH2N D(4)
387 #define DEF_TIM_AF__PC12__TCH_TIM8_CH3N D(4)
388 #define DEF_TIM_AF__PC13__TCH_TIM8_CH1N D(4)
390 #define DEF_TIM_AF__PD3__TCH_TIM2_CH1 D(2)
391 #define DEF_TIM_AF__PD4__TCH_TIM2_CH2 D(2)
392 #define DEF_TIM_AF__PD6__TCH_TIM2_CH4 D(2)
393 #define DEF_TIM_AF__PD7__TCH_TIM2_CH3 D(2)
395 #define DEF_TIM_AF__PD12__TCH_TIM4_CH1 D(2)
396 #define DEF_TIM_AF__PD13__TCH_TIM4_CH2 D(2)
397 #define DEF_TIM_AF__PD14__TCH_TIM4_CH3 D(2)
398 #define DEF_TIM_AF__PD15__TCH_TIM4_CH4 D(2)
400 #define DEF_TIM_AF__PD1__TCH_TIM8_CH4 D(4)
402 #define DEF_TIM_AF__PF9__TCH_TIM15_CH1 D(3)
403 #define DEF_TIM_AF__PF10__TCH_TIM15_CH2 D(3)
405 #elif defined(STM32F4)
407 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt) { \
408 tim, \
409 TIMER_GET_IO_TAG(pin), \
410 DEF_TIM_CHANNEL(CH_ ## chan), \
411 flags, \
412 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
413 DEF_TIM_AF(TIM_ ## tim) \
414 DEF_TIM_DMA_COND(/* add comma */ , \
415 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
416 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan) \
418 DEF_TIM_DMA_COND(/* add comma */ , \
419 DEF_TIM_DMA_STREAM(0, TCH_## tim ## _UP), \
420 DEF_TIM_DMA_CHANNEL(0, TCH_## tim ## _UP), \
421 DEF_TIM_DMA_HANDLER(0, TCH_## tim ## _UP) \
424 /**/
426 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
427 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_Channel_ ## chan_n
429 #define DEF_TIM_AF(tim) CONCAT(DEF_TIM_AF__, DEF_TIM_TIM_GET(tim))
430 #define DEF_TIM_AF__D(tim_n) GPIO_AF_TIM ## tim_n
432 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
433 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
434 #define DEF_TIM_DMA_CHANNEL__D(dma_n, stream_n, chan_n) DMA_Channel_ ## chan_n
435 #define DEF_TIM_DMA_CHANNEL__NONE DMA_Channel_0
437 #define DEF_TIM_DMA_STREAM(variant, timch) \
438 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
439 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n, chan_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
440 #define DEF_TIM_DMA_STREAM__NONE NULL
442 #define DEF_TIM_DMA_HANDLER(variant, timch) \
443 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
444 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n, chan_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
445 #define DEF_TIM_DMA_HANDLER__NONE 0
448 /* F4 Stream Mappings */
449 // D(DMAx, Stream, Channel)
450 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(2, 6, 0),D(2, 1, 6),D(2, 3, 6)
451 #define DEF_TIM_DMA__BTCH_TIM1_CH2 D(2, 6, 0),D(2, 2, 6)
452 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(2, 6, 0),D(2, 6, 6)
453 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(2, 4, 6)
455 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5, 3)
456 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 6, 3)
457 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1, 3)
458 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7, 3),D(1, 6, 3)
460 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 4, 5)
461 #define DEF_TIM_DMA__BTCH_TIM3_CH2 D(1, 5, 5)
462 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 7, 5)
463 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 2, 5)
465 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 0, 2)
466 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 3, 2)
467 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 7, 2)
469 #define DEF_TIM_DMA__BTCH_TIM5_CH1 D(1, 2, 6)
470 #define DEF_TIM_DMA__BTCH_TIM5_CH2 D(1, 4, 6)
471 #define DEF_TIM_DMA__BTCH_TIM5_CH3 D(1, 0, 6)
472 #define DEF_TIM_DMA__BTCH_TIM5_CH4 D(1, 1, 6),D(1, 3, 6)
474 #define DEF_TIM_DMA__BTCH_TIM8_CH1 D(2, 2, 0),D(2, 2, 7)
475 #define DEF_TIM_DMA__BTCH_TIM8_CH2 D(2, 2, 0),D(2, 3, 7)
476 #define DEF_TIM_DMA__BTCH_TIM8_CH3 D(2, 2, 0),D(2, 4, 7)
477 #define DEF_TIM_DMA__BTCH_TIM8_CH4 D(2, 7, 7)
479 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
481 #define DEF_TIM_DMA__BTCH_TIM9_CH1 NONE
482 #define DEF_TIM_DMA__BTCH_TIM9_CH2 NONE
484 #define DEF_TIM_DMA__BTCH_TIM10_CH1 NONE
486 #define DEF_TIM_DMA__BTCH_TIM11_CH1 NONE
488 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
489 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
491 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
493 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
495 // TIM_UP table
496 #define DEF_TIM_DMA__BTCH_TIM1_UP D(2, 5, 6)
497 #define DEF_TIM_DMA__BTCH_TIM2_UP D(1, 7, 3)
498 #define DEF_TIM_DMA__BTCH_TIM3_UP D(1, 2, 5)
499 #define DEF_TIM_DMA__BTCH_TIM4_UP D(1, 6, 2)
500 #define DEF_TIM_DMA__BTCH_TIM5_UP D(1, 0, 6)
501 #define DEF_TIM_DMA__BTCH_TIM6_UP D(1, 1, 7)
502 #define DEF_TIM_DMA__BTCH_TIM7_UP D(1, 4, 1)
503 #define DEF_TIM_DMA__BTCH_TIM8_UP D(2, 1, 7)
504 #define DEF_TIM_DMA__BTCH_TIM9_UP NONE
505 #define DEF_TIM_DMA__BTCH_TIM10_UP NONE
506 #define DEF_TIM_DMA__BTCH_TIM11_UP NONE
507 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
508 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
509 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
511 #elif defined(STM32F7)
512 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt) { \
513 tim, \
514 TIMER_GET_IO_TAG(pin), \
515 DEF_TIM_CHANNEL(CH_ ## chan), \
516 flags, \
517 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
518 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
519 DEF_TIM_DMA_COND(/* add comma */ , \
520 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
521 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan) \
523 DEF_TIM_DMA_COND(/* add comma */ , \
524 DEF_TIM_DMA_STREAM(0, TCH_## tim ## _UP), \
525 DEF_TIM_DMA_CHANNEL(0, TCH_## tim ## _UP), \
526 DEF_TIM_DMA_HANDLER(0, TCH_## tim ## _UP) \
529 /**/
531 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
532 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
534 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
535 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
537 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
538 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
539 #define DEF_TIM_DMA_CHANNEL__D(dma_n, stream_n, chan_n) DMA_CHANNEL_ ## chan_n
540 #define DEF_TIM_DMA_CHANNEL__NONE DMA_CHANNEL_0
542 #define DEF_TIM_DMA_STREAM(variant, timch) \
543 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
544 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n, chan_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
545 #define DEF_TIM_DMA_STREAM__NONE NULL
547 #define DEF_TIM_DMA_HANDLER(variant, timch) \
548 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
549 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n, chan_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
550 #define DEF_TIM_DMA_HANDLER__NONE 0
552 /* F7 Stream Mappings */
553 // D(DMAx, Stream, Channel)
554 #define DEF_TIM_DMA__BTCH_TIM1_CH1 D(2, 6, 0),D(2, 1, 6),D(2, 3, 6)
555 #define DEF_TIM_DMA__BTCH_TIM1_CH2 D(2, 6, 0),D(2, 2, 6)
556 #define DEF_TIM_DMA__BTCH_TIM1_CH3 D(2, 6, 0),D(2, 6, 6)
557 #define DEF_TIM_DMA__BTCH_TIM1_CH4 D(2, 4, 6)
559 #define DEF_TIM_DMA__BTCH_TIM2_CH1 D(1, 5, 3)
560 #define DEF_TIM_DMA__BTCH_TIM2_CH2 D(1, 6, 3)
561 #define DEF_TIM_DMA__BTCH_TIM2_CH3 D(1, 1, 3)
562 #define DEF_TIM_DMA__BTCH_TIM2_CH4 D(1, 7, 3),D(1, 6, 3)
564 #define DEF_TIM_DMA__BTCH_TIM3_CH1 D(1, 4, 5)
565 #define DEF_TIM_DMA__BTCH_TIM3_CH2 D(1, 5, 5)
566 #define DEF_TIM_DMA__BTCH_TIM3_CH3 D(1, 7, 5)
567 #define DEF_TIM_DMA__BTCH_TIM3_CH4 D(1, 2, 5)
569 #define DEF_TIM_DMA__BTCH_TIM4_CH1 D(1, 0, 2)
570 #define DEF_TIM_DMA__BTCH_TIM4_CH2 D(1, 3, 2)
571 #define DEF_TIM_DMA__BTCH_TIM4_CH3 D(1, 7, 2)
573 #define DEF_TIM_DMA__BTCH_TIM5_CH1 D(1, 2, 6)
574 #define DEF_TIM_DMA__BTCH_TIM5_CH2 D(1, 4, 6)
575 #define DEF_TIM_DMA__BTCH_TIM5_CH3 D(1, 0, 6)
576 #define DEF_TIM_DMA__BTCH_TIM5_CH4 D(1, 1, 6),D(1, 3, 6)
578 #define DEF_TIM_DMA__BTCH_TIM8_CH1 D(2, 2, 0),D(2, 2, 7)
579 #define DEF_TIM_DMA__BTCH_TIM8_CH2 D(2, 2, 0),D(2, 3, 7)
580 #define DEF_TIM_DMA__BTCH_TIM8_CH3 D(2, 2, 0),D(2, 4, 7)
581 #define DEF_TIM_DMA__BTCH_TIM8_CH4 D(2, 7, 7)
583 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
585 #define DEF_TIM_DMA__BTCH_TIM9_CH1 NONE
586 #define DEF_TIM_DMA__BTCH_TIM9_CH2 NONE
588 #define DEF_TIM_DMA__BTCH_TIM10_CH1 NONE
590 #define DEF_TIM_DMA__BTCH_TIM11_CH1 NONE
592 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
593 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
595 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
597 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
599 // TIM_UP table
600 #define DEF_TIM_DMA__BTCH_TIM1_UP D(2, 5, 6)
601 #define DEF_TIM_DMA__BTCH_TIM2_UP D(1, 7, 3)
602 #define DEF_TIM_DMA__BTCH_TIM3_UP D(1, 2, 5)
603 #define DEF_TIM_DMA__BTCH_TIM4_UP D(1, 6, 2)
604 #define DEF_TIM_DMA__BTCH_TIM5_UP D(1, 0, 6)
605 #define DEF_TIM_DMA__BTCH_TIM6_UP D(1, 1, 7)
606 #define DEF_TIM_DMA__BTCH_TIM7_UP D(1, 4, 1)
607 #define DEF_TIM_DMA__BTCH_TIM8_UP D(2, 1, 7)
608 #define DEF_TIM_DMA__BTCH_TIM9_UP NONE
609 #define DEF_TIM_DMA__BTCH_TIM10_UP NONE
610 #define DEF_TIM_DMA__BTCH_TIM11_UP NONE
611 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
612 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
613 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
615 // AF table
617 // NONE
618 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(1, 1)
619 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(1, 1)
620 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(1, 1)
621 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(1, 1)
622 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
623 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
624 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
625 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
627 //PORTA
628 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
629 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
630 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
631 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
632 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
633 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(1, 1)
634 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(1, 1)
635 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(1, 1)
636 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(1, 1)
637 #define DEF_TIM_AF__PA11__TCH_TIM1_CH1N D(1, 1)
638 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
640 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
641 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
642 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
643 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
644 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
645 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
647 #define DEF_TIM_AF__PA2__TCH_TIM9_CH1 D(3, 9)
648 #define DEF_TIM_AF__PA3__TCH_TIM9_CH2 D(3, 9)
649 #define DEF_TIM_AF__PA5__TCH_TIM8_CH1N D(3, 8)
650 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(3, 8)
652 #define DEF_TIM_AF__PA6__TCH_TIM13_CH1 D(9, 13)
653 #define DEF_TIM_AF__PA7__TCH_TIM14_CH1 D(9, 14)
655 //PORTB
656 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(1, 1)
657 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(1, 1)
658 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
659 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
660 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
661 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(1, 1)
662 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(1, 1)
663 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(1, 1)
665 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
666 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
667 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
668 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
669 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
670 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
671 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
672 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
674 #define DEF_TIM_AF__PB0__TCH_TIM8_CH2N D(3, 8)
675 #define DEF_TIM_AF__PB1__TCH_TIM8_CH3N D(3, 8)
676 #define DEF_TIM_AF__PB8__TCH_TIM10_CH1 D(3, 10)
677 #define DEF_TIM_AF__PB9__TCH_TIM11_CH1 D(3, 11)
678 #define DEF_TIM_AF__PB14__TCH_TIM8_CH2N D(3, 8)
679 #define DEF_TIM_AF__PB15__TCH_TIM8_CH3N D(3, 8)
681 #define DEF_TIM_AF__PB14__TCH_TIM12_CH1 D(9, 12)
682 #define DEF_TIM_AF__PB15__TCH_TIM12_CH2 D(9, 12)
684 //PORTC
685 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
686 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
687 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
688 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
690 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(3, 8)
691 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(3, 8)
692 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(3, 8)
693 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(3, 8)
695 //PORTD
696 #define DEF_TIM_AF__PD12__TCH_TIM4_CH1 D(2, 4)
697 #define DEF_TIM_AF__PD13__TCH_TIM4_CH2 D(2, 4)
698 #define DEF_TIM_AF__PD14__TCH_TIM4_CH3 D(2, 4)
699 #define DEF_TIM_AF__PD15__TCH_TIM4_CH4 D(2, 4)
701 //PORTE
702 #define DEF_TIM_AF__PE8__TCH_TIM1_CH1N D(1, 1)
703 #define DEF_TIM_AF__PE9__TCH_TIM1_CH1 D(1, 1)
704 #define DEF_TIM_AF__PE10__TCH_TIM1_CH2N D(1, 1)
705 #define DEF_TIM_AF__PE11__TCH_TIM1_CH2 D(1, 1)
706 #define DEF_TIM_AF__PE12__TCH_TIM1_CH3N D(1, 1)
707 #define DEF_TIM_AF__PE13__TCH_TIM1_CH3 D(1, 1)
708 #define DEF_TIM_AF__PE14__TCH_TIM1_CH4 D(1, 1)
710 #define DEF_TIM_AF__PE5__TCH_TIM9_CH1 D(3, 9)
711 #define DEF_TIM_AF__PE6__TCH_TIM9_CH2 D(3, 9)
713 //PORTF
714 #define DEF_TIM_AF__PF6__TCH_TIM10_CH1 D(3, 10)
715 #define DEF_TIM_AF__PF7__TCH_TIM11_CH1 D(3, 11)
717 //PORTH
718 #define DEF_TIM_AF__PH10__TCH_TIM5_CH1 D(2, 5)
719 #define DEF_TIM_AF__PH11__TCH_TIM5_CH2 D(2, 5)
720 #define DEF_TIM_AF__PH12__TCH_TIM5_CH3 D(2, 5)
722 #define DEF_TIM_AF__PH13__TCH_TIM8_CH1N D(3, 8)
723 #define DEF_TIM_AF__PH14__TCH_TIM8_CH2N D(3, 8)
724 #define DEF_TIM_AF__PH15__TCH_TIM8_CH3N D(3, 8)
726 #define DEF_TIM_AF__PH6__TCH_TIM12_CH1 D(9, 12)
727 #define DEF_TIM_AF__PH9__TCH_TIM12_CH2 D(9, 12)
729 //PORTI
730 #define DEF_TIM_AF__PI0__TCH_TIM5_CH4 D(2, 5)
732 #define DEF_TIM_AF__PI2__TCH_TIM8_CH4 D(3, 8)
733 #define DEF_TIM_AF__PI5__TCH_TIM8_CH1 D(3, 8)
734 #define DEF_TIM_AF__PI6__TCH_TIM8_CH2 D(3, 8)
735 #define DEF_TIM_AF__PI7__TCH_TIM8_CH3 D(3, 8)
737 #elif defined(STM32H7)
738 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt, upopt) { \
739 tim, \
740 TIMER_GET_IO_TAG(pin), \
741 DEF_TIM_CHANNEL(CH_ ## chan), \
742 flags, \
743 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
744 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
745 DEF_TIM_DMA_COND(/* add comma */ , \
746 DEF_TIM_DMA_STREAM(dmaopt, TCH_## tim ## _ ## chan), \
747 DEF_TIM_DMA_REQUEST(TCH_## tim ## _ ## chan) \
749 DEF_TIM_DMA_COND(/* add comma */ , \
750 DEF_TIM_DMA_STREAM(upopt, TCH_## tim ## _UP), \
751 DEF_TIM_DMA_REQUEST(TCH_## tim ## _UP), \
752 DEF_TIM_DMA_HANDLER(upopt, TCH_## tim ## _UP) \
755 /**/
757 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
758 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
760 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
761 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
763 #define DEF_TIM_DMA_STREAM(variant, timch) \
764 CONCAT(DEF_TIM_DMA_STREAM__, DEF_TIM_DMA_GET(variant, timch))
765 #define DEF_TIM_DMA_STREAM__D(dma_n, stream_n) (dmaResource_t *)DMA ## dma_n ## _Stream ## stream_n
766 #define DEF_TIM_DMA_STREAM__NONE NULL
768 // XXX This is awful. There must be some smart way of doing this ...
769 #define DEF_TIM_DMA_REQUEST(timch) \
770 CONCAT(DEF_TIM_DMA_REQ__, DEF_TIM_TCH2BTCH(timch))
772 #define DEF_TIM_DMA_HANDLER(variant, timch) \
773 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
774 #define DEF_TIM_DMA_HANDLER__D(dma_n, stream_n) DMA ## dma_n ## _ST ## stream_n ## _HANDLER
775 #define DEF_TIM_DMA_HANDLER__NONE 0
777 /* H7 Stream Mappings */
778 // D(DMAx, Stream)
780 // H7 has DMAMUX that allow arbitrary assignment of peripherals to streams.
782 #define DEF_TIM_DMA_FULL \
783 D(1, 0), D(1, 1), D(1, 2), D(1, 3), D(1, 4), D(1, 5), D(1, 6), D(1, 7), \
784 D(2, 0), D(2, 1), D(2, 2), D(2, 3), D(2, 4), D(2, 5), D(2, 6), D(2, 7)
786 #define DEF_TIM_DMA__BTCH_TIM1_CH1 DEF_TIM_DMA_FULL
787 #define DEF_TIM_DMA__BTCH_TIM1_CH2 DEF_TIM_DMA_FULL
788 #define DEF_TIM_DMA__BTCH_TIM1_CH3 DEF_TIM_DMA_FULL
789 #define DEF_TIM_DMA__BTCH_TIM1_CH4 DEF_TIM_DMA_FULL
791 #define DEF_TIM_DMA__BTCH_TIM2_CH1 DEF_TIM_DMA_FULL
792 #define DEF_TIM_DMA__BTCH_TIM2_CH2 DEF_TIM_DMA_FULL
793 #define DEF_TIM_DMA__BTCH_TIM2_CH3 DEF_TIM_DMA_FULL
794 #define DEF_TIM_DMA__BTCH_TIM2_CH4 DEF_TIM_DMA_FULL
796 #define DEF_TIM_DMA__BTCH_TIM3_CH1 DEF_TIM_DMA_FULL
797 #define DEF_TIM_DMA__BTCH_TIM3_CH2 DEF_TIM_DMA_FULL
798 #define DEF_TIM_DMA__BTCH_TIM3_CH3 DEF_TIM_DMA_FULL
799 #define DEF_TIM_DMA__BTCH_TIM3_CH4 DEF_TIM_DMA_FULL
801 #define DEF_TIM_DMA__BTCH_TIM4_CH1 DEF_TIM_DMA_FULL
802 #define DEF_TIM_DMA__BTCH_TIM4_CH2 DEF_TIM_DMA_FULL
803 #define DEF_TIM_DMA__BTCH_TIM4_CH3 DEF_TIM_DMA_FULL
804 #define DEF_TIM_DMA__BTCH_TIM4_CH4 NONE
806 #define DEF_TIM_DMA__BTCH_TIM5_CH1 DEF_TIM_DMA_FULL
807 #define DEF_TIM_DMA__BTCH_TIM5_CH2 DEF_TIM_DMA_FULL
808 #define DEF_TIM_DMA__BTCH_TIM5_CH3 DEF_TIM_DMA_FULL
809 #define DEF_TIM_DMA__BTCH_TIM5_CH4 DEF_TIM_DMA_FULL
811 #define DEF_TIM_DMA__BTCH_TIM8_CH1 DEF_TIM_DMA_FULL
812 #define DEF_TIM_DMA__BTCH_TIM8_CH2 DEF_TIM_DMA_FULL
813 #define DEF_TIM_DMA__BTCH_TIM8_CH3 DEF_TIM_DMA_FULL
814 #define DEF_TIM_DMA__BTCH_TIM8_CH4 DEF_TIM_DMA_FULL
816 #define DEF_TIM_DMA__BTCH_TIM12_CH1 NONE
817 #define DEF_TIM_DMA__BTCH_TIM12_CH2 NONE
819 #define DEF_TIM_DMA__BTCH_TIM13_CH1 NONE
821 #define DEF_TIM_DMA__BTCH_TIM14_CH1 NONE
823 #define DEF_TIM_DMA__BTCH_TIM15_CH1 DEF_TIM_DMA_FULL
824 #define DEF_TIM_DMA__BTCH_TIM15_CH2 NONE
826 #define DEF_TIM_DMA__BTCH_TIM16_CH1 DEF_TIM_DMA_FULL
828 #define DEF_TIM_DMA__BTCH_TIM17_CH1 DEF_TIM_DMA_FULL
830 #if defined(STM32H723xx) || defined(STM32H725xx)
831 #define DEF_TIM_DMA__BTCH_TIM23_CH1 DEF_TIM_DMA_FULL
832 #define DEF_TIM_DMA__BTCH_TIM23_CH2 DEF_TIM_DMA_FULL
833 #define DEF_TIM_DMA__BTCH_TIM23_CH3 DEF_TIM_DMA_FULL
834 #define DEF_TIM_DMA__BTCH_TIM23_CH4 DEF_TIM_DMA_FULL
836 #define DEF_TIM_DMA__BTCH_TIM24_CH1 DEF_TIM_DMA_FULL
837 #define DEF_TIM_DMA__BTCH_TIM24_CH2 DEF_TIM_DMA_FULL
838 #define DEF_TIM_DMA__BTCH_TIM24_CH3 DEF_TIM_DMA_FULL
839 #define DEF_TIM_DMA__BTCH_TIM24_CH4 DEF_TIM_DMA_FULL
840 #endif
842 // TIM_UP table
843 #define DEF_TIM_DMA__BTCH_TIM1_UP DEF_TIM_DMA_FULL
844 #define DEF_TIM_DMA__BTCH_TIM2_UP DEF_TIM_DMA_FULL
845 #define DEF_TIM_DMA__BTCH_TIM3_UP DEF_TIM_DMA_FULL
846 #define DEF_TIM_DMA__BTCH_TIM4_UP DEF_TIM_DMA_FULL
847 #define DEF_TIM_DMA__BTCH_TIM5_UP DEF_TIM_DMA_FULL
848 #define DEF_TIM_DMA__BTCH_TIM6_UP DEF_TIM_DMA_FULL
849 #define DEF_TIM_DMA__BTCH_TIM7_UP DEF_TIM_DMA_FULL
850 #define DEF_TIM_DMA__BTCH_TIM8_UP DEF_TIM_DMA_FULL
851 #define DEF_TIM_DMA__BTCH_TIM12_UP NONE
852 #define DEF_TIM_DMA__BTCH_TIM13_UP NONE
853 #define DEF_TIM_DMA__BTCH_TIM14_UP NONE
854 #define DEF_TIM_DMA__BTCH_TIM15_UP DEF_TIM_DMA_FULL
855 #define DEF_TIM_DMA__BTCH_TIM16_UP DEF_TIM_DMA_FULL
856 #define DEF_TIM_DMA__BTCH_TIM17_UP DEF_TIM_DMA_FULL
858 #if defined(STM32H723xx) || defined(STM32H725xx)
859 #define DEF_TIM_DMA__BTCH_TIM23_UP DEF_TIM_DMA_FULL
860 #define DEF_TIM_DMA__BTCH_TIM24_UP DEF_TIM_DMA_FULL
861 #endif
863 // TIMx_CHy request table
865 // This is not defined in stm32h7xx_hal_timer.h
866 #define DMA_REQUEST_NONE 255
868 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH1 DMA_REQUEST_TIM1_CH1
869 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH2 DMA_REQUEST_TIM1_CH2
870 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH3 DMA_REQUEST_TIM1_CH3
871 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH4 DMA_REQUEST_TIM1_CH4
873 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH1 DMA_REQUEST_TIM2_CH1
874 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH2 DMA_REQUEST_TIM2_CH2
875 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH3 DMA_REQUEST_TIM2_CH3
876 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH4 DMA_REQUEST_TIM2_CH4
878 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH1 DMA_REQUEST_TIM3_CH1
879 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH2 DMA_REQUEST_TIM3_CH2
880 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH3 DMA_REQUEST_TIM3_CH3
881 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH4 DMA_REQUEST_TIM3_CH4
883 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH1 DMA_REQUEST_TIM4_CH1
884 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH2 DMA_REQUEST_TIM4_CH2
885 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH3 DMA_REQUEST_TIM4_CH3
886 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH4 DMA_REQUEST_NONE
888 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH1 DMA_REQUEST_TIM5_CH1
889 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH2 DMA_REQUEST_TIM5_CH2
890 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH3 DMA_REQUEST_TIM5_CH3
891 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH4 DMA_REQUEST_TIM5_CH4
893 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH1 DMA_REQUEST_TIM8_CH1
894 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH2 DMA_REQUEST_TIM8_CH2
895 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH3 DMA_REQUEST_TIM8_CH3
896 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH4 DMA_REQUEST_TIM8_CH4
898 #define DEF_TIM_DMA_REQ__BTCH_TIM12_CH1 DMA_REQUEST_NONE
899 #define DEF_TIM_DMA_REQ__BTCH_TIM12_CH2 DMA_REQUEST_NONE
901 #define DEF_TIM_DMA_REQ__BTCH_TIM13_CH1 DMA_REQUEST_NONE
903 #define DEF_TIM_DMA_REQ__BTCH_TIM14_CH1 DMA_REQUEST_NONE
905 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH1 DMA_REQUEST_TIM15_CH1
906 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH2 DMA_REQUEST_NONE
908 #define DEF_TIM_DMA_REQ__BTCH_TIM16_CH1 DMA_REQUEST_TIM16_CH1
910 #define DEF_TIM_DMA_REQ__BTCH_TIM17_CH1 DMA_REQUEST_TIM17_CH1
912 #if defined(STM32H723xx) || defined(STM32H725xx)
913 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH1 DMA_REQUEST_TIM23_CH1
914 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH2 DMA_REQUEST_TIM23_CH2
915 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH3 DMA_REQUEST_TIM23_CH3
916 #define DEF_TIM_DMA_REQ__BTCH_TIM23_CH4 DMA_REQUEST_TIM23_CH4
918 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH1 DMA_REQUEST_TIM24_CH1
919 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH2 DMA_REQUEST_TIM24_CH2
920 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH3 DMA_REQUEST_TIM24_CH3
921 #define DEF_TIM_DMA_REQ__BTCH_TIM24_CH4 DMA_REQUEST_TIM24_CH4
922 #endif
924 // TIM_UP request table
925 #define DEF_TIM_DMA_REQ__BTCH_TIM1_UP DMA_REQUEST_TIM1_UP
926 #define DEF_TIM_DMA_REQ__BTCH_TIM2_UP DMA_REQUEST_TIM2_UP
927 #define DEF_TIM_DMA_REQ__BTCH_TIM3_UP DMA_REQUEST_TIM3_UP
928 #define DEF_TIM_DMA_REQ__BTCH_TIM4_UP DMA_REQUEST_TIM4_UP
929 #define DEF_TIM_DMA_REQ__BTCH_TIM5_UP DMA_REQUEST_TIM5_UP
930 #define DEF_TIM_DMA_REQ__BTCH_TIM6_UP DMA_REQUEST_TIM6_UP
931 #define DEF_TIM_DMA_REQ__BTCH_TIM7_UP DMA_REQUEST_TIM7_UP
932 #define DEF_TIM_DMA_REQ__BTCH_TIM8_UP DMA_REQUEST_TIM8_UP
933 #define DEF_TIM_DMA_REQ__BTCH_TIM12_UP DMA_REQUEST_NONE
934 #define DEF_TIM_DMA_REQ__BTCH_TIM13_UP DMA_REQUEST_NONE
935 #define DEF_TIM_DMA_REQ__BTCH_TIM14_UP DMA_REQUEST_NONE
936 #define DEF_TIM_DMA_REQ__BTCH_TIM15_UP DMA_REQUEST_TIM15_UP
937 #define DEF_TIM_DMA_REQ__BTCH_TIM16_UP DMA_REQUEST_TIM16_UP
938 #define DEF_TIM_DMA_REQ__BTCH_TIM17_UP DMA_REQUEST_TIM17_UP
940 #if defined(STM32H723xx) || defined(STM32H725xx)
941 #define DEF_TIM_DMA_REQ__BTCH_TIM23_UP DMA_REQUEST_TIM23_UP
942 #define DEF_TIM_DMA_REQ__BTCH_TIM24_UP DMA_REQUEST_TIM24_UP
943 #endif
945 // AF table
947 // NONE
948 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(1, 1)
949 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(1, 1)
950 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(1, 1)
951 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(1, 1)
952 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
953 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
954 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
955 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
957 //PORTA
958 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
959 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
960 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
961 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
962 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
963 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(1, 1)
964 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(1, 1)
965 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(1, 1)
966 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(1, 1)
967 #define DEF_TIM_AF__PA11__TCH_TIM1_CH4 D(1, 1)
968 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
970 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
971 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
972 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
973 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
974 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
975 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
977 #define DEF_TIM_AF__PA5__TCH_TIM8_CH1N D(3, 8)
978 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(3, 8)
980 #define DEF_TIM_AF__PA6__TCH_TIM13_CH1 D(9, 13)
981 #define DEF_TIM_AF__PA7__TCH_TIM14_CH1 D(9, 14)
983 #define DEF_TIM_AF__PA1__TCH_TIM15_CH1N D(4, 15)
984 #define DEF_TIM_AF__PA2__TCH_TIM15_CH1 D(4, 15)
985 #define DEF_TIM_AF__PA3__TCH_TIM15_CH2 D(4, 15)
987 //PORTB
988 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(1, 1)
989 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(1, 1)
990 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
991 #define DEF_TIM_AF__PB6__TCH_TIM16_CH1N D(1, 16)
992 #define DEF_TIM_AF__PB7__TCH_TIM17_CH1N D(1, 17)
993 #define DEF_TIM_AF__PB8__TCH_TIM16_CH1 D(1, 16)
994 #define DEF_TIM_AF__PB9__TCH_TIM17_CH1 D(1, 17)
995 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
996 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
997 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(1, 1)
998 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(1, 1)
999 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(1, 1)
1001 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
1002 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
1003 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
1004 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
1005 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
1006 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
1007 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
1008 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
1010 #define DEF_TIM_AF__PB14__TCH_TIM12_CH1 D(2, 12)
1011 #define DEF_TIM_AF__PB15__TCH_TIM12_CH2 D(2, 12)
1013 //PORTC
1014 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
1015 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
1016 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
1017 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
1019 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(3, 8)
1020 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(3, 8)
1021 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(3, 8)
1022 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(3, 8)
1024 //PORTD
1025 #define DEF_TIM_AF__PD12__TCH_TIM4_CH1 D(2, 4)
1026 #define DEF_TIM_AF__PD13__TCH_TIM4_CH2 D(2, 4)
1027 #define DEF_TIM_AF__PD14__TCH_TIM4_CH3 D(2, 4)
1028 #define DEF_TIM_AF__PD15__TCH_TIM4_CH4 D(2, 4)
1030 //PORTE
1031 #define DEF_TIM_AF__PE8__TCH_TIM1_CH1N D(1, 1)
1032 #define DEF_TIM_AF__PE9__TCH_TIM1_CH1 D(1, 1)
1033 #define DEF_TIM_AF__PE10__TCH_TIM1_CH2N D(1, 1)
1034 #define DEF_TIM_AF__PE11__TCH_TIM1_CH2 D(1, 1)
1035 #define DEF_TIM_AF__PE12__TCH_TIM1_CH3N D(1, 1)
1036 #define DEF_TIM_AF__PE13__TCH_TIM1_CH3 D(1, 1)
1037 #define DEF_TIM_AF__PE14__TCH_TIM1_CH4 D(1, 1)
1039 #define DEF_TIM_AF__PE4__TCH_TIM15_CH1N D(4, 15)
1040 #define DEF_TIM_AF__PE5__TCH_TIM15_CH1 D(4, 15)
1041 #define DEF_TIM_AF__PE6__TCH_TIM15_CH2 D(4, 15)
1043 //PORTF
1044 #define DEF_TIM_AF__PF6__TCH_TIM16_CH1 D(1, 16)
1045 #define DEF_TIM_AF__PF7__TCH_TIM17_CH1 D(1, 17)
1046 #define DEF_TIM_AF__PF8__TCH_TIM16_CH1N D(1, 16)
1047 #define DEF_TIM_AF__PF9__TCH_TIM17_CH1N D(1, 17)
1049 #define DEF_TIM_AF__PF8__TCH_TIM13_CH1N D(9, 13)
1050 #define DEF_TIM_AF__PF9__TCH_TIM14_CH1N D(9, 14)
1052 #if defined(STM32H723xx) || defined(STM32H725xx)
1053 #define DEF_TIM_AF__PF0__TCH_TIM23_CH1 D(13, 23)
1054 #define DEF_TIM_AF__PF1__TCH_TIM23_CH2 D(13, 23)
1055 #define DEF_TIM_AF__PF2__TCH_TIM23_CH3 D(13, 23)
1056 #define DEF_TIM_AF__PF3__TCH_TIM23_CH4 D(13, 23)
1057 #define DEF_TIM_AF__PF6__TCH_TIM23_CH1 D(13, 23)
1058 #define DEF_TIM_AF__PF7__TCH_TIM23_CH2 D(13, 23)
1059 #define DEF_TIM_AF__PF8__TCH_TIM23_CH3 D(13, 23)
1060 #define DEF_TIM_AF__PF9__TCH_TIM23_CH4 D(13, 23)
1062 #define DEF_TIM_AF__PF11__TCH_TIM24_CH1 D(14, 24)
1063 #define DEF_TIM_AF__PF12__TCH_TIM24_CH2 D(14, 24)
1064 #define DEF_TIM_AF__PF13__TCH_TIM24_CH3 D(14, 24)
1065 #define DEF_TIM_AF__PF14__TCH_TIM24_CH4 D(14, 24)
1066 #endif
1068 //PORTH
1069 #define DEF_TIM_AF__PH6__TCH_TIM12_CH1 D(2, 12)
1070 #define DEF_TIM_AF__PH9__TCH_TIM12_CH2 D(2, 12)
1071 #define DEF_TIM_AF__PH10__TCH_TIM5_CH1 D(2, 5)
1072 #define DEF_TIM_AF__PH11__TCH_TIM5_CH2 D(2, 5)
1073 #define DEF_TIM_AF__PH12__TCH_TIM5_CH3 D(2, 5)
1074 #define DEF_TIM_AF__PH13__TCH_TIM8_CH1N D(3, 8)
1075 #define DEF_TIM_AF__PH14__TCH_TIM8_CH2N D(3, 8)
1076 #define DEF_TIM_AF__PH15__TCH_TIM8_CH3N D(3, 8)
1078 //PORTI
1079 #define DEF_TIM_AF__PI0__TCH_TIM5_CH4 D(2, 5)
1081 #define DEF_TIM_AF__PI2__TCH_TIM8_CH4 D(3, 8)
1082 #define DEF_TIM_AF__PI5__TCH_TIM8_CH1 D(3, 8)
1083 #define DEF_TIM_AF__PI6__TCH_TIM8_CH2 D(3, 8)
1084 #define DEF_TIM_AF__PI7__TCH_TIM8_CH3 D(3, 8)
1086 #elif defined(STM32G4)
1088 // Missing from FW1.0.0 library?
1089 #define GPIO_AF12_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */
1091 #define DEF_TIM(tim, chan, pin, flags, out, dmaopt, upopt) { \
1092 tim, \
1093 TIMER_GET_IO_TAG(pin), \
1094 DEF_TIM_CHANNEL(CH_ ## chan), \
1095 flags, \
1096 (DEF_TIM_OUTPUT(CH_ ## chan) | out), \
1097 DEF_TIM_AF(TCH_## tim ## _ ## chan, pin) \
1098 DEF_TIM_DMA_COND(/* add comma */ , \
1099 DEF_TIM_DMA_CHANNEL(dmaopt, TCH_## tim ## _ ## chan), \
1100 DEF_TIM_DMA_REQUEST(TCH_## tim ## _ ## chan) \
1102 DEF_TIM_DMA_COND(/* add comma */ , \
1103 DEF_TIM_DMA_CHANNEL(upopt, TCH_## tim ## _UP), \
1104 DEF_TIM_DMA_REQUEST(TCH_## tim ## _UP), \
1105 DEF_TIM_DMA_HANDLER(upopt, TCH_## tim ## _UP) \
1108 /**/
1110 #define DEF_TIM_CHANNEL(ch) CONCAT(DEF_TIM_CHANNEL__, DEF_TIM_CH_GET(ch))
1111 #define DEF_TIM_CHANNEL__D(chan_n, n_channel) TIM_CHANNEL_ ## chan_n
1113 #define DEF_TIM_AF(timch, pin) CONCAT(DEF_TIM_AF__, DEF_TIM_AF_GET(timch, pin))
1114 #define DEF_TIM_AF__D(af_n, tim_n) GPIO_AF ## af_n ## _TIM ## tim_n
1116 #define DEF_TIM_DMA_CHANNEL(variant, timch) \
1117 CONCAT(DEF_TIM_DMA_CHANNEL__, DEF_TIM_DMA_GET(variant, timch))
1118 #define DEF_TIM_DMA_CHANNEL__D(dma_n, channel_n) (dmaResource_t *)DMA ## dma_n ## _Channel ## channel_n
1119 #define DEF_TIM_DMA_CHANNEL__NONE NULL
1121 // XXX This is awful. There must be some smart way of doing this ...
1122 #define DEF_TIM_DMA_REQUEST(timch) \
1123 CONCAT(DEF_TIM_DMA_REQ__, DEF_TIM_TCH2BTCH(timch))
1125 #define DEF_TIM_DMA_HANDLER(variant, timch) \
1126 CONCAT(DEF_TIM_DMA_HANDLER__, DEF_TIM_DMA_GET(variant, timch))
1127 #define DEF_TIM_DMA_HANDLER__D(dma_n, channel_n) DMA ## dma_n ## _CH ## channel_n ## _HANDLER
1128 #define DEF_TIM_DMA_HANDLER__NONE 0
1130 /* G4 Channel Mappings */
1131 // D(DMAx, Stream)
1133 // G4 has DMAMUX that allow arbitrary assignment of peripherals to streams.
1135 #define DEF_TIM_DMA_FULL \
1136 D(1, 1), D(1, 2), D(1, 3), D(1, 4), D(1, 5), D(1, 6), D(1, 7), D(1, 8), \
1137 D(2, 1), D(2, 2), D(2, 3), D(2, 4), D(2, 5), D(2, 6), D(2, 7), D(2, 8)
1139 #define DEF_TIM_DMA__BTCH_TIM1_CH1 DEF_TIM_DMA_FULL
1140 #define DEF_TIM_DMA__BTCH_TIM1_CH2 DEF_TIM_DMA_FULL
1141 #define DEF_TIM_DMA__BTCH_TIM1_CH3 DEF_TIM_DMA_FULL
1142 #define DEF_TIM_DMA__BTCH_TIM1_CH4 DEF_TIM_DMA_FULL
1144 #define DEF_TIM_DMA__BTCH_TIM2_CH1 DEF_TIM_DMA_FULL
1145 #define DEF_TIM_DMA__BTCH_TIM2_CH2 DEF_TIM_DMA_FULL
1146 #define DEF_TIM_DMA__BTCH_TIM2_CH3 DEF_TIM_DMA_FULL
1147 #define DEF_TIM_DMA__BTCH_TIM2_CH4 DEF_TIM_DMA_FULL
1149 #define DEF_TIM_DMA__BTCH_TIM3_CH1 DEF_TIM_DMA_FULL
1150 #define DEF_TIM_DMA__BTCH_TIM3_CH2 DEF_TIM_DMA_FULL
1151 #define DEF_TIM_DMA__BTCH_TIM3_CH3 DEF_TIM_DMA_FULL
1152 #define DEF_TIM_DMA__BTCH_TIM3_CH4 DEF_TIM_DMA_FULL
1154 #define DEF_TIM_DMA__BTCH_TIM4_CH1 DEF_TIM_DMA_FULL
1155 #define DEF_TIM_DMA__BTCH_TIM4_CH2 DEF_TIM_DMA_FULL
1156 #define DEF_TIM_DMA__BTCH_TIM4_CH3 DEF_TIM_DMA_FULL
1157 #define DEF_TIM_DMA__BTCH_TIM4_CH4 DEF_TIM_DMA_FULL
1159 #define DEF_TIM_DMA__BTCH_TIM5_CH1 DEF_TIM_DMA_FULL
1160 #define DEF_TIM_DMA__BTCH_TIM5_CH2 DEF_TIM_DMA_FULL
1161 #define DEF_TIM_DMA__BTCH_TIM5_CH3 DEF_TIM_DMA_FULL
1162 #define DEF_TIM_DMA__BTCH_TIM5_CH4 DEF_TIM_DMA_FULL
1164 #define DEF_TIM_DMA__BTCH_TIM8_CH1 DEF_TIM_DMA_FULL
1165 #define DEF_TIM_DMA__BTCH_TIM8_CH2 DEF_TIM_DMA_FULL
1166 #define DEF_TIM_DMA__BTCH_TIM8_CH3 DEF_TIM_DMA_FULL
1167 #define DEF_TIM_DMA__BTCH_TIM8_CH4 DEF_TIM_DMA_FULL
1169 #define DEF_TIM_DMA__BTCH_TIM15_CH1 DEF_TIM_DMA_FULL
1170 #define DEF_TIM_DMA__BTCH_TIM15_CH2 NONE
1172 #define DEF_TIM_DMA__BTCH_TIM16_CH1 DEF_TIM_DMA_FULL
1174 #define DEF_TIM_DMA__BTCH_TIM17_CH1 DEF_TIM_DMA_FULL
1176 #define DEF_TIM_DMA__BTCH_TIM20_CH1 DEF_TIM_DMA_FULL
1177 #define DEF_TIM_DMA__BTCH_TIM20_CH2 DEF_TIM_DMA_FULL
1178 #define DEF_TIM_DMA__BTCH_TIM20_CH3 DEF_TIM_DMA_FULL
1179 #define DEF_TIM_DMA__BTCH_TIM20_CH4 DEF_TIM_DMA_FULL
1181 // TIM_UP table
1182 #define DEF_TIM_DMA__BTCH_TIM1_UP DEF_TIM_DMA_FULL
1183 #define DEF_TIM_DMA__BTCH_TIM2_UP DEF_TIM_DMA_FULL
1184 #define DEF_TIM_DMA__BTCH_TIM3_UP DEF_TIM_DMA_FULL
1185 #define DEF_TIM_DMA__BTCH_TIM4_UP DEF_TIM_DMA_FULL
1186 #define DEF_TIM_DMA__BTCH_TIM5_UP DEF_TIM_DMA_FULL
1187 #define DEF_TIM_DMA__BTCH_TIM6_UP DEF_TIM_DMA_FULL
1188 #define DEF_TIM_DMA__BTCH_TIM7_UP DEF_TIM_DMA_FULL
1189 #define DEF_TIM_DMA__BTCH_TIM8_UP DEF_TIM_DMA_FULL
1190 #define DEF_TIM_DMA__BTCH_TIM15_UP DEF_TIM_DMA_FULL
1191 #define DEF_TIM_DMA__BTCH_TIM16_UP DEF_TIM_DMA_FULL
1192 #define DEF_TIM_DMA__BTCH_TIM17_UP DEF_TIM_DMA_FULL
1193 #define DEF_TIM_DMA__BTCH_TIM20_UP DEF_TIM_DMA_FULL
1195 // TIMx_CHy request table
1197 // This is not defined in stm32g7xx_hal_timer.h
1198 #define DMA_REQUEST_NONE 255
1200 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH1 DMA_REQUEST_TIM1_CH1
1201 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH2 DMA_REQUEST_TIM1_CH2
1202 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH3 DMA_REQUEST_TIM1_CH3
1203 #define DEF_TIM_DMA_REQ__BTCH_TIM1_CH4 DMA_REQUEST_TIM1_CH4
1205 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH1 DMA_REQUEST_TIM2_CH1
1206 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH2 DMA_REQUEST_TIM2_CH2
1207 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH3 DMA_REQUEST_TIM2_CH3
1208 #define DEF_TIM_DMA_REQ__BTCH_TIM2_CH4 DMA_REQUEST_TIM2_CH4
1210 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH1 DMA_REQUEST_TIM3_CH1
1211 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH2 DMA_REQUEST_TIM3_CH2
1212 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH3 DMA_REQUEST_TIM3_CH3
1213 #define DEF_TIM_DMA_REQ__BTCH_TIM3_CH4 DMA_REQUEST_TIM3_CH4
1215 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH1 DMA_REQUEST_TIM4_CH1
1216 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH2 DMA_REQUEST_TIM4_CH2
1217 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH3 DMA_REQUEST_TIM4_CH3
1218 #define DEF_TIM_DMA_REQ__BTCH_TIM4_CH4 DMA_REQUEST_TIM4_CH4
1220 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH1 DMA_REQUEST_TIM5_CH1
1221 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH2 DMA_REQUEST_TIM5_CH2
1222 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH3 DMA_REQUEST_TIM5_CH3
1223 #define DEF_TIM_DMA_REQ__BTCH_TIM5_CH4 DMA_REQUEST_TIM5_CH4
1225 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH1 DMA_REQUEST_TIM8_CH1
1226 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH2 DMA_REQUEST_TIM8_CH2
1227 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH3 DMA_REQUEST_TIM8_CH3
1228 #define DEF_TIM_DMA_REQ__BTCH_TIM8_CH4 DMA_REQUEST_TIM8_CH4
1230 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH1 DMA_REQUEST_TIM15_CH1
1231 #define DEF_TIM_DMA_REQ__BTCH_TIM15_CH2 DMA_REQUEST_NONE
1233 #define DEF_TIM_DMA_REQ__BTCH_TIM16_CH1 DMA_REQUEST_TIM16_CH1
1235 #define DEF_TIM_DMA_REQ__BTCH_TIM17_CH1 DMA_REQUEST_TIM17_CH1
1237 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH1 DMA_REQUEST_TIM20_CH1
1238 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH2 DMA_REQUEST_TIM20_CH2
1239 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH3 DMA_REQUEST_TIM20_CH3
1240 #define DEF_TIM_DMA_REQ__BTCH_TIM20_CH4 DMA_REQUEST_TIM20_CH4
1242 // TIM_UP request table
1243 #define DEF_TIM_DMA_REQ__BTCH_TIM1_UP DMA_REQUEST_TIM1_UP
1244 #define DEF_TIM_DMA_REQ__BTCH_TIM2_UP DMA_REQUEST_TIM2_UP
1245 #define DEF_TIM_DMA_REQ__BTCH_TIM3_UP DMA_REQUEST_TIM3_UP
1246 #define DEF_TIM_DMA_REQ__BTCH_TIM4_UP DMA_REQUEST_TIM4_UP
1247 #define DEF_TIM_DMA_REQ__BTCH_TIM5_UP DMA_REQUEST_TIM5_UP
1248 #define DEF_TIM_DMA_REQ__BTCH_TIM6_UP DMA_REQUEST_TIM6_UP
1249 #define DEF_TIM_DMA_REQ__BTCH_TIM7_UP DMA_REQUEST_TIM7_UP
1250 #define DEF_TIM_DMA_REQ__BTCH_TIM8_UP DMA_REQUEST_TIM8_UP
1251 #define DEF_TIM_DMA_REQ__BTCH_TIM15_UP DMA_REQUEST_TIM15_UP
1252 #define DEF_TIM_DMA_REQ__BTCH_TIM16_UP DMA_REQUEST_TIM16_UP
1253 #define DEF_TIM_DMA_REQ__BTCH_TIM17_UP DMA_REQUEST_TIM17_UP
1254 #define DEF_TIM_DMA_REQ__BTCH_TIM20_UP DMA_REQUEST_TIM20_UP
1256 // AF table
1258 //NONE
1259 #define DEF_TIM_AF__NONE__TCH_TIM1_CH1 D(6, 1)
1260 #define DEF_TIM_AF__NONE__TCH_TIM1_CH2 D(6, 1)
1261 #define DEF_TIM_AF__NONE__TCH_TIM1_CH3 D(6, 1)
1262 #define DEF_TIM_AF__NONE__TCH_TIM1_CH4 D(6, 1)
1263 #define DEF_TIM_AF__NONE__TCH_TIM8_CH1 D(3, 8)
1264 #define DEF_TIM_AF__NONE__TCH_TIM8_CH2 D(3, 8)
1265 #define DEF_TIM_AF__NONE__TCH_TIM8_CH3 D(3, 8)
1266 #define DEF_TIM_AF__NONE__TCH_TIM8_CH4 D(3, 8)
1268 //PORTA
1269 #define DEF_TIM_AF__PA0__TCH_TIM2_CH1 D(1, 2)
1270 #define DEF_TIM_AF__PA1__TCH_TIM2_CH2 D(1, 2)
1271 #define DEF_TIM_AF__PA2__TCH_TIM2_CH3 D(1, 2)
1272 #define DEF_TIM_AF__PA3__TCH_TIM2_CH4 D(1, 2)
1273 #define DEF_TIM_AF__PA5__TCH_TIM2_CH1 D(1, 2)
1274 #define DEF_TIM_AF__PA6__TCH_TIM16_CH1 D(1, 16)
1275 #define DEF_TIM_AF__PA7__TCH_TIM17_CH1 D(1, 17)
1276 #define DEF_TIM_AF__PA12__TCH_TIM16_CH1 D(1, 16)
1277 #define DEF_TIM_AF__PA13__TCH_TIM16_CH1N D(1, 16)
1278 #define DEF_TIM_AF__PA15__TCH_TIM2_CH1 D(1, 2)
1280 #define DEF_TIM_AF__PA0__TCH_TIM5_CH1 D(2, 5)
1281 #define DEF_TIM_AF__PA1__TCH_TIM5_CH2 D(2, 5)
1282 #define DEF_TIM_AF__PA2__TCH_TIM5_CH3 D(2, 5)
1283 #define DEF_TIM_AF__PA3__TCH_TIM5_CH4 D(2, 5)
1284 #define DEF_TIM_AF__PA4__TCH_TIM3_CH2 D(2, 3)
1285 #define DEF_TIM_AF__PA6__TCH_TIM3_CH1 D(2, 3)
1286 #define DEF_TIM_AF__PA7__TCH_TIM3_CH2 D(2, 3)
1287 #define DEF_TIM_AF__PA15__TCH_TIM8_CH1 D(2, 8)
1289 #define DEF_TIM_AF__PA7__TCH_TIM8_CH1N D(4, 8)
1291 #define DEF_TIM_AF__PA14__TCH_TIM8_CH2 D(5, 8)
1293 #define DEF_TIM_AF__PA7__TCH_TIM1_CH1N D(6, 1)
1294 #define DEF_TIM_AF__PA8__TCH_TIM1_CH1 D(6, 1)
1295 #define DEF_TIM_AF__PA9__TCH_TIM1_CH2 D(6, 1)
1296 #define DEF_TIM_AF__PA10__TCH_TIM1_CH3 D(6, 1)
1297 #define DEF_TIM_AF__PA11__TCH_TIM1_CH1N D(6, 1)
1298 #define DEF_TIM_AF__PA12__TCH_TIM1_CH2N D(6, 1)
1300 #define DEF_TIM_AF__PA1__TCH_TIM15_CH1N D(9, 15)
1301 #define DEF_TIM_AF__PA2__TCH_TIM15_CH1 D(9, 15)
1302 #define DEF_TIM_AF__PA3__TCH_TIM15_CH2 D(9, 15)
1304 #define DEF_TIM_AF__PA9__TCH_TIM2_CH3 D(10, 2)
1305 #define DEF_TIM_AF__PA10__TCH_TIM2_CH4 D(10, 2)
1306 #define DEF_TIM_AF__PA11__TCH_TIM4_CH1 D(10, 4)
1307 #define DEF_TIM_AF__PA12__TCH_TIM4_CH2 D(10, 4)
1308 #define DEF_TIM_AF__PA13__TCH_TIM4_CH3 D(10, 4)
1310 #define DEF_TIM_AF__PA11__TCH_TIM1_CH4 D(11, 1)
1312 //PORTB
1313 #define DEF_TIM_AF__PB3__TCH_TIM2_CH2 D(1, 2)
1314 #define DEF_TIM_AF__PB4__TCH_TIM16_CH1 D(1, 16)
1315 #define DEF_TIM_AF__PB6__TCH_TIM16_CH1N D(1, 16)
1316 #define DEF_TIM_AF__PB7__TCH_TIM17_CH1N D(1, 17)
1317 #define DEF_TIM_AF__PB8__TCH_TIM16_CH1 D(1, 16)
1318 #define DEF_TIM_AF__PB9__TCH_TIM17_CH1 D(1, 17)
1319 #define DEF_TIM_AF__PB10__TCH_TIM2_CH3 D(1, 2)
1320 #define DEF_TIM_AF__PB11__TCH_TIM2_CH4 D(1, 2)
1321 #define DEF_TIM_AF__PB14__TCH_TIM15_CH1 D(1, 15)
1322 #define DEF_TIM_AF__PB15__TCH_TIM15_CH2 D(1, 15)
1324 #define DEF_TIM_AF__PB0__TCH_TIM3_CH3 D(2, 3)
1325 #define DEF_TIM_AF__PB1__TCH_TIM3_CH4 D(2, 3)
1326 #define DEF_TIM_AF__PB2__TCH_TIM5_CH1 D(2, 5)
1327 #define DEF_TIM_AF__PB4__TCH_TIM3_CH1 D(2, 3)
1328 #define DEF_TIM_AF__PB5__TCH_TIM3_CH2 D(2, 3)
1329 #define DEF_TIM_AF__PB6__TCH_TIM4_CH1 D(2, 4)
1330 #define DEF_TIM_AF__PB7__TCH_TIM4_CH2 D(2, 4)
1331 #define DEF_TIM_AF__PB8__TCH_TIM4_CH3 D(2, 4)
1332 #define DEF_TIM_AF__PB9__TCH_TIM4_CH4 D(2, 4)
1333 #define DEF_TIM_AF__PB15__TCH_TIM15_CH1N D(2, 15)
1335 #define DEF_TIM_AF__PB2__TCH_TIM20_CH1 D(3, 20)
1336 #define DEF_TIM_AF__PB5__TCH_TIM8_CH3N D(3, 8)
1338 #define DEF_TIM_AF__PB0__TCH_TIM8_CH2N D(4, 8)
1339 #define DEF_TIM_AF__PB1__TCH_TIM8_CH3N D(4, 8)
1340 #define DEF_TIM_AF__PB3__TCH_TIM8_CH1N D(4, 8)
1341 #define DEF_TIM_AF__PB4__TCH_TIM8_CH2N D(4, 8)
1342 #define DEF_TIM_AF__PB15__TCH_TIM1_CH3N D(4, 1)
1344 #define DEF_TIM_AF__PB6__TCH_TIM8_CH1 D(5, 8)
1346 #define DEF_TIM_AF__PB0__TCH_TIM1_CH2N D(6, 1)
1347 #define DEF_TIM_AF__PB1__TCH_TIM1_CH3N D(6, 1)
1348 #define DEF_TIM_AF__PB13__TCH_TIM1_CH1N D(6, 1)
1349 #define DEF_TIM_AF__PB14__TCH_TIM1_CH2N D(6, 1)
1351 #define DEF_TIM_AF__PB5__TCH_TIM17_CH1 D(10, 17)
1352 #define DEF_TIM_AF__PB7__TCH_TIM3_CH4 D(10, 3)
1353 #define DEF_TIM_AF__PB8__TCH_TIM8_CH2 D(10, 8)
1354 #define DEF_TIM_AF__PB9__TCH_TIM8_CH3 D(10, 8)
1356 #define DEF_TIM_AF__PB9__TCH_TIM1_CH3N D(12, 1)
1358 //PORTC
1359 #define DEF_TIM_AF__PC12__TCH_TIM5_CH2 D(1, 5)
1361 #define DEF_TIM_AF__PC0__TCH_TIM1_CH1 D(2, 1)
1362 #define DEF_TIM_AF__PC1__TCH_TIM1_CH2 D(2, 1)
1363 #define DEF_TIM_AF__PC2__TCH_TIM1_CH3 D(2, 1)
1364 #define DEF_TIM_AF__PC3__TCH_TIM1_CH4 D(2, 1)
1365 #define DEF_TIM_AF__PC6__TCH_TIM3_CH1 D(2, 3)
1366 #define DEF_TIM_AF__PC7__TCH_TIM3_CH2 D(2, 3)
1367 #define DEF_TIM_AF__PC8__TCH_TIM3_CH3 D(2, 3)
1368 #define DEF_TIM_AF__PC9__TCH_TIM3_CH4 D(2, 3)
1370 #define DEF_TIM_AF__PC6__TCH_TIM8_CH1 D(4, 8)
1371 #define DEF_TIM_AF__PC7__TCH_TIM8_CH2 D(4, 8)
1372 #define DEF_TIM_AF__PC8__TCH_TIM8_CH3 D(4, 8)
1373 #define DEF_TIM_AF__PC9__TCH_TIM8_CH4 D(4, 8)
1374 #define DEF_TIM_AF__PC10__TCH_TIM8_CH1N D(4, 8)
1375 #define DEF_TIM_AF__PC11__TCH_TIM8_CH2N D(4, 8)
1376 #define DEF_TIM_AF__PC12__TCH_TIM8_CH3N D(4, 8)
1377 #define DEF_TIM_AF__PC13__TCH_TIM1_CH1N D(4, 1)
1379 #define DEF_TIM_AF__PC2__TCH_TIM20_CH2 D(6, 20)
1380 #define DEF_TIM_AF__PC5__TCH_TIM1_CH4N D(6, 1)
1381 #define DEF_TIM_AF__PC8__TCH_TIM20_CH3 D(6, 20)
1382 #define DEF_TIM_AF__PC13__TCH_TIM8_CH4N D(6, 8)
1384 #endif