Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
tawaki.h
Go to the documentation of this file.
1 #ifndef CONFIG_TAWAKI_1_00_H
2 #define CONFIG_TAWAKI_1_00_H
3 
4 #define BOARD_TAWAKI
5 
9 #include "board.h"
10 
15 /*
16  * AHB_CLK
17  */
18 #define AHB_CLK STM32_HCLK
19 
20 /*
21  * Concat macro
22  */
23 #define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
24 #define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
25 
26 /*
27  * LEDs
28  */
29 /* red, on PD15, 1 on LED_ON, 0 on LED_OFF */
30 #ifndef USE_LED_1
31 #define USE_LED_1 1
32 #endif
33 #define LED_1_GPIO PAL_PORT(LINE_LED1)
34 #define LED_1_GPIO_PIN PAL_PAD(LINE_LED1)
35 #define LED_1_GPIO_ON gpio_set
36 #define LED_1_GPIO_OFF gpio_clear
37 
38 /* orange, on PA10, 1 on LED_ON, 0 on LED_OFF */
39 #ifndef USE_LED_2
40 #define USE_LED_2 1
41 #endif
42 #define LED_2_GPIO PAL_PORT(LINE_LED2)
43 #define LED_2_GPIO_PIN PAL_PAD(LINE_LED2)
44 #define LED_2_GPIO_ON gpio_set
45 #define LED_2_GPIO_OFF gpio_clear
46 
47 /* green, on PC7, 1 on LED_ON, 0 on LED_OFF */
48 #ifndef USE_LED_3
49 #define USE_LED_3 1
50 #endif
51 #define LED_3_GPIO PAL_PORT(LINE_LED3)
52 #define LED_3_GPIO_PIN PAL_PAD(LINE_LED3)
53 #define LED_3_GPIO_ON gpio_set
54 #define LED_3_GPIO_OFF gpio_clear
55 
56 /* yellow, on PD10, 1 on LED_ON, 0 on LED_OFF */
57 #ifndef USE_LED_4
58 #define USE_LED_4 1
59 #endif
60 #define LED_4_GPIO PAL_PORT(LINE_LED4)
61 #define LED_4_GPIO_PIN PAL_PAD(LINE_LED4)
62 #define LED_4_GPIO_ON gpio_set
63 #define LED_4_GPIO_OFF gpio_clear
64 
65 /*
66  * ADCs
67  */
68 // AUXa1
69 #if USE_ADC_1
70 #define AD1_1_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_A1_ADC_IN)
71 #define ADC_1 AD1_1
72 #define ADC_1_GPIO_PORT PAL_PORT(LINE_AUX_A1)
73 #define ADC_1_GPIO_PIN PAL_PAD(LINE_AUX_A1)
74 #endif
75 
76 // AUXa2
77 #if USE_ADC_2
78 #define AD1_2_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_A2_ADC_IN)
79 #define ADC_2 AD1_2
80 #define ADC_2_GPIO_PORT PAL_PORT(LINE_AUX_A2)
81 #define ADC_2_GPIO_PIN PAL_PAD(LINE_AUX_A2)
82 #endif
83 
84 // AUXa3
85 #if USE_ADC_3
86 #define AD1_3_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_A3_ADC_IN)
87 #define ADC_3 AD1_3
88 #define ADC_3_GPIO_PORT PAL_PORT(LINE_AUX_A3)
89 #define ADC_3_GPIO_PIN PAL_PAD(LINE_AUX_A3)
90 #endif
91 
92 // AUXa4
93 #if USE_ADC_4
94 #define AD1_4_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_A4_ADC_IN)
95 #define ADC_4 AD1_4
96 #define ADC_4_GPIO_PORT PAL_PORT(LINE_AUX_A4)
97 #define ADC_4_GPIO_PIN PAL_PAD(LINE_AUX_A4)
98 #endif
99 
100 // AUXb1
101 #if USE_ADC_5
102 #define AD1_5_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_B1_ADC_IN)
103 #define ADC_5 AD1_5
104 #define ADC_5_GPIO_PORT PAL_PORT(LINE_AUX_B1)
105 #define ADC_5_GPIO_PIN PAL_PAD(LINE_AUX_B1)
106 #endif
107 
108 // AUXb2
109 #if USE_ADC_6
110 #define AD1_6_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_B2_ADC_IN)
111 #define ADC_6 AD1_6
112 #define ADC_6_GPIO_PORT PAL_PORT(LINE_AUX_B2)
113 #define ADC_6_GPIO_PIN PAL_PAD(LINE_AUX_B2)
114 #endif
115 
116 // AUXb3
117 #if USE_ADC_7
118 #define AD1_7_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_B3_ADC_IN)
119 #define ADC_7 AD1_7
120 #define ADC_7_GPIO_PORT PAL_PORT(LINE_AUX_B3)
121 #define ADC_7_GPIO_PIN PAL_PAD(LINE_AUX_B3)
122 #endif
123 
124 // AUXb4
125 #if USE_ADC_8
126 #define AD1_8_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, AUX_B4_ADC_IN)
127 #define ADC_8 AD1_8
128 #define ADC_8_GPIO_PORT PAL_PORT(LINE_AUX_B4)
129 #define ADC_8_GPIO_PIN PAL_PAD(LINE_AUX_B4)
130 #endif
131 
132 // Internal ADC for battery enabled by default
133 #ifndef USE_ADC_9
134 #define USE_ADC_9 1
135 #endif
136 #if USE_ADC_9
137 #define AD1_9_CHANNEL CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, VBAT_MEAS_ADC_IN)
138 #define ADC_9 AD1_9
139 #define ADC_9_GPIO_PORT PAL_PORT(LINE_VBAT_MEAS)
140 #define ADC_9_GPIO_PIN PAL_PAD(LINE_VBAT_MEAS)
141 #endif
142 
143 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
144 #ifndef ADC_CHANNEL_VSUPPLY
145 #define ADC_CHANNEL_VSUPPLY ADC_9
146 #endif
147 
148 /*
149  * R1 = 2.2k
150  * R2 = 12k
151  * adc * (3.3 / 2^12) * ((R1 + R2) / R1)
152  */
153 #define VBAT_R1 2200.0f
154 #define VBAT_R2 12000.0f
155 #define DefaultVoltageOfAdc(adc) ((3.3f/4096.0f)*((VBAT_R1+VBAT_R2)/VBAT_R1)*adc)
156 
157 /*
158  * PWM defines
159  */
160 
161 // SRVa connectors, activated in PWM mode by default
162 
163 #ifndef USE_PWM1
164 #define USE_PWM1 1
165 #endif
166 #if USE_PWM1
167 #define PWM_SERVO_1 1
168 #define PWM_SERVO_1_GPIO PAL_PORT(LINE_SRVA1)
169 #define PWM_SERVO_1_PIN PAL_PAD(LINE_SRVA1)
170 #define PWM_SERVO_1_AF AF_SRVA1
171 #define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVA1_TIM)
172 #define PWM_SERVO_1_CHANNEL (SRVA1_TIM_CH-1)
173 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
174 #else
175 #define PWM_SERVO_1_ACTIVE PWM_OUTPUT_DISABLED
176 #endif
177 
178 #ifndef USE_PWM2
179 #define USE_PWM2 1
180 #endif
181 #if USE_PWM2
182 #define PWM_SERVO_2 2
183 #define PWM_SERVO_2_GPIO PAL_PORT(LINE_SRVA2)
184 #define PWM_SERVO_2_PIN PAL_PAD(LINE_SRVA2)
185 #define PWM_SERVO_2_AF AF_SRVA2
186 #define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVA2_TIM)
187 #define PWM_SERVO_2_CHANNEL (SRVA2_TIM_CH-1)
188 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
189 #else
190 #define PWM_SERVO_2_ACTIVE PWM_OUTPUT_DISABLED
191 #endif
192 
193 #ifndef USE_PWM3
194 #define USE_PWM3 1
195 #endif
196 #if USE_PWM3
197 #define PWM_SERVO_3 3
198 #define PWM_SERVO_3_GPIO PAL_PORT(LINE_SRVA3)
199 #define PWM_SERVO_3_PIN PAL_PAD(LINE_SRVA3)
200 #define PWM_SERVO_3_AF AF_SRVA3
201 #define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVA3_TIM)
202 #define PWM_SERVO_3_CHANNEL (SRVA3_TIM_CH-1)
203 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
204 #else
205 #define PWM_SERVO_3_ACTIVE PWM_OUTPUT_DISABLED
206 #endif
207 
208 #ifndef USE_PWM4
209 #define USE_PWM4 1
210 #endif
211 #if USE_PWM4
212 #define PWM_SERVO_4 4
213 #define PWM_SERVO_4_GPIO PAL_PORT(LINE_SRVA4)
214 #define PWM_SERVO_4_PIN PAL_PAD(LINE_SRVA4)
215 #define PWM_SERVO_4_AF AF_SRVA4
216 #define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVA4_TIM)
217 #define PWM_SERVO_4_CHANNEL (SRVA4_TIM_CH-1)
218 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
219 #else
220 #define PWM_SERVO_4_ACTIVE PWM_OUTPUT_DISABLED
221 #endif
222 
223 // SRVb connector, PWM mode disabled by default (DShot is enabled by default)
224 
225 #ifndef USE_PWM5
226 #define USE_PWM5 0
227 #endif
228 #if USE_PWM5
229 #define PWM_SERVO_5 5
230 #define PWM_SERVO_5_GPIO PAL_PORT(LINE_SRVB1)
231 #define PWM_SERVO_5_PIN PAL_PAD(LINE_SRVB1)
232 #define PWM_SERVO_5_AF AF_SRVB1
233 #define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVB1_TIM)
234 #define PWM_SERVO_5_CHANNEL (SRVB1_TIM_CH-1)
235 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
236 #else
237 #define PWM_SERVO_5_ACTIVE PWM_OUTPUT_DISABLED
238 #endif
239 
240 #ifndef USE_PWM6
241 #define USE_PWM6 0
242 #endif
243 #if USE_PWM6
244 #define PWM_SERVO_6 6
245 #define PWM_SERVO_6_GPIO PAL_PORT(LINE_SRVB2)
246 #define PWM_SERVO_6_PIN PAL_PAD(LINE_SRVB2)
247 #define PWM_SERVO_6_AF AF_SRVB2
248 #define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVB2_TIM)
249 #define PWM_SERVO_6_CHANNEL (SRVB2_TIM_CH-1)
250 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
251 #else
252 #define PWM_SERVO_6_ACTIVE PWM_OUTPUT_DISABLED
253 #endif
254 
255 #ifndef USE_PWM7
256 #define USE_PWM7 0
257 #endif
258 #if USE_PWM7
259 #define PWM_SERVO_7 7
260 #define PWM_SERVO_7_GPIO PAL_PORT(LINE_SRVB3)
261 #define PWM_SERVO_7_PIN PAL_PAD(LINE_SRVB3)
262 #define PWM_SERVO_7_AF AF_SRVB3
263 #define PWM_SERVO_7_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVB3_TIM)
264 #define PWM_SERVO_7_CHANNEL (SRVB3_TIM_CH-1)
265 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
266 #else
267 #define PWM_SERVO_7_ACTIVE PWM_OUTPUT_DISABLED
268 #endif
269 
270 #ifndef USE_PWM8
271 #define USE_PWM8 0
272 #endif
273 #if USE_PWM8
274 #define PWM_SERVO_8 8
275 #define PWM_SERVO_8_GPIO PAL_PORT(LINE_SRVB4)
276 #define PWM_SERVO_8_PIN PAL_PAD(LINE_SRVB4)
277 #define PWM_SERVO_8_AF AF_SRVB4
278 #define PWM_SERVO_8_DRIVER CONCAT_BOARD_PARAM(PWMD, SRVB4_TIM)
279 #define PWM_SERVO_8_CHANNEL (SRVB4_TIM_CH-1)
280 #define PWM_SERVO_8_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
281 #else
282 #define PWM_SERVO_8_ACTIVE PWM_OUTPUT_DISABLED
283 #endif
284 
285 #ifndef USE_PWM9
286 #define USE_PWM9 0
287 #endif
288 #if USE_PWM9
289 #define PWM_SERVO_9 9
290 #define PWM_SERVO_9_GPIO PAL_PORT(LINE_AUX_A1)
291 #define PWM_SERVO_9_PIN PAL_PAD(LINE_AUX_A1)
292 #define PWM_SERVO_9_AF GPIO_AF2
293 #define PWM_SERVO_9_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_A1_TIM)
294 #define PWM_SERVO_9_CHANNEL (AUX_A1_TIM_CH-1)
295 #define PWM_SERVO_9_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
296 #else
297 #define PWM_SERVO_9_ACTIVE PWM_OUTPUT_DISABLED
298 #endif
299 
300 #ifndef USE_PWM10
301 #define USE_PWM10 0
302 #endif
303 #if USE_PWM10
304 #define PWM_SERVO_10 10
305 #define PWM_SERVO_10_GPIO PAL_PORT(LINE_AUX_A2)
306 #define PWM_SERVO_10_PIN PAL_PAD(LINE_AUX_A2)
307 #define PWM_SERVO_10_AF GPIO_AF2
308 #define PWM_SERVO_10_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_A2_TIM)
309 #define PWM_SERVO_10_CHANNEL (AUX_A2_TIM_CH-1)
310 #define PWM_SERVO_10_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
311 #else
312 #define PWM_SERVO_10_ACTIVE PWM_OUTPUT_DISABLED
313 #endif
314 
315 #ifndef USE_PWM11
316 #define USE_PWM11 0
317 #endif
318 #if USE_PWM11
319 #define PWM_SERVO_11 11
320 #define PWM_SERVO_11_GPIO PAL_PORT(LINE_AUX_A3)
321 #define PWM_SERVO_11_PIN PAL_PAD(LINE_AUX_A3)
322 #define PWM_SERVO_11_AF GPIO_AF2
323 #define PWM_SERVO_11_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_A3_TIM)
324 #define PWM_SERVO_11_CHANNEL (AUX_A3_TIM_CH-1)
325 #define PWM_SERVO_11_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
326 #else
327 #define PWM_SERVO_11_ACTIVE PWM_OUTPUT_DISABLED
328 #endif
329 
330 #ifndef USE_PWM12
331 #define USE_PWM12 0
332 #endif
333 #if USE_PWM12
334 #define PWM_SERVO_12 12
335 #define PWM_SERVO_12_GPIO PAL_PORT(LINE_AUX_A4)
336 #define PWM_SERVO_12_PIN PAL_PAD(LINE_AUX_A4)
337 #define PWM_SERVO_12_AF GPIO_AF2
338 #define PWM_SERVO_12_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_A4_TIM)
339 #define PWM_SERVO_12_CHANNEL (AUX_A4_TIM_CH-1)
340 #define PWM_SERVO_12_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
341 #else
342 #define PWM_SERVO_12_ACTIVE PWM_OUTPUT_DISABLED
343 #endif
344 
345 #ifndef USE_PWM13
346 #define USE_PWM13 0
347 #endif
348 #if USE_PWM13
349 #define PWM_SERVO_13 13
350 #define PWM_SERVO_13_GPIO PAL_PORT(LINE_AUX_B1)
351 #define PWM_SERVO_13_PIN PAL_PAD(LINE_AUX_B1)
352 #define PWM_SERVO_13_AF GPIO_AF2
353 #define PWM_SERVO_13_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_B1_TIM)
354 #define PWM_SERVO_13_CHANNEL (AUX_B1_TIM_CH-1)
355 #define PWM_SERVO_13_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
356 #else
357 #define PWM_SERVO_13_ACTIVE PWM_OUTPUT_DISABLED
358 #endif
359 
360 #ifndef USE_PWM14
361 #define USE_PWM14 0
362 #endif
363 #if USE_PWM14
364 #define PWM_SERVO_14 14
365 #define PWM_SERVO_14_GPIO PAL_PORT(LINE_AUX_B2)
366 #define PWM_SERVO_14_PIN PAL_PAD(LINE_AUX_B2)
367 #define PWM_SERVO_14_AF GPIO_AF2
368 #define PWM_SERVO_14_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_B2_TIM)
369 #define PWM_SERVO_14_CHANNEL (AUX_B2_TIM_CH-1)
370 #define PWM_SERVO_14_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
371 #else
372 #define PWM_SERVO_14_ACTIVE PWM_OUTPUT_DISABLED
373 #endif
374 
375 #ifndef USE_PWM15
376 #define USE_PWM15 0
377 #endif
378 #if USE_PWM15
379 #define PWM_SERVO_15 15
380 #define PWM_SERVO_15_GPIO PAL_PORT(LINE_AUX_B3)
381 #define PWM_SERVO_15_PIN PAL_PAD(LINE_AUX_B3)
382 #define PWM_SERVO_15_AF GPIO_AF2
383 #define PWM_SERVO_15_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_B3_TIM)
384 #define PWM_SERVO_15_CHANNEL (AUX_B3_TIM_CH-1)
385 #define PWM_SERVO_15_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
386 #else
387 #define PWM_SERVO_15_ACTIVE PWM_OUTPUT_DISABLED
388 #endif
389 
390 #ifndef USE_PWM16
391 #define USE_PWM16 0
392 #endif
393 #if USE_PWM16
394 #define PWM_SERVO_16 16
395 #define PWM_SERVO_16_GPIO PAL_PORT(LINE_AUX_B4)
396 #define PWM_SERVO_16_PIN PAL_PAD(LINE_AUX_B4)
397 #define PWM_SERVO_16_AF GPIO_AF2
398 #define PWM_SERVO_16_DRIVER CONCAT_BOARD_PARAM(PWMD, AUX_B4_TIM)
399 #define PWM_SERVO_16_CHANNEL (AUX_B4_TIM_CH-1)
400 #define PWM_SERVO_16_ACTIVE PWM_OUTPUT_ACTIVE_HIGH
401 #else
402 #define PWM_SERVO_16_ACTIVE PWM_OUTPUT_DISABLED
403 #endif
404 
405 // servo index starting at 1 + regular servos + aux servos
406 // so NB = 1+8+8
407 #define ACTUATORS_PWM_NB 17
408 
409 
410 #ifdef STM32_PWM_USE_TIM1
411 #define PWM_CONF_TIM1 STM32_PWM_USE_TIM1
412 #else
413 #define PWM_CONF_TIM1 1
414 #endif
415 #define PWM_CONF1_DEF { \
416  PWM_FREQUENCY, \
417  PWM_FREQUENCY/TIM1_SERVO_HZ, \
418  NULL, \
419  { \
420  { PWM_SERVO_1_ACTIVE, NULL }, \
421  { PWM_SERVO_2_ACTIVE, NULL }, \
422  { PWM_SERVO_3_ACTIVE, NULL }, \
423  { PWM_SERVO_4_ACTIVE, NULL }, \
424  }, \
425  0, \
426  0 \
427 }
428 
429 #ifdef STM32_PWM_USE_TIM3
430 #define PWM_CONF_TIM3 STM32_PWM_USE_TIM3
431 #else
432 #define PWM_CONF_TIM3 1
433 #endif
434 #define PWM_CONF3_DEF { \
435  PWM_FREQUENCY, \
436  PWM_FREQUENCY/TIM3_SERVO_HZ, \
437  NULL, \
438  { \
439  { PWM_SERVO_12_ACTIVE, NULL }, \
440  { PWM_SERVO_14_ACTIVE, NULL }, \
441  { PWM_SERVO_15_ACTIVE, NULL }, \
442  { PWM_SERVO_16_ACTIVE, NULL }, \
443  }, \
444  0, \
445  0 \
446 }
447 
448 #ifdef STM32_PWM_USE_TIM4
449 #define PWM_CONF_TIM4 STM32_PWM_USE_TIM4
450 #else
451 #define PWM_CONF_TIM4 1
452 #endif
453 #define PWM_CONF4_DEF { \
454  PWM_FREQUENCY, \
455  PWM_FREQUENCY/TIM4_SERVO_HZ, \
456  NULL, \
457  { \
458  { PWM_SERVO_5_ACTIVE, NULL }, \
459  { PWM_SERVO_6_ACTIVE, NULL }, \
460  { PWM_SERVO_7_ACTIVE, NULL }, \
461  { PWM_SERVO_8_ACTIVE, NULL }, \
462  }, \
463  0, \
464  0 \
465 }
466 
467 #ifdef STM32_PWM_USE_TIM5
468 #define PWM_CONF_TIM5 STM32_PWM_USE_TIM5
469 #else
470 #define PWM_CONF_TIM5 1
471 #endif
472 #define PWM_CONF5_DEF { \
473  PWM_FREQUENCY, \
474  PWM_FREQUENCY/TIM5_SERVO_HZ, \
475  NULL, \
476  { \
477  { PWM_SERVO_9_ACTIVE, NULL }, \
478  { PWM_SERVO_10_ACTIVE, NULL }, \
479  { PWM_SERVO_11_ACTIVE, NULL }, \
480  { PWM_SERVO_13_ACTIVE, NULL }, \
481  }, \
482  0, \
483  0 \
484 }
485 
489 #ifndef DSHOT_TELEMETRY_DEV
490 #define DSHOT_TELEMETRY_DEV NULL
491 #endif
492 
493 #ifndef USE_DSHOT_TIM4
494 #define USE_DSHOT_TIM4 1 // use SRVb for DShot by default
495 #endif
496 
497 #if USE_DSHOT_TIM4 // Servo B1, B2, B3, B4 on TIM4
498 
499 // Servo B1, B2, B3, B4 on TM4 are primary DSHOT connector
500 #define DSHOT_SERVO_1 1
501 #define DSHOT_SERVO_1_GPIO PAL_PORT(LINE_SRVB1)
502 #define DSHOT_SERVO_1_PIN PAL_PAD(LINE_SRVB1)
503 #define DSHOT_SERVO_1_AF AF_SRVB1
504 #define DSHOT_SERVO_1_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVB1_TIM)
505 #define DSHOT_SERVO_1_CHANNEL SRVB1_TIM_CH
506 
507 #define DSHOT_SERVO_2 2
508 #define DSHOT_SERVO_2_GPIO PAL_PORT(LINE_SRVB2)
509 #define DSHOT_SERVO_2_PIN PAL_PAD(LINE_SRVB2)
510 #define DSHOT_SERVO_2_AF AF_SRVB2
511 #define DSHOT_SERVO_2_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVB2_TIM)
512 #define DSHOT_SERVO_2_CHANNEL SRVB2_TIM_CH
513 
514 #define DSHOT_SERVO_3 3
515 #define DSHOT_SERVO_3_GPIO PAL_PORT(LINE_SRVB3)
516 #define DSHOT_SERVO_3_PIN PAL_PAD(LINE_SRVB3)
517 #define DSHOT_SERVO_3_AF AF_SRVB3
518 #define DSHOT_SERVO_3_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVB3_TIM)
519 #define DSHOT_SERVO_3_CHANNEL SRVB3_TIM_CH
520 
521 #define DSHOT_SERVO_4 4
522 #define DSHOT_SERVO_4_GPIO PAL_PORT(LINE_SRVB4)
523 #define DSHOT_SERVO_4_PIN PAL_PAD(LINE_SRVB4)
524 #define DSHOT_SERVO_4_AF AF_SRVB4
525 #define DSHOT_SERVO_4_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVB4_TIM)
526 #define DSHOT_SERVO_4_CHANNEL SRVB4_TIM_CH
527 
528 #define DSHOT_CONF_TIM4 1
529 #define DSHOT_CONF4_DEF { \
530  .dma_stream = STM32_PWM4_UP_DMA_STREAM, \
531  .dma_channel = STM32_PWM4_UP_DMA_CHANNEL, \
532  .pwmp = &PWMD4, \
533  .tlm_sd = DSHOT_TELEMETRY_DEV, \
534  .dma_buf = &dshot4DmaBuffer, \
535  .dcache_memory_in_use = false \
536 }
537 
538 #endif
539 
540 #if USE_DSHOT_TIM1 // Servo A1, A2, A3, A4 on TIM1 only activated if needed
541 
542 #define DSHOT_SERVO_5 5
543 #define DSHOT_SERVO_5_GPIO PAL_PORT(LINE_SRVA1)
544 #define DSHOT_SERVO_5_PIN PAL_PAD(LINE_SRVA1)
545 #define DSHOT_SERVO_5_AF AF_SRVA1
546 #define DSHOT_SERVO_5_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVA1_TIM)
547 #define DSHOT_SERVO_5_CHANNEL SRVA1_TIM_CH
548 
549 #define DSHOT_SERVO_6 6
550 #define DSHOT_SERVO_6_GPIO PAL_PORT(LINE_SRVA2)
551 #define DSHOT_SERVO_6_PIN PAL_PAD(LINE_SRVA2)
552 #define DSHOT_SERVO_6_AF AF_SRVA2
553 #define DSHOT_SERVO_6_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVA2_TIM)
554 #define DSHOT_SERVO_6_CHANNEL SRVA2_TIM_CH
555 
556 #define DSHOT_SERVO_7 7
557 #define DSHOT_SERVO_7_GPIO PAL_PORT(LINE_SRVA3)
558 #define DSHOT_SERVO_7_PIN PAL_PAD(LINE_SRVA3)
559 #define DSHOT_SERVO_7_AF AF_SRVA3
560 #define DSHOT_SERVO_7_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVA3_TIM)
561 #define DSHOT_SERVO_7_CHANNEL SRVA3_TIM_CH
562 
563 #define DSHOT_SERVO_8 8
564 #define DSHOT_SERVO_8_GPIO PAL_PORT(LINE_SRVA4)
565 #define DSHOT_SERVO_8_PIN PAL_PAD(LINE_SRVA4)
566 #define DSHOT_SERVO_8_AF AF_SRVA4
567 #define DSHOT_SERVO_8_DRIVER CONCAT_BOARD_PARAM(DSHOTD, SRVA4_TIM)
568 #define DSHOT_SERVO_8_CHANNEL SRVA4_TIM_CH
569 
570 #define DSHOT_CONF_TIM1 1
571 #define DSHOT_CONF1_DEF { \
572  .dma_stream = STM32_PWM1_UP_DMA_STREAM, \
573  .dma_channel = STM32_PWM1_UP_DMA_CHANNEL, \
574  .pwmp = &PWMD1, \
575  .tlm_sd = DSHOT_TELEMETRY_DEV, \
576  .dma_buf = &dshot1DmaBuffer, \
577  .dcache_memory_in_use = false \
578 }
579 
580 #endif
581 
585 #define UART2_GPIO_PORT_TX PAL_PORT(LINE_UART2_TX)
586 #define UART2_GPIO_TX PAL_PAD(LINE_UART2_TX)
587 #define UART2_GPIO_PORT_RX PAL_PORT(LINE_UART2_RX)
588 #define UART2_GPIO_RX PAL_PAD(LINE_UART2_RX)
589 #define UART2_GPIO_AF AF_UART2_TX
590 #ifndef UART2_HW_FLOW_CONTROL
591 #define UART2_HW_FLOW_CONTROL FALSE
592 #endif
593 
599 #define UART3_GPIO_PORT_TX PAL_PORT(LINE_UART3_TX)
600 #define UART3_GPIO_TX PAL_PAD(LINE_UART3_TX)
601 #define UART3_GPIO_PORT_RX PAL_PORT(LINE_UART3_RX)
602 #define UART3_GPIO_RX PAL_PAD(LINE_UART3_RX)
603 #define UART3_GPIO_AF AF_UART3_TX
604 
605 #define UART7_GPIO_PORT_TX PAL_PORT(LINE_UART7_TX)
606 #define UART7_GPIO_TX PAL_PAD(LINE_UART7_TX)
607 #define UART7_GPIO_PORT_RX PAL_PORT(LINE_UART7_RX)
608 #define UART7_GPIO_RX PAL_PAD(LINE_UART7_RX)
609 #define UART7_GPIO_AF AF_UART7_TX
610 
615 #define UART4_GPIO_PORT_TX PAL_PORT(LINE_AUX_A1)
616 #define UART4_GPIO_TX PAL_PAD(LINE_AUX_A1)
617 #define UART4_GPIO_PORT_RX PAL_PORT(LINE_AUX_A2)
618 #define UART4_GPIO_RX PAL_PAD(LINE_AUX_A2)
619 #define UART4_GPIO_AF AUX_A1_UART_AF
620 
633 // In case, do dynamic config of UARTs
634 #ifndef USE_UART8_RX
635 #define USE_UART8_RX TRUE
636 #endif
637 #ifndef USE_UART8_TX // may be used in half duplex mode
638 #define USE_UART8_TX FALSE
639 #endif
640 // Tx and Rx are configured on the same pin, only one of them should be used
641 #define UART8_GPIO_PORT_TX PAL_PORT(LINE_RC1)
642 #define UART8_GPIO_TX PAL_PAD(LINE_RC1)
643 #define UART8_GPIO_PORT_RX PAL_PORT(LINE_RC1)
644 #define UART8_GPIO_RX PAL_PAD(LINE_RC1)
645 #define UART8_GPIO_AF RC1_UART_AF
646 
647 #ifndef USE_UART6_RX
648 #define USE_UART6_RX FALSE
649 #endif
650 #ifndef USE_UART6_TX
651 #define USE_UART6_TX TRUE
652 #endif
653 // Tx and Rx are configured on the same pin, only one of them should be used
654 #define UART6_GPIO_PORT_TX PAL_PORT(LINE_RC2)
655 #define UART6_GPIO_TX PAL_PAD(LINE_RC2)
656 #define UART6_GPIO_PORT_RX PAL_PORT(LINE_RC2)
657 #define UART6_GPIO_RX PAL_PAD(LINE_RC2)
658 #define UART6_GPIO_AF RC2_USART_AF
659 
660 /* The line that is pulled low at power up to initiate the bind process
661  * PB1: AUXb4
662  */
663 #define SPEKTRUM_BIND_PIN PAL_PORT(LINE_AUX_B4)
664 #define SPEKTRUM_BIND_PIN_PORT PAL_PAD(LINE_AUX_B4)
665 
666 // no wait with chibios as the RTC oscillator takes longer to stabilize
667 #define SPEKTRUM_BIND_WAIT 30000
668 
674 #define RC_PPM_TICKS_PER_USEC 6
675 #define PPM_TIMER_FREQUENCY 6000000
676 #define PPM_CHANNEL CONCAT_BOARD_PARAM(ICU_CHANNEL_, RC2_TIM_CH)
677 #define PPM_TIMER CONCAT_BOARD_PARAM(ICUD, RC2_TIM)
678 
679 /*
680  * PWM input
681  */
682 // PWM_INPUT 1 on PA0 (AUXa1)
683 #define PWM_INPUT1_ICU ICUD2
684 #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
685 #define PWM_INPUT1_GPIO_PORT PAL_PORT(LINE_AUX_A1)
686 #define PWM_INPUT1_GPIO_PIN PAL_PAD(LINE_AUX_A1)
687 #define PWM_INPUT1_GPIO_AF GPIO_AF1
688 
689 // PWM_INPUT 2 on PA1 (AUXa2)
690 #define PWM_INPUT2_ICU ICUD5
691 #define PWM_INPUT2_CHANNEL ICU_CHANNEL_2
692 #define PWM_INPUT2_GPIO_PORT PAL_PORT(LINE_AUX_A2)
693 #define PWM_INPUT2_GPIO_PIN PAL_PAD(LINE_AUX_A2)
694 #define PWM_INPUT2_GPIO_AF GPIO_AF2
695 
699 // Digital noise filter: 0 disabled, [0x1 - 0xF] enable up to n t_I2CCLK
700 #define STM32_CR1_DNF(n) ((n & 0x0f) << 8)
701 // Timing register
702 #define I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(0U) | \
703  STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(0U) | \
704  STM32_TIMINGR_SCLH(34U) | STM32_TIMINGR_SCLL(86U))
705 #define I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR (STM32_TIMINGR_PRESC(1U) | \
706  STM32_TIMINGR_SCLDEL(9U) | STM32_TIMINGR_SDADEL(0U) | \
707  STM32_TIMINGR_SCLH(105U) | STM32_TIMINGR_SCLL(153U))
708 
709 
710 // Internal I2C (baro, magneto)
711 
712 #ifndef I2C4_CLOCK_SPEED
713 #define I2C4_CLOCK_SPEED 400000
714 #endif
715 
716 #if I2C4_CLOCK_SPEED == 400000
717 #define I2C4_CFG_DEF { \
718  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
719  .cr1 = STM32_CR1_DNF(0), \
720  .cr2 = 0 \
721 }
722 #elif I2C4_CLOCK_SPEED == 100000
723 #define I2C4_CFG_DEF { \
724  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
725  .cr1 = STM32_CR1_DNF(0), \
726  .cr2 = 0 \
727 }
728 #else
729 #error "Unknown I2C4 clock speed"
730 #endif
731 
732 // External I2C
733 
734 #ifndef I2C2_CLOCK_SPEED
735 #define I2C2_CLOCK_SPEED 400000
736 #endif
737 
738 #if I2C2_CLOCK_SPEED == 400000
739 #define I2C2_CFG_DEF { \
740  .timingr = I2C_FAST_400KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
741  .cr1 = STM32_CR1_DNF(0), \
742  .cr2 = 0 \
743 }
744 #elif I2C2_CLOCK_SPEED == 100000
745 #define I2C2_CFG_DEF { \
746  .timingr = I2C_STD_100KHZ_DNF0_100NS_PCLK54MHZ_TIMINGR, \
747  .cr1 = STM32_CR1_DNF(0), \
748  .cr2 = 0 \
749 }
750 #else
751 #error "Unknown I2C2 clock speed"
752 #endif
753 
758 // Internal SPI (IMU)
759 #define SPI4_GPIO_AF AF_SPI4_INTERNAL_CLK
760 #define SPI4_GPIO_PORT_MISO PAL_PORT(LINE_SPI4_INTERNAL_MISO)
761 #define SPI4_GPIO_MISO PAL_PAD(LINE_SPI4_INTERNAL_MISO)
762 #define SPI4_GPIO_PORT_MOSI PAL_PORT(LINE_SPI4_INTERNAL_MOSI)
763 #define SPI4_GPIO_MOSI PAL_PAD(LINE_SPI4_INTERNAL_MOSI)
764 #define SPI4_GPIO_PORT_SCK PAL_PORT(LINE_SPI4_INTERNAL_CLK)
765 #define SPI4_GPIO_SCK PAL_PAD(LINE_SPI4_INTERNAL_CLK)
766 
767 // External SPI
768 #define SPI2_GPIO_AF AF_SPI2_EXTERNAL_CLK
769 #define SPI2_GPIO_PORT_MISO PAL_PORT(LINE_SPI2_EXTERNAL_MISO)
770 #define SPI2_GPIO_MISO PAL_PAD(LINE_SPI2_EXTERNAL_MISO)
771 #define SPI2_GPIO_PORT_MOSI PAL_PORT(LINE_SPI2_EXTERNAL_MOSI)
772 #define SPI2_GPIO_MOSI PAL_PAD(LINE_SPI2_EXTERNAL_MOSI)
773 #define SPI2_GPIO_PORT_SCK PAL_PORT(LINE_SPI2_EXTERNAL_CLK)
774 #define SPI2_GPIO_SCK PAL_PAD(LINE_SPI2_EXTERNAL_CLK)
775 
776 // SLAVE0 on SPI connector (NSS possible)
777 #define SPI_SELECT_SLAVE0_PORT PAL_PORT(LINE_SPI2_EXTERNAL_CS)
778 #define SPI_SELECT_SLAVE0_PIN PAL_PAD(LINE_SPI2_EXTERNAL_CS)
779 // SLAVE1 on AUXb1
780 #define SPI_SELECT_SLAVE1_PORT PAL_PORT(LINE_AUX_B1)
781 #define SPI_SELECT_SLAVE1_PIN PAL_PAD(LINE_AUX_B1)
782 // SLAVE2 on AUXb2
783 #define SPI_SELECT_SLAVE2_PORT PAL_PORT(LINE_AUX_B2)
784 #define SPI_SELECT_SLAVE2_PIN PAL_PAD(LINE_AUX_B2)
785 // SLAVE3 on AUXb3
786 #define SPI_SELECT_SLAVE3_PORT PAL_PORT(LINE_AUX_B3)
787 #define SPI_SELECT_SLAVE3_PIN PAL_PAD(LINE_AUX_B3)
788 // SLAVE4 on AUXb4
789 #define SPI_SELECT_SLAVE4_PORT PAL_PORT(LINE_AUX_B4)
790 #define SPI_SELECT_SLAVE4_PIN PAL_PAD(LINE_AUX_B4)
791 // SLAVE5 on PE4 (internal IMU)
792 #define SPI_SELECT_SLAVE5_PORT PAL_PORT(LINE_SPI4_INTERNAL_CS)
793 #define SPI_SELECT_SLAVE5_PIN PAL_PAD(LINE_SPI4_INTERNAL_CS)
794 
801 #ifndef USE_BARO_BOARD
802 #define USE_BARO_BOARD 0
803 #endif
804 
808 #define SDIO_D0_PORT PAL_PORT(LINE_SDMMC1_D0)
809 #define SDIO_D0_PIN PAL_PAD(LINE_SDMMC1_D0)
810 #define SDIO_D1_PORT PAL_PORT(LINE_SDMMC1_D1)
811 #define SDIO_D1_PIN PAL_PAD(LINE_SDMMC1_D1)
812 #define SDIO_D2_PORT PAL_PORT(LINE_SDMMC1_D2)
813 #define SDIO_D2_PIN PAL_PAD(LINE_SDMMC1_D2)
814 #define SDIO_D3_PORT PAL_PORT(LINE_SDMMC1_D3)
815 #define SDIO_D3_PIN PAL_PAD(LINE_SDMMC1_D3)
816 #define SDIO_CK_PORT PAL_PORT(LINE_SDMMC1_CK)
817 #define SDIO_CK_PIN PAL_PAD(LINE_SDMMC1_CK)
818 #define SDIO_CMD_PORT PAL_PORT(LINE_SDMMC1_CMD)
819 #define SDIO_CMD_PIN PAL_PAD(LINE_SDMMC1_CMD)
820 #define SDIO_AF AF_SDMMC1_CK
821 // bat monitoring for file closing
822 #define SDLOG_BAT_ADC CONCAT_BOARD_PARAM(ADCD, VBAT_MEAS_ADC)
823 #define SDLOG_BAT_CHAN CONCAT_BOARD_PARAM(ADC_CHANNEL_IN, VBAT_MEAS_ADC_IN)
824 // usb led status
825 #define SDLOG_USB_LED 4
826 #define SDLOG_USB_VBUS_PORT PAL_PORT(LINE_USB_VBUS)
827 #define SDLOG_USB_VBUS_PIN PAL_PAD(LINE_USB_VBUS)
828 
829 
830 /*
831  * Actuators for fixedwing
832  */
833  /* Default actuators driver */
834 #define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
835 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
836 #define ActuatorsDefaultInit() ActuatorsPwmInit()
837 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
838 
842 #define WS2812D1_GPIO PAL_PORT(LINE_AUX_A1)
843 #define WS2812D1_PIN PAL_PAD(LINE_AUX_A1)
844 #define WS2812D1_AF 2
845 #define WS2812D1_CFG_DEF { \
846  .dma_stream = STM32_PWM5_UP_DMA_STREAM, \
847  .dma_channel = STM32_PWM5_UP_DMA_CHANNEL, \
848  .dma_priority = STM32_PWM5_UP_DMA_PRIORITY, \
849  .pwm_channel = 0, \
850  .pwmp = &PWMD5 \
851 }
852 
853 #endif /* CONFIG_TAWAKI_1_00_H */
854