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_EXPRESSLRS)
295 #if !defined(RX_EXPRESSLRS_SPI_RESET_PIN)
296 #define RX_EXPRESSLRS_SPI_RESET_PIN NONE
299 #if !defined(RX_EXPRESSLRS_SPI_BUSY_PIN)
300 #define RX_EXPRESSLRS_SPI_BUSY_PIN NONE
303 #if !defined(RX_EXPRESSLRS_TIMER_INSTANCE)
304 #define RX_EXPRESSLRS_TIMER_INSTANCE NULL
313 #if !defined(GYRO_1_SPI_INSTANCE) && !defined(SIMULATOR_BUILD)
314 #define GYRO_1_SPI_INSTANCE NULL
317 #if !defined(GYRO_1_CS_PIN)
318 #define GYRO_1_CS_PIN NONE
321 #if !defined(GYRO_1_EXTI_PIN)
322 #define GYRO_1_EXTI_PIN NONE
325 // F4 and F7 single gyro boards
326 #if defined(USE_MULTI_GYRO) && !defined(GYRO_2_SPI_INSTANCE)
327 #define GYRO_2_SPI_INSTANCE NULL
328 #define GYRO_2_CS_PIN NONE
329 #define GYRO_2_EXTI_PIN NONE
332 #if defined(MPU_ADDRESS)
333 #define GYRO_I2C_ADDRESS MPU_ADDRESS
335 #define GYRO_I2C_ADDRESS 0 // AUTO
338 #ifdef USE_MULTI_GYRO
339 #define MAX_GYRODEV_COUNT 2
340 #define MAX_ACCDEV_COUNT 2
342 #define MAX_GYRODEV_COUNT 1
343 #define MAX_ACCDEV_COUNT 1
348 #if !defined(GYRO_1_ALIGN)
349 #define GYRO_1_ALIGN CW0_DEG
352 #if !defined(GYRO_2_ALIGN)
353 #define GYRO_2_ALIGN CW0_DEG
356 // Previously there was logic here to default GYRO_1_CUSTOM_ALIGN and GYRO_2_CUSTOM_ALIGN
357 // to CUSTOM_ALIGN_CW0_DEG if they weren't defined in the target. The defaulting logic
358 // has been moved to pg/gyrodev.c to set the custom alignment based on the sensor alignment
359 // if a custom alignment is not applied in the target.
362 #ifndef USB_DETECT_PIN
363 #define USB_DETECT_PIN NONE
365 #ifndef USB_MSC_BUTTON_PIN
366 #define USB_MSC_BUTTON_PIN NONE
368 #if !defined(MSC_BUTTON_IPU)
369 #define MSC_BUTTON_IPU true
373 #ifdef USE_TIMER_MGMT
374 #ifndef MAX_TIMER_PINMAP_COUNT
375 #define MAX_TIMER_PINMAP_COUNT 21 // Largest known for F405RG (OMNINXT)
380 #ifndef SDCARD_DETECT_PIN
381 #define SDCARD_DETECT_PIN NONE
383 #ifdef SDCARD_DETECT_INVERTED
384 #define SDCARD_DETECT_IS_INVERTED 1
386 #define SDCARD_DETECT_IS_INVERTED 0
388 #ifdef USE_SDCARD_SPI
389 #ifndef SDCARD_SPI_INSTANCE
390 #define SDCARD_SPI_INSTANCE NULL
392 #ifndef SDCARD_SPI_CS_PIN
393 #define SDCARD_SPI_CS_PIN NONE
395 #endif // USE_SDCARD_SPI
396 #ifdef USE_SDCARD_SDIO
397 #ifndef SDCARD_SDIO_DMA_OPT
398 #define SDCARD_SDIO_DMA_OPT (DMA_OPT_UNUSED)
401 #define SDIO_DEVICE SDIOINVALID
403 #ifndef SDIO_USE_4BIT
404 #define SDIO_USE_4BIT false
407 #define SDIO_CK_PIN NONE
410 #define SDIO_CMD_PIN NONE
413 #define SDIO_D0_PIN NONE
416 #define SDIO_D1_PIN NONE
419 #define SDIO_D2_PIN NONE
422 #define SDIO_D3_PIN NONE
424 #endif // USE_SDCARD_SDIO
427 #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)
432 #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)
437 #ifndef DEFAULT_MIXER
438 #define DEFAULT_MIXER MIXER_QUADX
441 #if defined(USE_RANGEFINDER) && defined(USE_RANGEFINDER_HCSR04)
442 #ifndef RANGEFINDER_HCSR04_TRIGGER_PIN
443 #define RANGEFINDER_HCSR04_TRIGGER_PIN NONE
445 #ifndef RANGEFINDER_HCSR04_ECHO_PIN
446 #define RANGEFINDER_HCSR04_ECHO_PIN NONE
452 #ifndef MAG_SPI_INSTANCE
453 #define MAG_SPI_INSTANCE NULL
456 #define MAG_CS_PIN NONE
458 #ifndef MAG_I2C_INSTANCE
459 #define MAG_I2C_INSTANCE I2C_DEVICE
464 #define MAG_INT_EXTI NONE
468 #if defined(USE_BARO)
469 #ifndef BARO_SPI_INSTANCE
470 #define BARO_SPI_INSTANCE NULL
473 #define BARO_CS_PIN NONE
475 #ifndef BARO_I2C_INSTANCE
476 #define BARO_I2C_INSTANCE I2C_DEVICE
478 #ifndef BARO_XCLR_PIN
479 #define BARO_XCLR_PIN NONE
485 #if !defined(ADC1_DMA_OPT)
486 #define ADC1_DMA_OPT (DMA_OPT_UNUSED)
488 #if !defined(ADC2_DMA_OPT)
489 #define ADC2_DMA_OPT (DMA_OPT_UNUSED)
491 #if !defined(ADC3_DMA_OPT)
492 #define ADC3_DMA_OPT (DMA_OPT_UNUSED)
494 #if !defined(ADC4_DMA_OPT)
495 #define ADC4_DMA_OPT (DMA_OPT_UNUSED)
497 #if !defined(ADC5_DMA_OPT)
498 #define ADC5_DMA_OPT (DMA_OPT_UNUSED)
504 #ifdef USE_SPI_DEVICE_1
505 #ifndef SPI1_TX_DMA_OPT
506 #define SPI1_TX_DMA_OPT (DMA_OPT_UNUSED)
508 #ifndef SPI1_RX_DMA_OPT
509 #define SPI1_RX_DMA_OPT (DMA_OPT_UNUSED)
512 #ifdef USE_SPI_DEVICE_2
513 #ifndef SPI2_TX_DMA_OPT
514 #define SPI2_TX_DMA_OPT (DMA_OPT_UNUSED)
516 #ifndef SPI2_RX_DMA_OPT
517 #define SPI2_RX_DMA_OPT (DMA_OPT_UNUSED)
520 #ifdef USE_SPI_DEVICE_3
521 #ifndef SPI3_TX_DMA_OPT
522 #define SPI3_TX_DMA_OPT (DMA_OPT_UNUSED)
524 #ifndef SPI3_RX_DMA_OPT
525 #define SPI3_RX_DMA_OPT (DMA_OPT_UNUSED)
528 #ifdef USE_SPI_DEVICE_4
529 #ifndef SPI4_TX_DMA_OPT
530 #define SPI4_TX_DMA_OPT (DMA_OPT_UNUSED)
532 #ifndef SPI4_RX_DMA_OPT
533 #define SPI4_RX_DMA_OPT (DMA_OPT_UNUSED)
536 #ifdef USE_SPI_DEVICE_5
537 #ifndef SPI5_TX_DMA_OPT
538 #define SPI5_TX_DMA_OPT (DMA_OPT_UNUSED)
540 #ifndef SPI5_RX_DMA_OPT
541 #define SPI5_RX_DMA_OPT (DMA_OPT_UNUSED)
544 #ifdef USE_SPI_DEVICE_6
545 #ifndef SPI6_TX_DMA_OPT
546 #define SPI6_TX_DMA_OPT (DMA_OPT_UNUSED)
548 #ifndef SPI6_RX_DMA_OPT
549 #define SPI6_RX_DMA_OPT (DMA_OPT_UNUSED)
555 #ifndef UART1_TX_DMA_OPT
556 #define UART1_TX_DMA_OPT (DMA_OPT_UNUSED)
558 #ifndef UART1_RX_DMA_OPT
559 #define UART1_RX_DMA_OPT (DMA_OPT_UNUSED)
564 #ifndef UART2_TX_DMA_OPT
565 #define UART2_TX_DMA_OPT (DMA_OPT_UNUSED)
567 #ifndef UART2_RX_DMA_OPT
568 #define UART2_RX_DMA_OPT (DMA_OPT_UNUSED)
573 #ifndef UART3_TX_DMA_OPT
574 #define UART3_TX_DMA_OPT (DMA_OPT_UNUSED)
576 #ifndef UART3_RX_DMA_OPT
577 #define UART3_RX_DMA_OPT (DMA_OPT_UNUSED)
582 #ifndef UART4_TX_DMA_OPT
583 #define UART4_TX_DMA_OPT (DMA_OPT_UNUSED)
585 #ifndef UART4_RX_DMA_OPT
586 #define UART4_RX_DMA_OPT (DMA_OPT_UNUSED)
591 #ifndef UART5_TX_DMA_OPT
592 #define UART5_TX_DMA_OPT (DMA_OPT_UNUSED)
594 #ifndef UART5_RX_DMA_OPT
595 #define UART5_RX_DMA_OPT (DMA_OPT_UNUSED)
600 #ifndef UART6_TX_DMA_OPT
601 #define UART6_TX_DMA_OPT (DMA_OPT_UNUSED)
603 #ifndef UART6_RX_DMA_OPT
604 #define UART6_RX_DMA_OPT (DMA_OPT_UNUSED)
609 #ifndef UART7_TX_DMA_OPT
610 #define UART7_TX_DMA_OPT (DMA_OPT_UNUSED)
612 #ifndef UART7_RX_DMA_OPT
613 #define UART7_RX_DMA_OPT (DMA_OPT_UNUSED)
618 #ifndef UART8_TX_DMA_OPT
619 #define UART8_TX_DMA_OPT (DMA_OPT_UNUSED)
621 #ifndef UART8_RX_DMA_OPT
622 #define UART8_RX_DMA_OPT (DMA_OPT_UNUSED)
627 #ifndef UART9_TX_DMA_OPT
628 #define UART9_TX_DMA_OPT (DMA_OPT_UNUSED)
630 #ifndef UART9_RX_DMA_OPT
631 #define UART9_RX_DMA_OPT (DMA_OPT_UNUSED)
636 #ifndef UART10_TX_DMA_OPT
637 #define UART10_TX_DMA_OPT (DMA_OPT_UNUSED)
639 #ifndef UART10_RX_DMA_OPT
640 #define UART10_RX_DMA_OPT (DMA_OPT_UNUSED)
644 #ifndef RTC6705_CS_PIN
645 #define RTC6705_CS_PIN NONE
648 #ifndef RTC6705_POWER_PIN
649 #define RTC6705_POWER_PIN NONE
652 #ifndef RTC6705_SPICLK_PIN
653 #define RTC6705_SPICLK_PIN NONE
656 #ifndef RTC6705_SPI_MOSI_PIN
657 #define RTC6705_SPI_MOSI_PIN NONE
660 #ifndef RTC6705_SPI_INSTANCE
661 #define RTC6705_SPI_INSTANCE NULL
664 #if defined(USE_QUAD_MIXER_ONLY)
665 #define MAX_SUPPORTED_MOTORS 4
666 #define MAX_SUPPORTED_SERVOS 1
668 #ifndef MAX_SUPPORTED_MOTORS
669 #define MAX_SUPPORTED_MOTORS 8
671 #define MAX_SUPPORTED_SERVOS 8
674 #if defined(USE_DSHOT_BITBANG)
675 #if !defined(DSHOT_BITBANG_DEFAULT)
676 #define DSHOT_BITBANG_DEFAULT DSHOT_BITBANG_AUTO
679 #if !defined(DSHOT_BITBANGED_TIMER_DEFAULT)
680 #define DSHOT_BITBANGED_TIMER_DEFAULT DSHOT_BITBANGED_TIMER_AUTO
682 #endif // USE_DSHOT_BITBANG