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
227 #ifdef USE_SPI_DEVICE_5
228 #define SPI5_SCK_PIN NONE
229 #define SPI5_MISO_PIN NONE
230 #define SPI5_MOSI_PIN NONE
233 #ifdef USE_SPI_DEVICE_6
234 #define SPI6_SCK_PIN NONE
235 #define SPI6_MISO_PIN NONE
236 #define SPI6_MOSI_PIN NONE
240 // Pin defaults for backward compatibility
243 #define SPI1_SCK_PIN PA5
244 #define SPI1_MISO_PIN PA6
245 #define SPI1_MOSI_PIN PA7
249 #define SPI2_SCK_PIN PB13
250 #define SPI2_MISO_PIN PB14
251 #define SPI2_MOSI_PIN PB15
255 #define SPI3_SCK_PIN PB3
256 #define SPI3_MISO_PIN PB4
257 #define SPI3_MOSI_PIN PB5
261 #define SPI4_SCK_PIN NONE
262 #define SPI4_MISO_PIN NONE
263 #define SPI4_MOSI_PIN NONE
267 #define SPI5_SCK_PIN NONE
268 #define SPI5_MISO_PIN NONE
269 #define SPI5_MOSI_PIN NONE
273 #define SPI6_SCK_PIN NONE
274 #define SPI6_MISO_PIN NONE
275 #define SPI6_MOSI_PIN NONE
280 // Extracted from rx/rx.c and rx/rx.h
282 #define RX_MAPPABLE_CHANNEL_COUNT 8
284 #ifndef RX_SPI_DEFAULT_PROTOCOL
285 #define RX_SPI_DEFAULT_PROTOCOL 0
287 #ifndef SERIALRX_PROVIDER
288 #define SERIALRX_PROVIDER 0
291 #define RX_MIN_USEC 885
292 #define RX_MAX_USEC 2115
293 #define RX_MID_USEC 1500
295 #ifndef SPEKTRUM_BIND_PIN
296 #define SPEKTRUM_BIND_PIN NONE
300 #define BINDPLUG_PIN NONE
304 #if !defined(RX_SPI_INSTANCE)
305 #define RX_SPI_INSTANCE NULL
308 #if !defined(RX_NSS_PIN)
309 #define RX_NSS_PIN NONE
312 #ifndef RX_SPI_LED_PIN
313 #define RX_SPI_LED_PIN NONE
316 #if !defined(RX_SPI_EXTI_PIN)
317 #define RX_SPI_EXTI_PIN NONE
320 #if !defined(RX_SPI_BIND_PIN)
321 #define RX_SPI_BIND_PIN NONE
324 #if defined(USE_RX_CC2500)
325 #if !defined(RX_CC2500_SPI_TX_EN_PIN)
326 #define RX_CC2500_SPI_TX_EN_PIN NONE
329 #if !defined(RX_CC2500_SPI_LNA_EN_PIN)
330 #define RX_CC2500_SPI_LNA_EN_PIN NONE
333 #if !defined(RX_CC2500_SPI_ANT_SEL_PIN)
334 #define RX_CC2500_SPI_ANT_SEL_PIN NONE
338 #if defined(USE_RX_EXPRESSLRS)
339 #if !defined(RX_EXPRESSLRS_SPI_RESET_PIN)
340 #define RX_EXPRESSLRS_SPI_RESET_PIN NONE
343 #if !defined(RX_EXPRESSLRS_SPI_BUSY_PIN)
344 #define RX_EXPRESSLRS_SPI_BUSY_PIN NONE
347 #if !defined(RX_EXPRESSLRS_TIMER_INSTANCE)
348 #define RX_EXPRESSLRS_TIMER_INSTANCE NULL
357 #if !defined(GYRO_1_SPI_INSTANCE)
358 #define GYRO_1_SPI_INSTANCE NULL
361 #if !defined(GYRO_1_CS_PIN)
362 #define GYRO_1_CS_PIN NONE
365 #if !defined(GYRO_1_EXTI_PIN)
366 #define GYRO_1_EXTI_PIN NONE
369 // F4 and F7 single gyro boards
370 #if defined(USE_MULTI_GYRO) && !defined(GYRO_2_SPI_INSTANCE)
371 #define GYRO_2_SPI_INSTANCE NULL
372 #define GYRO_2_CS_PIN NONE
373 #define GYRO_2_EXTI_PIN NONE
376 #if defined(MPU_ADDRESS)
377 #define GYRO_I2C_ADDRESS MPU_ADDRESS
379 #define GYRO_I2C_ADDRESS 0 // AUTO
382 #ifdef USE_MULTI_GYRO
383 #define MAX_GYRODEV_COUNT 2
384 #define MAX_ACCDEV_COUNT 2
386 #define MAX_GYRODEV_COUNT 1
387 #define MAX_ACCDEV_COUNT 1
392 #if !defined(GYRO_1_ALIGN)
393 #define GYRO_1_ALIGN CW0_DEG
396 #if !defined(GYRO_2_ALIGN)
397 #define GYRO_2_ALIGN CW0_DEG
400 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
401 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
402 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
403 // if a custom alignment is not applied in the target.
406 #ifndef USB_DETECT_PIN
407 #define USB_DETECT_PIN NONE
409 #ifndef USB_MSC_BUTTON_PIN
410 #define USB_MSC_BUTTON_PIN NONE
412 #if !defined(MSC_BUTTON_IPU)
413 #define MSC_BUTTON_IPU true
417 #ifdef USE_TIMER_MGMT
418 #ifndef MAX_TIMER_PINMAP_COUNT
419 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
424 #ifndef SDCARD_DETECT_PIN
425 #define SDCARD_DETECT_PIN NONE
427 #ifdef SDCARD_DETECT_INVERTED
428 #define SDCARD_DETECT_IS_INVERTED 1
430 #define SDCARD_DETECT_IS_INVERTED 0
432 #ifdef USE_SDCARD_SPI
433 #ifndef SDCARD_SPI_INSTANCE
434 #define SDCARD_SPI_INSTANCE NULL
436 #ifndef SDCARD_SPI_CS_PIN
437 #define SDCARD_SPI_CS_PIN NONE
439 #endif // USE_SDCARD_SPI
440 #ifdef USE_SDCARD_SDIO
441 #ifndef SDCARD_SDIO_DMA_OPT
442 #define SDCARD_SDIO_DMA_OPT (DMA_OPT_UNUSED)
445 #define SDIO_DEVICE SDIOINVALID
447 #ifndef SDIO_USE_4BIT
448 #define SDIO_USE_4BIT false
451 #define SDIO_CK_PIN NONE
454 #define SDIO_CMD_PIN NONE
457 #define SDIO_D0_PIN NONE
460 #define SDIO_D1_PIN NONE
463 #define SDIO_D2_PIN NONE
466 #define SDIO_D3_PIN NONE
468 #endif // USE_SDCARD_SDIO
471 #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)
476 #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)
481 #ifndef DEFAULT_MIXER
482 #define DEFAULT_MIXER MIXER_QUADX
485 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
486 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
487 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
489 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
490 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
496 #ifndef MAG_SPI_INSTANCE
497 #define MAG_SPI_INSTANCE NULL
500 #define MAG_CS_PIN NONE
502 #ifndef MAG_I2C_INSTANCE
503 #define MAG_I2C_INSTANCE I2C_DEVICE
508 #define MAG_INT_EXTI NONE
512 #if defined(USE_BARO)
513 #ifndef BARO_SPI_INSTANCE
514 #define BARO_SPI_INSTANCE NULL
517 #define BARO_CS_PIN NONE
519 #ifndef BARO_I2C_INSTANCE
520 #define BARO_I2C_INSTANCE I2C_DEVICE
522 #ifndef BARO_XCLR_PIN
523 #define BARO_XCLR_PIN NONE
528 #if !defined(USE_UNIFIED_TARGET) && !defined(ADC_INSTANCE)
529 #define ADC_INSTANCE ADC1
531 #define ADC1_DMA_OPT 1
535 #if !defined(ADC1_DMA_OPT)
536 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
538 #if !defined(ADC2_DMA_OPT)
539 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
541 #if !defined(ADC3_DMA_OPT)
542 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
544 #if !defined(ADC4_DMA_OPT)
545 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
547 #if !defined(ADC5_DMA_OPT)
548 #define ADC5_DMA_OPT (DMA_OPT_UNUSED)
554 #ifdef USE_SPI_DEVICE_1
555 #ifndef SPI1_TX_DMA_OPT
556 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
558 #ifndef SPI1_RX_DMA_OPT
559 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
562 #ifdef USE_SPI_DEVICE_2
563 #ifndef SPI2_TX_DMA_OPT
564 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
566 #ifndef SPI2_RX_DMA_OPT
567 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
570 #ifdef USE_SPI_DEVICE_3
571 #ifndef SPI3_TX_DMA_OPT
572 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
574 #ifndef SPI3_RX_DMA_OPT
575 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
578 #ifdef USE_SPI_DEVICE_4
579 #ifndef SPI4_TX_DMA_OPT
580 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
582 #ifndef SPI4_RX_DMA_OPT
583 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
586 #ifdef USE_SPI_DEVICE_5
587 #ifndef SPI5_TX_DMA_OPT
588 #define SPI5_TX_DMA_OPT (DMA_OPT_UNUSED)
590 #ifndef SPI5_RX_DMA_OPT
591 #define SPI5_RX_DMA_OPT (DMA_OPT_UNUSED)
594 #ifdef USE_SPI_DEVICE_6
595 #ifndef SPI6_TX_DMA_OPT
596 #define SPI6_TX_DMA_OPT (DMA_OPT_UNUSED)
598 #ifndef SPI6_RX_DMA_OPT
599 #define SPI6_RX_DMA_OPT (DMA_OPT_UNUSED)
605 #ifndef UART1_TX_DMA_OPT
606 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
608 #ifndef UART1_RX_DMA_OPT
609 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
614 #ifndef UART2_TX_DMA_OPT
615 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
617 #ifndef UART2_RX_DMA_OPT
618 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
623 #ifndef UART3_TX_DMA_OPT
624 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
626 #ifndef UART3_RX_DMA_OPT
627 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
632 #ifndef UART4_TX_DMA_OPT
633 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
635 #ifndef UART4_RX_DMA_OPT
636 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
641 #ifndef UART5_TX_DMA_OPT
642 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
644 #ifndef UART5_RX_DMA_OPT
645 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
650 #ifndef UART6_TX_DMA_OPT
651 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
653 #ifndef UART6_RX_DMA_OPT
654 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
659 #ifndef UART7_TX_DMA_OPT
660 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
662 #ifndef UART7_RX_DMA_OPT
663 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
668 #ifndef UART8_TX_DMA_OPT
669 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
671 #ifndef UART8_RX_DMA_OPT
672 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
677 #ifndef UART9_TX_DMA_OPT
678 #define UART9_TX_DMA_OPT (DMA_OPT_UNUSED)
680 #ifndef UART9_RX_DMA_OPT
681 #define UART9_RX_DMA_OPT (DMA_OPT_UNUSED)
686 #ifndef UART10_TX_DMA_OPT
687 #define UART10_TX_DMA_OPT (DMA_OPT_UNUSED)
689 #ifndef UART10_RX_DMA_OPT
690 #define UART10_RX_DMA_OPT (DMA_OPT_UNUSED)
694 #ifndef RTC6705_CS_PIN
695 #define RTC6705_CS_PIN NONE
698 #ifndef RTC6705_POWER_PIN
699 #define RTC6705_POWER_PIN NONE
702 #ifndef RTC6705_SPICLK_PIN
703 #define RTC6705_SPICLK_PIN NONE
706 #ifndef RTC6705_SPI_MOSI_PIN
707 #define RTC6705_SPI_MOSI_PIN NONE
710 #ifndef RTC6705_SPI_INSTANCE
711 #define RTC6705_SPI_INSTANCE NULL
714 #if defined(USE_QUAD_MIXER_ONLY)
715 #define MAX_SUPPORTED_MOTORS 4
716 #define MAX_SUPPORTED_SERVOS 1
718 #ifndef MAX_SUPPORTED_MOTORS
719 #define MAX_SUPPORTED_MOTORS 8
721 #define MAX_SUPPORTED_SERVOS 8
724 #if defined(USE_DSHOT_BITBANG)
725 #if !defined(DSHOT_BITBANG_DEFAULT)
726 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
729 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
730 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
732 #endif // USE_DSHOT_BITBANG