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
121 #define I2C2_SCL PB10
124 #define I2C2_SDA PB11
133 #define I2C4_SCL PD12
136 #define I2C4_SDA PD13
140 #endif // I2C_FULL_RECONFIGURABILITY
142 #ifndef I2C1_CLOCKSPEED
143 #define I2C1_CLOCKSPEED 800
145 #ifndef I2C2_CLOCKSPEED
146 #define I2C2_CLOCKSPEED 800
148 #ifndef I2C3_CLOCKSPEED
149 #define I2C3_CLOCKSPEED 800
151 #ifndef I2C4_CLOCKSPEED
152 #define I2C4_CLOCKSPEED 800
155 // Default values for internal pullup
157 #if defined(USE_I2C_PULLUP)
158 #define I2C1_PULLUP true
159 #define I2C2_PULLUP true
160 #define I2C3_PULLUP true
161 #define I2C4_PULLUP true
163 #define I2C1_PULLUP false
164 #define I2C2_PULLUP false
165 #define I2C3_PULLUP false
166 #define I2C4_PULLUP false
171 #ifdef SPI_FULL_RECONFIGURABILITY
173 #ifdef USE_SPI_DEVICE_1
174 #define SPI1_SCK_PIN NONE
175 #define SPI1_MISO_PIN NONE
176 #define SPI1_MOSI_PIN NONE
179 #ifdef USE_SPI_DEVICE_2
180 #define SPI2_SCK_PIN NONE
181 #define SPI2_MISO_PIN NONE
182 #define SPI2_MOSI_PIN NONE
185 #ifdef USE_SPI_DEVICE_3
186 #define SPI3_SCK_PIN NONE
187 #define SPI3_MISO_PIN NONE
188 #define SPI3_MOSI_PIN NONE
191 #ifdef USE_SPI_DEVICE_4
192 #define SPI4_SCK_PIN NONE
193 #define SPI4_MISO_PIN NONE
194 #define SPI4_MOSI_PIN NONE
197 #ifdef USE_SPI_DEVICE_5
198 #define SPI5_SCK_PIN NONE
199 #define SPI5_MISO_PIN NONE
200 #define SPI5_MOSI_PIN NONE
203 #ifdef USE_SPI_DEVICE_6
204 #define SPI6_SCK_PIN NONE
205 #define SPI6_MISO_PIN NONE
206 #define SPI6_MOSI_PIN NONE
210 // Pin defaults for backward compatibility
213 #define SPI1_SCK_PIN PA5
214 #define SPI1_MISO_PIN PA6
215 #define SPI1_MOSI_PIN PA7
219 #define SPI2_SCK_PIN PB13
220 #define SPI2_MISO_PIN PB14
221 #define SPI2_MOSI_PIN PB15
225 #define SPI3_SCK_PIN PB3
226 #define SPI3_MISO_PIN PB4
227 #define SPI3_MOSI_PIN PB5
231 #define SPI4_SCK_PIN NONE
232 #define SPI4_MISO_PIN NONE
233 #define SPI4_MOSI_PIN NONE
237 #define SPI5_SCK_PIN NONE
238 #define SPI5_MISO_PIN NONE
239 #define SPI5_MOSI_PIN NONE
243 #define SPI6_SCK_PIN NONE
244 #define SPI6_MISO_PIN NONE
245 #define SPI6_MOSI_PIN NONE
250 // Extracted from rx/rx.c and rx/rx.h
252 #define RX_MAPPABLE_CHANNEL_COUNT 8
254 #ifndef RX_SPI_DEFAULT_PROTOCOL
255 #define RX_SPI_DEFAULT_PROTOCOL 0
257 #ifndef SERIALRX_PROVIDER
258 #define SERIALRX_PROVIDER 0
261 #define RX_MIN_USEC 885
262 #define RX_MAX_USEC 2115
263 #define RX_MID_USEC 1500
265 #ifndef SPEKTRUM_BIND_PIN
266 #define SPEKTRUM_BIND_PIN NONE
270 #define BINDPLUG_PIN NONE
274 #if !defined(RX_SPI_INSTANCE)
275 #define RX_SPI_INSTANCE NULL
278 #if !defined(RX_NSS_PIN)
279 #define RX_NSS_PIN NONE
282 #ifndef RX_SPI_LED_PIN
283 #define RX_SPI_LED_PIN NONE
286 #if !defined(RX_SPI_EXTI_PIN)
287 #define RX_SPI_EXTI_PIN NONE
290 #if !defined(RX_SPI_BIND_PIN)
291 #define RX_SPI_BIND_PIN NONE
294 #if defined(USE_RX_CC2500)
295 #if !defined(RX_CC2500_SPI_TX_EN_PIN)
296 #define RX_CC2500_SPI_TX_EN_PIN NONE
299 #if !defined(RX_CC2500_SPI_LNA_EN_PIN)
300 #define RX_CC2500_SPI_LNA_EN_PIN NONE
303 #if !defined(RX_CC2500_SPI_ANT_SEL_PIN)
304 #define RX_CC2500_SPI_ANT_SEL_PIN NONE
308 #if defined(USE_RX_EXPRESSLRS)
309 #if !defined(RX_EXPRESSLRS_SPI_RESET_PIN)
310 #define RX_EXPRESSLRS_SPI_RESET_PIN NONE
313 #if !defined(RX_EXPRESSLRS_SPI_BUSY_PIN)
314 #define RX_EXPRESSLRS_SPI_BUSY_PIN NONE
317 #if !defined(RX_EXPRESSLRS_TIMER_INSTANCE)
318 #define RX_EXPRESSLRS_TIMER_INSTANCE NULL
327 #if !defined(GYRO_1_SPI_INSTANCE) && !defined(SIMULATOR_BUILD)
328 #define GYRO_1_SPI_INSTANCE NULL
331 #if !defined(GYRO_1_CS_PIN)
332 #define GYRO_1_CS_PIN NONE
335 #if !defined(GYRO_1_EXTI_PIN)
336 #define GYRO_1_EXTI_PIN NONE
339 // F4 and F7 single gyro boards
340 #if defined(USE_MULTI_GYRO) && !defined(GYRO_2_SPI_INSTANCE)
341 #define GYRO_2_SPI_INSTANCE NULL
342 #define GYRO_2_CS_PIN NONE
343 #define GYRO_2_EXTI_PIN NONE
346 #if defined(MPU_ADDRESS)
347 #define GYRO_I2C_ADDRESS MPU_ADDRESS
349 #define GYRO_I2C_ADDRESS 0 // AUTO
352 #ifdef USE_MULTI_GYRO
353 #define MAX_GYRODEV_COUNT 2
354 #define MAX_ACCDEV_COUNT 2
356 #define MAX_GYRODEV_COUNT 1
357 #define MAX_ACCDEV_COUNT 1
362 #if !defined(GYRO_1_ALIGN)
363 #define GYRO_1_ALIGN CW0_DEG
366 #if !defined(GYRO_2_ALIGN)
367 #define GYRO_2_ALIGN CW0_DEG
370 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
371 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
372 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
373 // if a custom alignment is not applied in the target.
376 #ifndef USB_DETECT_PIN
377 #define USB_DETECT_PIN NONE
379 #ifndef USB_MSC_BUTTON_PIN
380 #define USB_MSC_BUTTON_PIN NONE
382 #if !defined(MSC_BUTTON_IPU)
383 #define MSC_BUTTON_IPU true
387 #ifdef USE_TIMER_MGMT
388 #ifndef MAX_TIMER_PINMAP_COUNT
389 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
394 #ifndef SDCARD_DETECT_PIN
395 #define SDCARD_DETECT_PIN NONE
397 #ifdef SDCARD_DETECT_INVERTED
398 #define SDCARD_DETECT_IS_INVERTED 1
400 #define SDCARD_DETECT_IS_INVERTED 0
402 #ifdef USE_SDCARD_SPI
403 #ifndef SDCARD_SPI_INSTANCE
404 #define SDCARD_SPI_INSTANCE NULL
406 #ifndef SDCARD_SPI_CS_PIN
407 #define SDCARD_SPI_CS_PIN NONE
409 #endif // USE_SDCARD_SPI
410 #ifdef USE_SDCARD_SDIO
411 #ifndef SDCARD_SDIO_DMA_OPT
412 #define SDCARD_SDIO_DMA_OPT (DMA_OPT_UNUSED)
415 #define SDIO_DEVICE SDIOINVALID
417 #ifndef SDIO_USE_4BIT
418 #define SDIO_USE_4BIT false
421 #define SDIO_CK_PIN NONE
424 #define SDIO_CMD_PIN NONE
427 #define SDIO_D0_PIN NONE
430 #define SDIO_D1_PIN NONE
433 #define SDIO_D2_PIN NONE
436 #define SDIO_D3_PIN NONE
438 #endif // USE_SDCARD_SDIO
441 #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)
446 #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)
451 #ifndef DEFAULT_MIXER
452 #define DEFAULT_MIXER MIXER_QUADX
455 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
456 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
457 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
459 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
460 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
466 #ifndef MAG_SPI_INSTANCE
467 #define MAG_SPI_INSTANCE NULL
470 #define MAG_CS_PIN NONE
472 #ifndef MAG_I2C_INSTANCE
473 #define MAG_I2C_INSTANCE I2C_DEVICE
478 #define MAG_INT_EXTI NONE
482 #if defined(USE_BARO)
483 #ifndef BARO_SPI_INSTANCE
484 #define BARO_SPI_INSTANCE NULL
487 #define BARO_CS_PIN NONE
489 #ifndef BARO_I2C_INSTANCE
490 #define BARO_I2C_INSTANCE I2C_DEVICE
492 #ifndef BARO_XCLR_PIN
493 #define BARO_XCLR_PIN NONE
498 #if !defined(USE_UNIFIED_TARGET) && !defined(ADC_INSTANCE)
499 #define ADC_INSTANCE ADC1
501 #define ADC1_DMA_OPT 1
505 #if !defined(ADC1_DMA_OPT)
506 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
508 #if !defined(ADC2_DMA_OPT)
509 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
511 #if !defined(ADC3_DMA_OPT)
512 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
514 #if !defined(ADC4_DMA_OPT)
515 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
517 #if !defined(ADC5_DMA_OPT)
518 #define ADC5_DMA_OPT (DMA_OPT_UNUSED)
524 #ifdef USE_SPI_DEVICE_1
525 #ifndef SPI1_TX_DMA_OPT
526 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
528 #ifndef SPI1_RX_DMA_OPT
529 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
532 #ifdef USE_SPI_DEVICE_2
533 #ifndef SPI2_TX_DMA_OPT
534 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
536 #ifndef SPI2_RX_DMA_OPT
537 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
540 #ifdef USE_SPI_DEVICE_3
541 #ifndef SPI3_TX_DMA_OPT
542 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
544 #ifndef SPI3_RX_DMA_OPT
545 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
548 #ifdef USE_SPI_DEVICE_4
549 #ifndef SPI4_TX_DMA_OPT
550 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
552 #ifndef SPI4_RX_DMA_OPT
553 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
556 #ifdef USE_SPI_DEVICE_5
557 #ifndef SPI5_TX_DMA_OPT
558 #define SPI5_TX_DMA_OPT (DMA_OPT_UNUSED)
560 #ifndef SPI5_RX_DMA_OPT
561 #define SPI5_RX_DMA_OPT (DMA_OPT_UNUSED)
564 #ifdef USE_SPI_DEVICE_6
565 #ifndef SPI6_TX_DMA_OPT
566 #define SPI6_TX_DMA_OPT (DMA_OPT_UNUSED)
568 #ifndef SPI6_RX_DMA_OPT
569 #define SPI6_RX_DMA_OPT (DMA_OPT_UNUSED)
575 #ifndef UART1_TX_DMA_OPT
576 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
578 #ifndef UART1_RX_DMA_OPT
579 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
584 #ifndef UART2_TX_DMA_OPT
585 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
587 #ifndef UART2_RX_DMA_OPT
588 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
593 #ifndef UART3_TX_DMA_OPT
594 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
596 #ifndef UART3_RX_DMA_OPT
597 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
602 #ifndef UART4_TX_DMA_OPT
603 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
605 #ifndef UART4_RX_DMA_OPT
606 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
611 #ifndef UART5_TX_DMA_OPT
612 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
614 #ifndef UART5_RX_DMA_OPT
615 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
620 #ifndef UART6_TX_DMA_OPT
621 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
623 #ifndef UART6_RX_DMA_OPT
624 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
629 #ifndef UART7_TX_DMA_OPT
630 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
632 #ifndef UART7_RX_DMA_OPT
633 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
638 #ifndef UART8_TX_DMA_OPT
639 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
641 #ifndef UART8_RX_DMA_OPT
642 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
647 #ifndef UART9_TX_DMA_OPT
648 #define UART9_TX_DMA_OPT (DMA_OPT_UNUSED)
650 #ifndef UART9_RX_DMA_OPT
651 #define UART9_RX_DMA_OPT (DMA_OPT_UNUSED)
656 #ifndef UART10_TX_DMA_OPT
657 #define UART10_TX_DMA_OPT (DMA_OPT_UNUSED)
659 #ifndef UART10_RX_DMA_OPT
660 #define UART10_RX_DMA_OPT (DMA_OPT_UNUSED)
664 #ifndef RTC6705_CS_PIN
665 #define RTC6705_CS_PIN NONE
668 #ifndef RTC6705_POWER_PIN
669 #define RTC6705_POWER_PIN NONE
672 #ifndef RTC6705_SPICLK_PIN
673 #define RTC6705_SPICLK_PIN NONE
676 #ifndef RTC6705_SPI_MOSI_PIN
677 #define RTC6705_SPI_MOSI_PIN NONE
680 #ifndef RTC6705_SPI_INSTANCE
681 #define RTC6705_SPI_INSTANCE NULL
684 #if defined(USE_QUAD_MIXER_ONLY)
685 #define MAX_SUPPORTED_MOTORS 4
686 #define MAX_SUPPORTED_SERVOS 1
688 #ifndef MAX_SUPPORTED_MOTORS
689 #define MAX_SUPPORTED_MOTORS 8
691 #define MAX_SUPPORTED_SERVOS 8
694 #if defined(USE_DSHOT_BITBANG)
695 #if !defined(DSHOT_BITBANG_DEFAULT)
696 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
699 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
700 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
702 #endif // USE_DSHOT_BITBANG