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_CS_PIN
33 #define MAX7456_SPI_CS_PIN NONE
36 #ifndef MAX7456_SPI_INSTANCE
37 #define MAX7456_SPI_INSTANCE NULL
43 #ifdef USE_FLASH_M25P16
45 #define FLASH_CS_PIN NONE
48 #ifndef FLASH_SPI_INSTANCE
49 #define FLASH_SPI_INSTANCE NULL
55 #ifdef USE_FLASH_M25P16
57 #define FLASH_CS_PIN NONE
60 #ifndef FLASH_SPI_INSTANCE
61 #define FLASH_SPI_INSTANCE NULL
67 #ifdef I2C_FULL_RECONFIGURABILITY
68 #ifdef USE_I2C_DEVICE_1
73 #ifdef USE_I2C_DEVICE_2
78 #ifdef USE_I2C_DEVICE_3
83 #ifdef USE_I2C_DEVICE_4
88 #else // I2C_FULL_RECONFIGURABILITY
90 // Backward compatibility for exisiting targets
100 #define I2C2_SCL PB10
103 #define I2C2_SDA PB11
118 #define I2C2_SDA PA10
130 #define I2C2_SCL PB10
133 #define I2C2_SDA PB11
151 #define I2C2_SCL PB10
154 #define I2C2_SDA PB11
163 #define I2C4_SCL PD12
166 #define I2C4_SDA PD13
170 #endif // I2C_FULL_RECONFIGURABILITY
172 #ifndef I2C1_CLOCKSPEED
173 #define I2C1_CLOCKSPEED 800
175 #ifndef I2C2_CLOCKSPEED
176 #define I2C2_CLOCKSPEED 800
178 #ifndef I2C3_CLOCKSPEED
179 #define I2C3_CLOCKSPEED 800
181 #ifndef I2C4_CLOCKSPEED
182 #define I2C4_CLOCKSPEED 800
185 // Default values for internal pullup
187 #if defined(USE_I2C_PULLUP)
188 #define I2C1_PULLUP true
189 #define I2C2_PULLUP true
190 #define I2C3_PULLUP true
191 #define I2C4_PULLUP true
193 #define I2C1_PULLUP false
194 #define I2C2_PULLUP false
195 #define I2C3_PULLUP false
196 #define I2C4_PULLUP false
201 #ifdef SPI_FULL_RECONFIGURABILITY
203 #ifdef USE_SPI_DEVICE_1
204 #define SPI1_SCK_PIN NONE
205 #define SPI1_MISO_PIN NONE
206 #define SPI1_MOSI_PIN NONE
209 #ifdef USE_SPI_DEVICE_2
210 #define SPI2_SCK_PIN NONE
211 #define SPI2_MISO_PIN NONE
212 #define SPI2_MOSI_PIN NONE
215 #ifdef USE_SPI_DEVICE_3
216 #define SPI3_SCK_PIN NONE
217 #define SPI3_MISO_PIN NONE
218 #define SPI3_MOSI_PIN NONE
221 #ifdef USE_SPI_DEVICE_4
222 #define SPI4_SCK_PIN NONE
223 #define SPI4_MISO_PIN NONE
224 #define SPI4_MOSI_PIN NONE
229 // Pin defaults for backward compatibility
232 #define SPI1_SCK_PIN PA5
233 #define SPI1_MISO_PIN PA6
234 #define SPI1_MOSI_PIN PA7
238 #define SPI2_SCK_PIN PB13
239 #define SPI2_MISO_PIN PB14
240 #define SPI2_MOSI_PIN PB15
244 #define SPI3_SCK_PIN PB3
245 #define SPI3_MISO_PIN PB4
246 #define SPI3_MOSI_PIN PB5
250 #define SPI4_SCK_PIN NONE
251 #define SPI4_MISO_PIN NONE
252 #define SPI4_MOSI_PIN NONE
256 #define SPI5_SCK_PIN NONE
257 #define SPI5_MISO_PIN NONE
258 #define SPI5_MOSI_PIN NONE
262 #define SPI6_SCK_PIN NONE
263 #define SPI6_MISO_PIN NONE
264 #define SPI6_MOSI_PIN NONE
269 // Extracted from rx/rx.c and rx/rx.h
271 #define RX_MAPPABLE_CHANNEL_COUNT 8
273 #ifndef RX_SPI_DEFAULT_PROTOCOL
274 #define RX_SPI_DEFAULT_PROTOCOL 0
276 #ifndef SERIALRX_PROVIDER
277 #define SERIALRX_PROVIDER 0
280 #define RX_MIN_USEC 885
281 #define RX_MAX_USEC 2115
282 #define RX_MID_USEC 1500
284 #ifndef SPEKTRUM_BIND_PIN
285 #define SPEKTRUM_BIND_PIN NONE
289 #define BINDPLUG_PIN NONE
293 #if !defined(RX_SPI_INSTANCE)
294 #define RX_SPI_INSTANCE NULL
297 #if !defined(RX_NSS_PIN)
298 #define RX_NSS_PIN NONE
301 #ifndef RX_SPI_LED_PIN
302 #define RX_SPI_LED_PIN NONE
305 #if !defined(RX_SPI_EXTI_PIN)
306 #define RX_SPI_EXTI_PIN NONE
309 #if !defined(RX_SPI_BIND_PIN)
310 #define RX_SPI_BIND_PIN NONE
313 #if defined(USE_RX_CC2500)
314 #if !defined(RX_CC2500_SPI_TX_EN_PIN)
315 #define RX_CC2500_SPI_TX_EN_PIN NONE
318 #if !defined(RX_CC2500_SPI_LNA_EN_PIN)
319 #define RX_CC2500_SPI_LNA_EN_PIN NONE
322 #if !defined(RX_CC2500_SPI_ANT_SEL_PIN)
323 #define RX_CC2500_SPI_ANT_SEL_PIN NONE
330 #if !defined(GYRO_1_SPI_INSTANCE)
331 #define GYRO_1_SPI_INSTANCE NULL
334 #if !defined(GYRO_1_CS_PIN)
335 #define GYRO_1_CS_PIN NONE
338 #if !defined(GYRO_1_EXTI_PIN)
339 #define GYRO_1_EXTI_PIN NONE
342 // F4 and F7 single gyro boards
343 #if defined(USE_MULTI_GYRO) && !defined(GYRO_2_SPI_INSTANCE)
344 #define GYRO_2_SPI_INSTANCE NULL
345 #define GYRO_2_CS_PIN NONE
346 #define GYRO_2_EXTI_PIN NONE
349 #if defined(MPU_ADDRESS)
350 #define GYRO_I2C_ADDRESS MPU_ADDRESS
352 #define GYRO_I2C_ADDRESS 0 // AUTO
355 #ifdef USE_MULTI_GYRO
356 #define MAX_GYRODEV_COUNT 2
357 #define MAX_ACCDEV_COUNT 2
359 #define MAX_GYRODEV_COUNT 1
360 #define MAX_ACCDEV_COUNT 1
365 #if !defined(GYRO_1_ALIGN)
366 #define GYRO_1_ALIGN CW0_DEG
369 #if !defined(GYRO_2_ALIGN)
370 #define GYRO_2_ALIGN CW0_DEG
373 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
374 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
375 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
376 // if a custom alignment is not applied in the target.
379 #ifndef USB_DETECT_PIN
380 #define USB_DETECT_PIN NONE
382 #ifndef USB_MSC_BUTTON_PIN
383 #define USB_MSC_BUTTON_PIN NONE
385 #if !defined(MSC_BUTTON_IPU)
386 #define MSC_BUTTON_IPU true
390 #ifdef USE_TIMER_MGMT
391 #ifndef MAX_TIMER_PINMAP_COUNT
392 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
397 #ifndef SDCARD_DETECT_PIN
398 #define SDCARD_DETECT_PIN NONE
400 #ifdef SDCARD_DETECT_INVERTED
401 #define SDCARD_DETECT_IS_INVERTED 1
403 #define SDCARD_DETECT_IS_INVERTED 0
405 #ifdef USE_SDCARD_SPI
406 #ifndef SDCARD_SPI_INSTANCE
407 #define SDCARD_SPI_INSTANCE NULL
409 #ifndef SDCARD_SPI_CS_PIN
410 #define SDCARD_SPI_CS_PIN NONE
412 #endif // USE_SDCARD_SPI
413 #ifdef USE_SDCARD_SDIO
414 #ifndef SDCARD_SDIO_DMA_OPT
415 #define SDCARD_SDIO_DMA_OPT (DMA_OPT_UNUSED)
418 #define SDIO_DEVICE SDIOINVALID
420 #ifndef SDIO_USE_4BIT
421 #define SDIO_USE_4BIT false
424 #define SDIO_CK_PIN NONE
427 #define SDIO_CMD_PIN NONE
430 #define SDIO_D0_PIN NONE
433 #define SDIO_D1_PIN NONE
436 #define SDIO_D2_PIN NONE
439 #define SDIO_D3_PIN NONE
441 #endif // USE_SDCARD_SDIO
444 #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)
449 #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)
454 #ifndef DEFAULT_MIXER
455 #define DEFAULT_MIXER MIXER_QUADX
458 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
459 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
460 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
462 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
463 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
469 #ifndef MAG_SPI_INSTANCE
470 #define MAG_SPI_INSTANCE NULL
473 #define MAG_CS_PIN NONE
475 #ifndef MAG_I2C_INSTANCE
476 #define MAG_I2C_INSTANCE I2C_DEVICE
481 #define MAG_INT_EXTI NONE
485 #if defined(USE_BARO)
486 #ifndef BARO_SPI_INSTANCE
487 #define BARO_SPI_INSTANCE NULL
490 #define BARO_CS_PIN NONE
492 #ifndef BARO_I2C_INSTANCE
493 #define BARO_I2C_INSTANCE I2C_DEVICE
495 #ifndef BARO_XCLR_PIN
496 #define BARO_XCLR_PIN NONE
501 #if !defined(USE_UNIFIED_TARGET) && !defined(ADC_INSTANCE)
502 #define ADC_INSTANCE ADC1
504 #define ADC1_DMA_OPT 1
508 #if !defined(ADC1_DMA_OPT)
509 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
511 #if !defined(ADC2_DMA_OPT)
512 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
514 #if !defined(ADC3_DMA_OPT)
515 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
517 #if !defined(ADC4_DMA_OPT)
518 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
520 #if !defined(ADC5_DMA_OPT)
521 #define ADC5_DMA_OPT (DMA_OPT_UNUSED)
527 #ifdef USE_SPI_DEVICE_1
528 #ifndef SPI1_TX_DMA_OPT
529 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
531 #ifndef SPI1_RX_DMA_OPT
532 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
535 #ifdef USE_SPI_DEVICE_2
536 #ifndef SPI2_TX_DMA_OPT
537 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
539 #ifndef SPI2_RX_DMA_OPT
540 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
543 #ifdef USE_SPI_DEVICE_3
544 #ifndef SPI3_TX_DMA_OPT
545 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
547 #ifndef SPI3_RX_DMA_OPT
548 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
551 #ifdef USE_SPI_DEVICE_4
552 #ifndef SPI4_TX_DMA_OPT
553 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
555 #ifndef SPI4_RX_DMA_OPT
556 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
562 #ifndef UART1_TX_DMA_OPT
563 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
565 #ifndef UART1_RX_DMA_OPT
566 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
571 #ifndef UART2_TX_DMA_OPT
572 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
574 #ifndef UART2_RX_DMA_OPT
575 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
580 #ifndef UART3_TX_DMA_OPT
581 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
583 #ifndef UART3_RX_DMA_OPT
584 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
589 #ifndef UART4_TX_DMA_OPT
590 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
592 #ifndef UART4_RX_DMA_OPT
593 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
598 #ifndef UART5_TX_DMA_OPT
599 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
601 #ifndef UART5_RX_DMA_OPT
602 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
607 #ifndef UART6_TX_DMA_OPT
608 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
610 #ifndef UART6_RX_DMA_OPT
611 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
616 #ifndef UART7_TX_DMA_OPT
617 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
619 #ifndef UART7_RX_DMA_OPT
620 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
625 #ifndef UART8_TX_DMA_OPT
626 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
628 #ifndef UART8_RX_DMA_OPT
629 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
634 #ifndef UART9_TX_DMA_OPT
635 #define UART9_TX_DMA_OPT (DMA_OPT_UNUSED)
637 #ifndef UART9_RX_DMA_OPT
638 #define UART9_RX_DMA_OPT (DMA_OPT_UNUSED)
643 #ifndef UART10_TX_DMA_OPT
644 #define UART10_TX_DMA_OPT (DMA_OPT_UNUSED)
646 #ifndef UART10_RX_DMA_OPT
647 #define UART10_RX_DMA_OPT (DMA_OPT_UNUSED)
651 #ifndef RTC6705_CS_PIN
652 #define RTC6705_CS_PIN NONE
655 #ifndef RTC6705_POWER_PIN
656 #define RTC6705_POWER_PIN NONE
659 #ifndef RTC6705_SPICLK_PIN
660 #define RTC6705_SPICLK_PIN NONE
663 #ifndef RTC6705_SPI_MOSI_PIN
664 #define RTC6705_SPI_MOSI_PIN NONE
667 #ifndef RTC6705_SPI_INSTANCE
668 #define RTC6705_SPI_INSTANCE NULL
671 #if defined(USE_QUAD_MIXER_ONLY)
672 #define MAX_SUPPORTED_MOTORS 4
673 #define MAX_SUPPORTED_SERVOS 1
675 #ifndef MAX_SUPPORTED_MOTORS
676 #define MAX_SUPPORTED_MOTORS 8
678 #define MAX_SUPPORTED_SERVOS 8
681 #if defined(USE_DSHOT_BITBANG)
682 #if !defined(DSHOT_BITBANG_DEFAULT)
683 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
686 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
687 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
689 #endif // USE_DSHOT_BITBANG