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