2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
24 #define DEBUG_MODE DEBUG_NONE
28 #ifndef MAX7456_CLOCK_CONFIG_DEFAULT
29 #define MAX7456_CLOCK_CONFIG_DEFAULT MAX7456_CLOCK_CONFIG_OC
32 #ifndef MAX7456_SPI_CLK
33 #define MAX7456_SPI_CLK (SPI_CLOCK_STANDARD)
36 #ifndef MAX7456_RESTORE_CLK
37 #define MAX7456_RESTORE_CLK (SPI_CLOCK_FAST)
40 #ifndef MAX7456_SPI_CS_PIN
41 #define MAX7456_SPI_CS_PIN NONE
44 #ifndef MAX7456_SPI_INSTANCE
45 #define MAX7456_SPI_INSTANCE NULL
51 #ifdef USE_FLASH_M25P16
53 #define FLASH_CS_PIN NONE
56 #ifndef FLASH_SPI_INSTANCE
57 #define FLASH_SPI_INSTANCE NULL
63 #ifdef USE_FLASH_M25P16
65 #define FLASH_CS_PIN NONE
68 #ifndef FLASH_SPI_INSTANCE
69 #define FLASH_SPI_INSTANCE NULL
75 #ifdef I2C_FULL_RECONFIGURABILITY
76 #ifdef USE_I2C_DEVICE_1
81 #ifdef USE_I2C_DEVICE_2
86 #ifdef USE_I2C_DEVICE_3
91 #ifdef USE_I2C_DEVICE_4
96 #else // I2C_FULL_RECONFIGURABILITY
98 // Backward compatibility for exisiting targets
108 #define I2C2_SCL PB10
111 #define I2C2_SDA PB11
126 #define I2C2_SDA PA10
138 #define I2C2_SCL PB10
141 #define I2C2_SDA PB11
159 #define I2C2_SCL PB10
162 #define I2C2_SDA PB11
171 #define I2C4_SCL PD12
174 #define I2C4_SDA PD13
178 #endif // I2C_FULL_RECONFIGURABILITY
180 #ifndef I2C1_OVERCLOCK
181 #define I2C1_OVERCLOCK false
183 #ifndef I2C2_OVERCLOCK
184 #define I2C2_OVERCLOCK false
186 #ifndef I2C3_OVERCLOCK
187 #define I2C3_OVERCLOCK false
189 #ifndef I2C4_OVERCLOCK
190 #define I2C4_OVERCLOCK false
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
201 #define I2C1_PULLUP false
202 #define I2C2_PULLUP false
203 #define I2C3_PULLUP false
204 #define I2C4_PULLUP false
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
217 #ifdef USE_SPI_DEVICE_2
218 #define SPI2_SCK_PIN NONE
219 #define SPI2_MISO_PIN NONE
220 #define SPI2_MOSI_PIN NONE
223 #ifdef USE_SPI_DEVICE_3
224 #define SPI3_SCK_PIN NONE
225 #define SPI3_MISO_PIN NONE
226 #define SPI3_MOSI_PIN NONE
229 #ifdef USE_SPI_DEVICE_4
230 #define SPI4_SCK_PIN NONE
231 #define SPI4_MISO_PIN NONE
232 #define SPI4_MOSI_PIN NONE
237 // Pin defaults for backward compatibility
240 #define SPI1_SCK_PIN PA5
241 #define SPI1_MISO_PIN PA6
242 #define SPI1_MOSI_PIN PA7
246 #define SPI2_SCK_PIN PB13
247 #define SPI2_MISO_PIN PB14
248 #define SPI2_MOSI_PIN PB15
252 #define SPI3_SCK_PIN PB3
253 #define SPI3_MISO_PIN PB4
254 #define SPI3_MOSI_PIN PB5
258 #define SPI4_SCK_PIN NONE
259 #define SPI4_MISO_PIN NONE
260 #define SPI4_MOSI_PIN NONE
264 #define SPI5_SCK_PIN NONE
265 #define SPI5_MISO_PIN NONE
266 #define SPI5_MOSI_PIN NONE
270 #define SPI6_SCK_PIN NONE
271 #define SPI6_MISO_PIN NONE
272 #define SPI6_MOSI_PIN NONE
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
284 #ifndef SERIALRX_PROVIDER
285 #define SERIALRX_PROVIDER 0
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
297 #define BINDPLUG_PIN NONE
301 #if !defined(RX_SPI_INSTANCE)
302 #define RX_SPI_INSTANCE NULL
305 #if !defined(RX_NSS_PIN)
306 #define RX_NSS_PIN NONE
309 #ifndef RX_SPI_LED_PIN
310 #define RX_SPI_LED_PIN NONE
313 #if !defined(RX_SPI_EXTI_PIN)
314 #define RX_SPI_EXTI_PIN NONE
317 #if !defined(RX_SPI_BIND_PIN)
318 #define RX_SPI_BIND_PIN NONE
321 #if defined(USE_RX_CC2500)
322 #if !defined(RX_CC2500_SPI_TX_EN_PIN)
323 #define RX_CC2500_SPI_TX_EN_PIN NONE
326 #if !defined(RX_CC2500_SPI_LNA_EN_PIN)
327 #define RX_CC2500_SPI_LNA_EN_PIN NONE
330 #if !defined(RX_CC2500_SPI_ANT_SEL_PIN)
331 #define RX_CC2500_SPI_ANT_SEL_PIN NONE
338 #if !defined(GYRO_1_SPI_INSTANCE)
339 #define GYRO_1_SPI_INSTANCE NULL
342 #if !defined(GYRO_1_CS_PIN)
343 #define GYRO_1_CS_PIN NONE
346 #if !defined(GYRO_1_EXTI_PIN)
347 #define GYRO_1_EXTI_PIN NONE
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
357 #if defined(MPU_ADDRESS)
358 #define GYRO_I2C_ADDRESS MPU_ADDRESS
360 #define GYRO_I2C_ADDRESS 0 // AUTO
363 #ifdef USE_MULTI_GYRO
364 #define MAX_GYRODEV_COUNT 2
365 #define MAX_ACCDEV_COUNT 2
367 #define MAX_GYRODEV_COUNT 1
368 #define MAX_ACCDEV_COUNT 1
373 #if !defined(GYRO_1_ALIGN)
374 #define GYRO_1_ALIGN CW0_DEG
377 #if !defined(GYRO_2_ALIGN)
378 #define GYRO_2_ALIGN CW0_DEG
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.
387 #ifndef USB_DETECT_PIN
388 #define USB_DETECT_PIN NONE
390 #ifndef USB_MSC_BUTTON_PIN
391 #define USB_MSC_BUTTON_PIN NONE
393 #if !defined(MSC_BUTTON_IPU)
394 #define MSC_BUTTON_IPU true
398 #ifdef USE_TIMER_MGMT
399 #ifndef MAX_TIMER_PINMAP_COUNT
400 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
405 #ifndef SDCARD_DETECT_PIN
406 #define SDCARD_DETECT_PIN NONE
408 #ifdef SDCARD_DETECT_INVERTED
409 #define SDCARD_DETECT_IS_INVERTED 1
411 #define SDCARD_DETECT_IS_INVERTED 0
413 #ifdef USE_SDCARD_SPI
414 #ifndef SDCARD_SPI_INSTANCE
415 #define SDCARD_SPI_INSTANCE NULL
417 #ifndef SDCARD_SPI_CS_PIN
418 #define SDCARD_SPI_CS_PIN NONE
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)
426 #define SDIO_DEVICE SDIOINVALID
428 #ifndef SDIO_USE_4BIT
429 #define SDIO_USE_4BIT false
432 #define SDIO_CK_PIN NONE
435 #define SDIO_CMD_PIN NONE
438 #define SDIO_D0_PIN NONE
441 #define SDIO_D1_PIN NONE
444 #define SDIO_D2_PIN NONE
447 #define SDIO_D3_PIN NONE
449 #endif // USE_SDCARD_SDIO
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)
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)
462 #ifndef DEFAULT_MIXER
463 #define DEFAULT_MIXER MIXER_QUADX
466 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
467 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
468 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
470 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
471 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
477 #ifndef MAG_SPI_INSTANCE
478 #define MAG_SPI_INSTANCE NULL
481 #define MAG_CS_PIN NONE
483 #ifndef MAG_I2C_INSTANCE
484 #define MAG_I2C_INSTANCE I2C_DEVICE
489 #define MAG_INT_EXTI NONE
493 #if defined(USE_BARO)
494 #ifndef BARO_SPI_INSTANCE
495 #define BARO_SPI_INSTANCE NULL
498 #define BARO_CS_PIN NONE
500 #ifndef BARO_I2C_INSTANCE
501 #define BARO_I2C_INSTANCE I2C_DEVICE
503 #ifndef BARO_XCLR_PIN
504 #define BARO_XCLR_PIN NONE
509 #if !defined(USE_UNIFIED_TARGET) && !defined(ADC_INSTANCE)
510 #define ADC_INSTANCE ADC1
512 #define ADC1_DMA_OPT 1
516 #if !defined(ADC1_DMA_OPT)
517 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
519 #if !defined(ADC2_DMA_OPT)
520 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
522 #if !defined(ADC3_DMA_OPT)
523 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
525 #if !defined(ADC4_DMA_OPT)
526 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
528 #if !defined(ADC4_DMA_OPT)
529 #define ADC4_DMA_OPT (-1)
535 #ifdef USE_SPI_DEVICE_1
536 #ifndef SPI1_TX_DMA_OPT
537 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
539 #ifndef SPI1_RX_DMA_OPT
540 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
543 #ifdef USE_SPI_DEVICE_2
544 #ifndef SPI2_TX_DMA_OPT
545 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
547 #ifndef SPI2_RX_DMA_OPT
548 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
551 #ifdef USE_SPI_DEVICE_3
552 #ifndef SPI3_TX_DMA_OPT
553 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
555 #ifndef SPI3_RX_DMA_OPT
556 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
559 #ifdef USE_SPI_DEVICE_4
560 #ifndef SPI4_TX_DMA_OPT
561 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
563 #ifndef SPI4_RX_DMA_OPT
564 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
570 #ifndef UART1_TX_DMA_OPT
571 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
573 #ifndef UART1_RX_DMA_OPT
574 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
579 #ifndef UART2_TX_DMA_OPT
580 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
582 #ifndef UART2_RX_DMA_OPT
583 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
588 #ifndef UART3_TX_DMA_OPT
589 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
591 #ifndef UART3_RX_DMA_OPT
592 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
597 #ifndef UART4_TX_DMA_OPT
598 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
600 #ifndef UART4_RX_DMA_OPT
601 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
606 #ifndef UART5_TX_DMA_OPT
607 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
609 #ifndef UART5_RX_DMA_OPT
610 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
615 #ifndef UART6_TX_DMA_OPT
616 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
618 #ifndef UART6_RX_DMA_OPT
619 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
624 #ifndef UART7_TX_DMA_OPT
625 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
627 #ifndef UART7_RX_DMA_OPT
628 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
633 #ifndef UART8_TX_DMA_OPT
634 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
636 #ifndef UART8_RX_DMA_OPT
637 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
641 #ifndef RTC6705_CS_PIN
642 #define RTC6705_CS_PIN NONE
645 #ifndef RTC6705_POWER_PIN
646 #define RTC6705_POWER_PIN NONE
649 #ifndef RTC6705_SPICLK_PIN
650 #define RTC6705_SPICLK_PIN NONE
653 #ifndef RTC6705_SPI_MOSI_PIN
654 #define RTC6705_SPI_MOSI_PIN NONE
657 #ifndef RTC6705_SPI_INSTANCE
658 #define RTC6705_SPI_INSTANCE NULL
661 #if defined(USE_QUAD_MIXER_ONLY)
662 #define MAX_SUPPORTED_MOTORS 4
663 #define MAX_SUPPORTED_SERVOS 1
665 #ifndef MAX_SUPPORTED_MOTORS
666 #define MAX_SUPPORTED_MOTORS 8
668 #define MAX_SUPPORTED_SERVOS 8
671 #if defined(USE_DSHOT_BITBANG)
672 #if !defined(DSHOT_BITBANG_DEFAULT)
673 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
676 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
677 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
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