Add temporary facility of vendor specific init string to displayport msp
[betaflight.git] / src / main / target / common_defaults_post.h
blobcb642120b7d007a4bc1f60cb83faee3e7ccbe028
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 // pg/max7456
23 #ifndef DEBUG_MODE
24 #define DEBUG_MODE DEBUG_NONE
25 #endif
27 #ifdef USE_MAX7456
28 #ifndef MAX7456_CLOCK_CONFIG_DEFAULT
29 #define MAX7456_CLOCK_CONFIG_DEFAULT MAX7456_CLOCK_CONFIG_OC
30 #endif
32 #ifndef MAX7456_SPI_CLK
33 #define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD)
34 #endif
36 #ifndef MAX7456_RESTORE_CLK
37 #define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
38 #endif
40 #ifndef MAX7456_SPI_CS_PIN
41 #define MAX7456_SPI_CS_PIN NONE
42 #endif
44 #ifndef MAX7456_SPI_INSTANCE
45 #define MAX7456_SPI_INSTANCE NULL
46 #endif
47 #endif
49 // pg/flash
51 #ifdef USE_FLASH_M25P16
52 #ifndef FLASH_CS_PIN
53 #define FLASH_CS_PIN NONE
54 #endif
56 #ifndef FLASH_SPI_INSTANCE
57 #define FLASH_SPI_INSTANCE NULL
58 #endif
59 #endif
61 // pg/flash
63 #ifdef USE_FLASH_M25P16
64 #ifndef FLASH_CS_PIN
65 #define FLASH_CS_PIN NONE
66 #endif
68 #ifndef FLASH_SPI_INSTANCE
69 #define FLASH_SPI_INSTANCE NULL
70 #endif
71 #endif
73 // pg/bus_i2c
75 #ifdef I2C_FULL_RECONFIGURABILITY
76 #ifdef USE_I2C_DEVICE_1
77 #define I2C1_SCL NONE
78 #define I2C1_SDA NONE
79 #endif
81 #ifdef USE_I2C_DEVICE_2
82 #define I2C2_SCL NONE
83 #define I2C2_SDA NONE
84 #endif
86 #ifdef USE_I2C_DEVICE_3
87 #define I2C3_SCL NONE
88 #define I2C3_SDA NONE
89 #endif
91 #ifdef USE_I2C_DEVICE_4
92 #define I2C4_SCL NONE
93 #define I2C4_SDA NONE
94 #endif
96 #else // I2C_FULL_RECONFIGURABILITY
98 // Backward compatibility for exisiting targets
100 #ifdef STM32F1
101 #ifndef I2C1_SCL
102 #define I2C1_SCL PB8
103 #endif
104 #ifndef I2C1_SDA
105 #define I2C1_SDA PB9
106 #endif
107 #ifndef I2C2_SCL
108 #define I2C2_SCL PB10
109 #endif
110 #ifndef I2C2_SDA
111 #define I2C2_SDA PB11
112 #endif
113 #endif // STM32F1
115 #ifdef STM32F3
116 #ifndef I2C1_SCL
117 #define I2C1_SCL PB6
118 #endif
119 #ifndef I2C1_SDA
120 #define I2C1_SDA PB7
121 #endif
122 #ifndef I2C2_SCL
123 #define I2C2_SCL PA9
124 #endif
125 #ifndef I2C2_SDA
126 #define I2C2_SDA PA10
127 #endif
128 #endif // STM32F3
130 #ifdef STM32F4
131 #ifndef I2C1_SCL
132 #define I2C1_SCL PB6
133 #endif
134 #ifndef I2C1_SDA
135 #define I2C1_SDA PB7
136 #endif
137 #ifndef I2C2_SCL
138 #define I2C2_SCL PB10
139 #endif
140 #ifndef I2C2_SDA
141 #define I2C2_SDA PB11
142 #endif
143 #ifndef I2C3_SCL
144 #define I2C3_SCL PA8
145 #endif
146 #ifndef I2C3_SDA
147 #define I2C3_SDA PC9
148 #endif
149 #endif // STM32F4
151 #ifdef STM32F7
152 #ifndef I2C1_SCL
153 #define I2C1_SCL PB6
154 #endif
155 #ifndef I2C1_SDA
156 #define I2C1_SDA PB7
157 #endif
158 #ifndef I2C2_SCL
159 #define I2C2_SCL PB10
160 #endif
161 #ifndef I2C2_SDA
162 #define I2C2_SDA PB11
163 #endif
164 #ifndef I2C3_SCL
165 #define I2C3_SCL PA8
166 #endif
167 #ifndef I2C3_SDA
168 #define I2C3_SDA PB4
169 #endif
170 #ifndef I2C4_SCL
171 #define I2C4_SCL PD12
172 #endif
173 #ifndef I2C4_SDA
174 #define I2C4_SDA PD13
175 #endif
176 #endif // STM32F7
178 #endif // I2C_FULL_RECONFIGURABILITY
180 #ifndef I2C1_OVERCLOCK
181 #define I2C1_OVERCLOCK false
182 #endif
183 #ifndef I2C2_OVERCLOCK
184 #define I2C2_OVERCLOCK false
185 #endif
186 #ifndef I2C3_OVERCLOCK
187 #define I2C3_OVERCLOCK false
188 #endif
189 #ifndef I2C4_OVERCLOCK
190 #define I2C4_OVERCLOCK false
191 #endif
193 // Default values for internal pullup
195 #if defined(USE_I2C_PULLUP)
196 #define I2C1_PULLUP true
197 #define I2C2_PULLUP true
198 #define I2C3_PULLUP true
199 #define I2C4_PULLUP true
200 #else
201 #define I2C1_PULLUP false
202 #define I2C2_PULLUP false
203 #define I2C3_PULLUP false
204 #define I2C4_PULLUP false
205 #endif
207 // pg/bus_spi
209 #ifdef SPI_FULL_RECONFIGURABILITY
211 #ifdef USE_SPI_DEVICE_1
212 #define SPI1_SCK_PIN NONE
213 #define SPI1_MISO_PIN NONE
214 #define SPI1_MOSI_PIN NONE
215 #endif
217 #ifdef USE_SPI_DEVICE_2
218 #define SPI2_SCK_PIN NONE
219 #define SPI2_MISO_PIN NONE
220 #define SPI2_MOSI_PIN NONE
221 #endif
223 #ifdef USE_SPI_DEVICE_3
224 #define SPI3_SCK_PIN NONE
225 #define SPI3_MISO_PIN NONE
226 #define SPI3_MOSI_PIN NONE
227 #endif
229 #ifdef USE_SPI_DEVICE_4
230 #define SPI4_SCK_PIN NONE
231 #define SPI4_MISO_PIN NONE
232 #define SPI4_MOSI_PIN NONE
233 #endif
235 #else
237 // Pin defaults for backward compatibility
239 #ifndef SPI1_SCK_PIN
240 #define SPI1_SCK_PIN PA5
241 #define SPI1_MISO_PIN PA6
242 #define SPI1_MOSI_PIN PA7
243 #endif
245 #ifndef SPI2_SCK_PIN
246 #define SPI2_SCK_PIN PB13
247 #define SPI2_MISO_PIN PB14
248 #define SPI2_MOSI_PIN PB15
249 #endif
251 #ifndef SPI3_SCK_PIN
252 #define SPI3_SCK_PIN PB3
253 #define SPI3_MISO_PIN PB4
254 #define SPI3_MOSI_PIN PB5
255 #endif
257 #ifndef SPI4_SCK_PIN
258 #define SPI4_SCK_PIN NONE
259 #define SPI4_MISO_PIN NONE
260 #define SPI4_MOSI_PIN NONE
261 #endif
263 #ifndef SPI5_SCK_PIN
264 #define SPI5_SCK_PIN NONE
265 #define SPI5_MISO_PIN NONE
266 #define SPI5_MOSI_PIN NONE
267 #endif
269 #ifndef SPI6_SCK_PIN
270 #define SPI6_SCK_PIN NONE
271 #define SPI6_MISO_PIN NONE
272 #define SPI6_MOSI_PIN NONE
273 #endif
275 #endif
277 // Extracted from rx/rx.c and rx/rx.h
279 #define RX_MAPPABLE_CHANNEL_COUNT 8
281 #ifndef RX_SPI_DEFAULT_PROTOCOL
282 #define RX_SPI_DEFAULT_PROTOCOL 0
283 #endif
284 #ifndef SERIALRX_PROVIDER
285 #define SERIALRX_PROVIDER 0
286 #endif
288 #define RX_MIN_USEC 885
289 #define RX_MAX_USEC 2115
290 #define RX_MID_USEC 1500
292 #ifndef SPEKTRUM_BIND_PIN
293 #define SPEKTRUM_BIND_PIN NONE
294 #endif
296 #ifndef BINDPLUG_PIN
297 #define BINDPLUG_PIN NONE
298 #endif
300 #ifdef USE_RX_SPI
301 #if !defined(RX_SPI_INSTANCE)
302 #define RX_SPI_INSTANCE NULL
303 #endif
305 #if !defined(RX_NSS_PIN)
306 #define RX_NSS_PIN NONE
307 #endif
309 #ifndef RX_SPI_LED_PIN
310 #define RX_SPI_LED_PIN NONE
311 #endif
313 #if !defined(RX_SPI_EXTI_PIN)
314 #define RX_SPI_EXTI_PIN NONE
315 #endif
317 #if !defined(RX_SPI_BIND_PIN)
318 #define RX_SPI_BIND_PIN NONE
319 #endif
321 #if defined(USE_RX_CC2500)
322 #if !defined(RX_CC2500_SPI_TX_EN_PIN)
323 #define RX_CC2500_SPI_TX_EN_PIN NONE
324 #endif
326 #if !defined(RX_CC2500_SPI_LNA_EN_PIN)
327 #define RX_CC2500_SPI_LNA_EN_PIN NONE
328 #endif
330 #if !defined(RX_CC2500_SPI_ANT_SEL_PIN)
331 #define RX_CC2500_SPI_ANT_SEL_PIN NONE
332 #endif
333 #endif
334 #endif
336 // gyro hardware
338 #if !defined(GYRO_1_SPI_INSTANCE)
339 #define GYRO_1_SPI_INSTANCE NULL
340 #endif
342 #if !defined(GYRO_1_CS_PIN)
343 #define GYRO_1_CS_PIN NONE
344 #endif
346 #if !defined(GYRO_1_EXTI_PIN)
347 #define GYRO_1_EXTI_PIN NONE
348 #endif
350 // F4 and F7 single gyro boards
351 #if defined(USE_MULTI_GYRO) && !defined(GYRO_2_SPI_INSTANCE)
352 #define GYRO_2_SPI_INSTANCE NULL
353 #define GYRO_2_CS_PIN NONE
354 #define GYRO_2_EXTI_PIN NONE
355 #endif
357 #if defined(MPU_ADDRESS)
358 #define GYRO_I2C_ADDRESS MPU_ADDRESS
359 #else
360 #define GYRO_I2C_ADDRESS 0 // AUTO
361 #endif
363 #ifdef USE_MULTI_GYRO
364 #define MAX_GYRODEV_COUNT 2
365 #define MAX_ACCDEV_COUNT 2
366 #else
367 #define MAX_GYRODEV_COUNT 1
368 #define MAX_ACCDEV_COUNT 1
369 #endif
371 // gyro alignments
373 #if !defined(GYRO_1_ALIGN)
374 #define GYRO_1_ALIGN CW0_DEG
375 #endif
377 #if !defined(GYRO_2_ALIGN)
378 #define GYRO_2_ALIGN CW0_DEG
379 #endif
381 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
382 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
383 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
384 // if a custom alignment is not applied in the target.
386 #ifdef USE_VCP
387 #ifndef USB_DETECT_PIN
388 #define USB_DETECT_PIN NONE
389 #endif
390 #ifndef USB_MSC_BUTTON_PIN
391 #define USB_MSC_BUTTON_PIN NONE
392 #endif
393 #if !defined(MSC_BUTTON_IPU)
394 #define MSC_BUTTON_IPU true
395 #endif
396 #endif
398 #ifdef USE_TIMER_MGMT
399 #ifndef MAX_TIMER_PINMAP_COUNT
400 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
401 #endif
402 #endif
404 #ifdef USE_SDCARD
405 #ifndef SDCARD_DETECT_PIN
406 #define SDCARD_DETECT_PIN NONE
407 #endif
408 #ifdef SDCARD_DETECT_INVERTED
409 #define SDCARD_DETECT_IS_INVERTED 1
410 #else
411 #define SDCARD_DETECT_IS_INVERTED 0
412 #endif
413 #ifdef USE_SDCARD_SPI
414 #ifndef SDCARD_SPI_INSTANCE
415 #define SDCARD_SPI_INSTANCE NULL
416 #endif
417 #ifndef SDCARD_SPI_CS_PIN
418 #define SDCARD_SPI_CS_PIN NONE
419 #endif
420 #endif // USE_SDCARD_SPI
421 #ifdef USE_SDCARD_SDIO
422 #ifndef SDCARD_SDIO_DMA_OPT
423 #define SDCARD_SDIO_DMA_OPT (DMA_OPT_UNUSED)
424 #endif
425 #ifndef SDIO_DEVICE
426 #define SDIO_DEVICE SDIOINVALID
427 #endif
428 #ifndef SDIO_USE_4BIT
429 #define SDIO_USE_4BIT false
430 #endif
431 #ifndef SDIO_CK_PIN
432 #define SDIO_CK_PIN NONE
433 #endif
434 #ifndef SDIO_CMD_PIN
435 #define SDIO_CMD_PIN NONE
436 #endif
437 #ifndef SDIO_D0_PIN
438 #define SDIO_D0_PIN NONE
439 #endif
440 #ifndef SDIO_D1_PIN
441 #define SDIO_D1_PIN NONE
442 #endif
443 #ifndef SDIO_D2_PIN
444 #define SDIO_D2_PIN NONE
445 #endif
446 #ifndef SDIO_D3_PIN
447 #define SDIO_D3_PIN NONE
448 #endif
449 #endif // USE_SDCARD_SDIO
450 #endif // USE_SDCARD
452 #if defined(USE_UART1) || defined(USE_UART2) || defined(USE_UART3) || defined(USE_UART4) || defined(USE_UART5) || defined(USE_UART6) || defined(USE_UART7) || defined(USE_UART8)
453 #define USE_UART
454 #endif
456 #ifdef USE_UART
457 #if defined(INVERTER_PIN_UART1) || defined(INVERTER_PIN_UART2) || defined(INVERTER_PIN_UART3) || defined(INVERTER_PIN_UART4) || defined(INVERTER_PIN_UART5) || defined(INVERTER_PIN_UART6)
458 #define USE_INVERTER
459 #endif
460 #endif
462 #ifndef DEFAULT_MIXER
463 #define DEFAULT_MIXER MIXER_QUADX
464 #endif
466 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
467 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
468 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
469 #endif
470 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
471 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
472 #endif
473 #endif
475 // Mag
476 #if defined(USE_MAG)
477 #ifndef MAG_SPI_INSTANCE
478 #define MAG_SPI_INSTANCE NULL
479 #endif
480 #ifndef MAG_CS_PIN
481 #define MAG_CS_PIN NONE
482 #endif
483 #ifndef MAG_I2C_INSTANCE
484 #define MAG_I2C_INSTANCE I2C_DEVICE
485 #endif
486 #endif
488 #ifndef MAG_INT_EXTI
489 #define MAG_INT_EXTI NONE
490 #endif
492 // Baro
493 #if defined(USE_BARO)
494 #ifndef BARO_SPI_INSTANCE
495 #define BARO_SPI_INSTANCE NULL
496 #endif
497 #ifndef BARO_CS_PIN
498 #define BARO_CS_PIN NONE
499 #endif
500 #ifndef BARO_I2C_INSTANCE
501 #define BARO_I2C_INSTANCE I2C_DEVICE
502 #endif
503 #ifndef BARO_XCLR_PIN
504 #define BARO_XCLR_PIN NONE
505 #endif
506 #endif
508 #ifdef USE_ADC
509 #if !defined(USE_UNIFIED_TARGET) && !defined(ADC_INSTANCE)
510 #define ADC_INSTANCE ADC1
511 #ifndef ADC1_DMA_OPT
512 #define ADC1_DMA_OPT 1
513 #endif
514 #endif
516 #if !defined(ADC1_DMA_OPT)
517 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
518 #endif
519 #if !defined(ADC2_DMA_OPT)
520 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
521 #endif
522 #if !defined(ADC3_DMA_OPT)
523 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
524 #endif
525 #if !defined(ADC4_DMA_OPT)
526 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
527 #endif
528 #if !defined(ADC4_DMA_OPT)
529 #define ADC4_DMA_OPT (-1)
530 #endif
532 #endif // USE_ADC
534 #ifdef USE_SPI
535 #ifdef USE_SPI_DEVICE_1
536 #ifndef SPI1_TX_DMA_OPT
537 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
538 #endif
539 #ifndef SPI1_RX_DMA_OPT
540 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
541 #endif
542 #endif
543 #ifdef USE_SPI_DEVICE_2
544 #ifndef SPI2_TX_DMA_OPT
545 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
546 #endif
547 #ifndef SPI2_RX_DMA_OPT
548 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
549 #endif
550 #endif
551 #ifdef USE_SPI_DEVICE_3
552 #ifndef SPI3_TX_DMA_OPT
553 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
554 #endif
555 #ifndef SPI3_RX_DMA_OPT
556 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
557 #endif
558 #endif
559 #ifdef USE_SPI_DEVICE_4
560 #ifndef SPI4_TX_DMA_OPT
561 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
562 #endif
563 #ifndef SPI4_RX_DMA_OPT
564 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
565 #endif
566 #endif
567 #endif
569 #ifdef USE_UART1
570 #ifndef UART1_TX_DMA_OPT
571 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
572 #endif
573 #ifndef UART1_RX_DMA_OPT
574 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
575 #endif
576 #endif
578 #ifdef USE_UART2
579 #ifndef UART2_TX_DMA_OPT
580 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
581 #endif
582 #ifndef UART2_RX_DMA_OPT
583 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
584 #endif
585 #endif
587 #ifdef USE_UART3
588 #ifndef UART3_TX_DMA_OPT
589 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
590 #endif
591 #ifndef UART3_RX_DMA_OPT
592 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
593 #endif
594 #endif
596 #ifdef USE_UART4
597 #ifndef UART4_TX_DMA_OPT
598 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
599 #endif
600 #ifndef UART4_RX_DMA_OPT
601 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
602 #endif
603 #endif
605 #ifdef USE_UART5
606 #ifndef UART5_TX_DMA_OPT
607 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
608 #endif
609 #ifndef UART5_RX_DMA_OPT
610 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
611 #endif
612 #endif
614 #ifdef USE_UART6
615 #ifndef UART6_TX_DMA_OPT
616 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
617 #endif
618 #ifndef UART6_RX_DMA_OPT
619 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
620 #endif
621 #endif
623 #ifdef USE_UART7
624 #ifndef UART7_TX_DMA_OPT
625 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
626 #endif
627 #ifndef UART7_RX_DMA_OPT
628 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
629 #endif
630 #endif
632 #ifdef USE_UART8
633 #ifndef UART8_TX_DMA_OPT
634 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
635 #endif
636 #ifndef UART8_RX_DMA_OPT
637 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
638 #endif
639 #endif
641 #ifndef RTC6705_CS_PIN
642 #define RTC6705_CS_PIN NONE
643 #endif
645 #ifndef RTC6705_POWER_PIN
646 #define RTC6705_POWER_PIN NONE
647 #endif
649 #ifndef RTC6705_SPICLK_PIN
650 #define RTC6705_SPICLK_PIN NONE
651 #endif
653 #ifndef RTC6705_SPI_MOSI_PIN
654 #define RTC6705_SPI_MOSI_PIN NONE
655 #endif
657 #ifndef RTC6705_SPI_INSTANCE
658 #define RTC6705_SPI_INSTANCE NULL
659 #endif
661 #if defined(USE_QUAD_MIXER_ONLY)
662 #define MAX_SUPPORTED_MOTORS 4
663 #define MAX_SUPPORTED_SERVOS 1
664 #else
665 #ifndef MAX_SUPPORTED_MOTORS
666 #define MAX_SUPPORTED_MOTORS 8
667 #endif
668 #define MAX_SUPPORTED_SERVOS 8
669 #endif
671 #if defined(USE_DSHOT_BITBANG)
672 #if !defined(DSHOT_BITBANG_DEFAULT)
673 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
674 #endif
676 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
677 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
678 #endif
679 #endif // USE_DSHOT_BITBANG
681 // XXX Tentative; may be removed
682 #if defined(USE_MSP_DISPLAYPORT) && defined(USE_OSD_OVER_MSP_DISPLAYPORT)
683 #define USE_DISPLAYPORT_MSP_VENDOR_SPECIFIC
684 #endif