FIX: MSP Displayport now has dependency on OSD config (#12106)
[betaflight.git] / src / main / target / common_pre.h
blob11bc11def2e6eace1ee7d26fa23780fd414504a6
1 /*
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)
8 * any later version.
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/>.
21 #pragma once
23 #define USE_PARAMETER_GROUPS
24 // type conversion warnings.
25 // -Wconversion can be turned on to enable the process of eliminating these warnings
26 //#pragma GCC diagnostic warning "-Wconversion"
27 #pragma GCC diagnostic ignored "-Wsign-conversion"
28 // -Wpadded can be turned on to check padding of structs
29 //#pragma GCC diagnostic warning "-Wpadded"
31 #if !defined(CLOUD_BUILD) && !defined(SITL)
32 #define USE_DSHOT
33 #endif
35 #ifdef USE_DSHOT
36 #define USE_DSHOT_BITBANG
37 #define USE_DSHOT_TELEMETRY
38 #define USE_DSHOT_TELEMETRY_STATS
39 #endif
41 #ifdef STM32F4
42 #if defined(STM32F40_41xxx)
43 #define USE_FAST_DATA
44 #endif
46 #define USE_RPM_FILTER
47 #define USE_DYN_IDLE
48 #define USE_DYN_NOTCH_FILTER
49 #define USE_ADC_INTERNAL
50 #define USE_USB_CDC_HID
51 #define USE_USB_MSC
52 #define USE_PERSISTENT_MSC_RTC
53 #define USE_MCO
54 #define USE_DMA_SPEC
55 #define USE_TIMER_MGMT
56 #define USE_PERSISTENT_OBJECTS
57 #define USE_CUSTOM_DEFAULTS_ADDRESS
58 #define USE_LATE_TASK_STATISTICS
60 #if defined(STM32F40_41xxx) || defined(STM32F411xE)
61 #define USE_OVERCLOCK
62 #endif
63 #endif // STM32F4
65 #ifdef STM32F7
66 #define USE_ITCM_RAM
67 #define ITCM_RAM_OPTIMISATION "-O2", "-freorder-blocks-algorithm=simple"
68 #define USE_FAST_DATA
69 #define USE_RPM_FILTER
70 #define USE_DYN_IDLE
71 #define USE_DYN_NOTCH_FILTER
72 #define USE_OVERCLOCK
73 #define USE_ADC_INTERNAL
74 #define USE_USB_CDC_HID
75 #define USE_USB_MSC
76 #define USE_PERSISTENT_MSC_RTC
77 #define USE_MCO
78 #define USE_DMA_SPEC
79 #define USE_TIMER_MGMT
80 #define USE_PERSISTENT_OBJECTS
81 #define USE_CUSTOM_DEFAULTS_ADDRESS
82 #define USE_LATE_TASK_STATISTICS
83 #endif // STM32F7
85 #ifdef STM32H7
87 #ifdef USE_DSHOT
88 #define USE_DSHOT_CACHE_MGMT
89 #endif
91 #define USE_ITCM_RAM
92 #define USE_FAST_DATA
93 #define USE_RPM_FILTER
94 #define USE_DYN_IDLE
95 #define USE_DYN_NOTCH_FILTER
96 #define USE_ADC_INTERNAL
97 #define USE_USB_CDC_HID
98 #define USE_DMA_SPEC
99 #define USE_TIMER_MGMT
100 #define USE_PERSISTENT_OBJECTS
101 #define USE_DMA_RAM
102 #define USE_USB_MSC
103 #define USE_RTC_TIME
104 #define USE_PERSISTENT_MSC_RTC
105 #define USE_LATE_TASK_STATISTICS
106 #endif
108 #ifdef STM32G4
109 #define USE_RPM_FILTER
110 #define USE_DYN_IDLE
111 #define USE_OVERCLOCK
112 #define USE_DYN_NOTCH_FILTER
113 #define USE_ADC_INTERNAL
114 #define USE_USB_MSC
115 #define USE_USB_CDC_HID
116 #define USE_MCO
117 #define USE_DMA_SPEC
118 #define USE_TIMER_MGMT
119 #define USE_LATE_TASK_STATISTICS
120 #endif
122 #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4)
123 #define TASK_GYROPID_DESIRED_PERIOD 125 // 125us = 8kHz
124 #define SCHEDULER_DELAY_LIMIT 10
125 #else
126 #define TASK_GYROPID_DESIRED_PERIOD 1000 // 1000us = 1kHz
127 #define SCHEDULER_DELAY_LIMIT 100
128 #endif
130 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
131 #define DEFAULT_AUX_CHANNEL_COUNT MAX_AUX_CHANNEL_COUNT
132 #else
133 #define DEFAULT_AUX_CHANNEL_COUNT 6
134 #endif
136 // Set the default cpu_overclock to the first level (108MHz) for F411
137 // Helps with looptime stability as the CPU is borderline when running native gyro sampling
138 #if defined(USE_OVERCLOCK) && defined(STM32F411xE)
139 #define DEFAULT_CPU_OVERCLOCK 1
140 #else
141 #define DEFAULT_CPU_OVERCLOCK 0
142 #endif
144 #if defined(STM32H7)
145 // Move ISRs to fast ram to avoid flash latency.
146 #define FAST_IRQ_HANDLER FAST_CODE
147 #else
148 #define FAST_IRQ_HANDLER
149 #endif
152 #ifdef USE_ITCM_RAM
153 #if defined(ITCM_RAM_OPTIMISATION) && !defined(DEBUG)
154 #define FAST_CODE __attribute__((section(".tcm_code"))) __attribute__((optimize(ITCM_RAM_OPTIMISATION)))
155 #else
156 #define FAST_CODE __attribute__((section(".tcm_code")))
157 #endif
158 // Handle case where we'd prefer code to be in ITCM, but it won't fit on the F745
159 #ifdef STM32F745xx
160 #define FAST_CODE_PREF
161 #else
162 #define FAST_CODE_PREF __attribute__((section(".tcm_code")))
163 #endif
164 #define FAST_CODE_NOINLINE NOINLINE
165 #else
166 #define FAST_CODE
167 #define FAST_CODE_PREF
168 #define FAST_CODE_NOINLINE
169 #endif // USE_ITCM_RAM
171 #ifdef USE_CCM_CODE
172 #define CCM_CODE __attribute__((section(".ccm_code")))
173 #else
174 #define CCM_CODE
175 #endif
177 #ifdef USE_FAST_DATA
178 #define FAST_DATA_ZERO_INIT __attribute__ ((section(".fastram_bss"), aligned(4)))
179 #define FAST_DATA __attribute__ ((section(".fastram_data"), aligned(4)))
180 #else
181 #define FAST_DATA_ZERO_INIT
182 #define FAST_DATA
183 #endif // USE_FAST_DATA
185 #if defined(STM32F4) || defined(STM32G4)
186 // F4 can't DMA to/from CCM (core coupled memory) SRAM (where the stack lives)
187 // On G4 there is no specific DMA target memory
188 #define DMA_DATA_ZERO_INIT
189 #define DMA_DATA
190 #define STATIC_DMA_DATA_AUTO static
191 #elif defined (STM32F7)
192 // F7 has no cache coherency issues DMAing to/from DTCM, otherwise buffers must be cache aligned
193 #define DMA_DATA_ZERO_INIT FAST_DATA_ZERO_INIT
194 #define DMA_DATA FAST_DATA
195 #define STATIC_DMA_DATA_AUTO static DMA_DATA
196 #else
197 // DMA to/from any memory
198 #define DMA_DATA_ZERO_INIT __attribute__ ((section(".dmaram_bss"), aligned(32)))
199 #define DMA_DATA __attribute__ ((section(".dmaram_data"), aligned(32)))
200 #define STATIC_DMA_DATA_AUTO static DMA_DATA
201 #endif
203 #if defined(STM32F4) || defined (STM32H7)
204 // Data in RAM which is guaranteed to not be reset on hot reboot
205 #define PERSISTENT __attribute__ ((section(".persistent_data"), aligned(4)))
206 #endif
208 #ifdef USE_DMA_RAM
209 #if defined(STM32H7)
210 #define DMA_RAM __attribute__((section(".DMA_RAM"), aligned(32)))
211 #define DMA_RW_AXI __attribute__((section(".DMA_RW_AXI"), aligned(32)))
212 extern uint8_t _dmaram_start__;
213 extern uint8_t _dmaram_end__;
214 #elif defined(STM32G4)
215 #define DMA_RAM_R __attribute__((section(".DMA_RAM_R")))
216 #define DMA_RAM_W __attribute__((section(".DMA_RAM_W")))
217 #define DMA_RAM_RW __attribute__((section(".DMA_RAM_RW")))
218 #endif
219 #else
220 #define DMA_RAM
221 #define DMA_RW_AXI
222 #define DMA_RAM_R
223 #define DMA_RAM_W
224 #define DMA_RAM_RW
225 #endif
227 #define USE_MOTOR
228 #define USE_DMA
229 #define USE_TIMER
231 #define USE_CLI
232 #define USE_SERIAL_PASSTHROUGH
233 #define USE_GYRO_REGISTER_DUMP // Adds gyroregisters command to cli to dump configured register values
234 #define USE_IMU_CALC
236 #if !defined(CLOUD_BUILD) && !defined(SITL)
238 #define USE_MAG
239 #define USE_BARO
241 #define USE_ACC
242 #define USE_GYRO
244 #define USE_ACC_MPU6500
245 #define USE_GYRO_MPU6500
246 #define USE_ACC_SPI_MPU6000
247 #define USE_GYRO_SPI_MPU6000
248 #define USE_ACC_SPI_MPU6500
249 #define USE_GYRO_SPI_MPU6500
250 #define USE_ACC_SPI_ICM20689
251 #define USE_GYRO_SPI_ICM20689
252 #define USE_ACCGYRO_LSM6DSO
253 #define USE_ACCGYRO_BMI270
254 #define USE_GYRO_SPI_ICM42605
255 #define USE_GYRO_SPI_ICM42688P
256 #define USE_ACC_SPI_ICM42605
257 #define USE_ACC_SPI_ICM42688P
259 #if defined(STM32F405) || defined(STM32F745) || defined(STM32G4) || defined(STM32H7)
260 #define USE_ACC_MPU6050
261 #define USE_GYRO_MPU6050
262 #define USE_ACCGYRO_BMI160
263 #endif
265 #define USE_FLASHFS
266 #define USE_FLASH_TOOLS
267 #define USE_FLASH_M25P16
268 #define USE_FLASH_W25N01G // 1Gb NAND flash support
269 #define USE_FLASH_W25M // Stacked die support
270 #define USE_FLASH_W25M512 // 512Kb (256Kb x 2 stacked) NOR flash support
271 #define USE_FLASH_W25M02G // 2Gb (1Gb x 2 stacked) NAND flash support
272 #define USE_FLASH_W25Q128FV // 16MB Winbond 25Q128
274 #define USE_MAX7456
276 #define USE_RX_SPI
277 #define USE_RX_CC2500
279 #define USE_SDCARD
281 #if defined(STM32F405) || defined(STM32F745) || defined(STM32H7)
282 #define USE_VTX_RTC6705
283 #define USE_VTX_RTC6705_SOFTSPI
285 #define USE_TRANSPONDER
287 #define USE_RANGEFINDER
288 #define USE_RANGEFINDER_HCSR04
289 #define USE_RANGEFINDER_TF
291 #define USE_RX_EXPRESSLRS
292 #define USE_RX_SX1280
293 #define USE_RX_SX127X
294 #endif
296 #define USE_PPM
298 #define USE_BRUSHED_ESC_AUTODETECT // Detect if brushed motors are connected and set defaults appropriately to avoid motors spinning on boot
299 #define USE_PWM
301 #define USE_PINIO
303 #define USE_SERIALRX
304 #define USE_SERIALRX_CRSF // Team Black Sheep Crossfire protocol
305 #define USE_SERIALRX_GHST // ImmersionRC Ghost Protocol
306 #define USE_SERIALRX_IBUS // FlySky and Turnigy receivers
307 #define USE_SERIALRX_SBUS // Frsky and Futaba receivers
308 #define USE_SERIALRX_SPEKTRUM // SRXL, DSM2 and DSMX protocol
309 #define USE_SERIALRX_SUMD // Graupner Hott protocol
310 #define USE_TELEMETRY
311 #define USE_TELEMETRY_FRSKY_HUB
312 #define USE_TELEMETRY_SMARTPORT
313 #define USE_SERIALRX_FPORT // FrSky FPort
314 #define USE_TELEMETRY_CRSF
315 #define USE_TELEMETRY_GHST
316 #define USE_TELEMETRY_SRXL
318 #define USE_SERVOS
320 #define USE_VTX
322 #define USE_TELEMETRY_HOTT
323 #define USE_TELEMETRY_LTM
324 #define USE_SERIALRX_SUMH // Graupner legacy protocol
325 #define USE_SERIALRX_XBUS // JR
326 #define USE_CRSF_CMS_TELEMETRY
327 #define USE_CRSF_LINK_STATISTICS
329 #define USE_SERIALRX_JETIEXBUS
330 #define USE_TELEMETRY_IBUS
331 #define USE_TELEMETRY_IBUS_EXTENDED
332 #define USE_TELEMETRY_JETIEXBUS
333 #define USE_TELEMETRY_MAVLINK
334 #define USE_SERIALRX_SRXL2 // Spektrum SRXL2 protocol
336 #define USE_GPS
337 #define USE_OSD
338 #define USE_LED_STRIP
340 #if TARGET_FLASH_SIZE > 512
341 #define USE_BATTERY_CONTINUE
342 #define USE_DASHBOARD
343 #define USE_EMFAT_AUTORUN
344 #define USE_EMFAT_ICON
345 #define USE_ESCSERIAL_SIMONK
346 #define USE_GPS_PLUS_CODES
347 #define USE_SERIAL_4WAY_SK_BOOTLOADER
348 #endif
350 #endif // !defined(CLOUD_BUILD)
352 #ifndef LED_MAX_STRIP_LENGTH
353 #ifdef USE_LEDSTRIP_64
354 #define LED_MAX_STRIP_LENGTH 64
355 #else
356 #define LED_MAX_STRIP_LENGTH 32
357 #endif
358 #endif // #ifndef LED_MAX_STRIP_LENGTH
360 #if defined(USE_SDCARD)
361 #define USE_SDCARD_SPI
362 #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
363 #define USE_SDCARD_SDIO
364 #endif
365 #endif
367 #if defined(USE_PINIO)
368 #define USE_PINIOBOX
369 #define USE_PIN_PULL_UP_DOWN
370 #endif
372 #if defined(USE_VTX)
373 #define USE_VTX_COMMON
374 #define USE_VTX_CONTROL
375 #define USE_VTX_SMARTAUDIO
376 #define USE_VTX_TRAMP
377 #define USE_VTX_MSP
378 #define USE_VTX_TABLE
379 #endif // USE_VTX
381 #define USE_HUFFMAN
383 #define PID_PROFILE_COUNT 4
384 #define CONTROL_RATE_PROFILE_COUNT 4
386 #define USE_ACRO_TRAINER
387 #define USE_BLACKBOX
388 #define USE_CLI_BATCH
389 #define USE_RESOURCE_MGMT
390 #define USE_RUNAWAY_TAKEOFF // Runaway Takeoff Prevention (anti-taz)
392 #define USE_GYRO_OVERFLOW_CHECK
393 #define USE_YAW_SPIN_RECOVERY
395 #ifdef USE_DSHOT
396 #define USE_DSHOT_DMAR
397 #endif
399 #define USE_MSP_OVER_TELEMETRY
401 #define USE_VIRTUAL_CURRENT_METER
402 #define USE_CAMERA_CONTROL
403 #define USE_ESC_SENSOR
404 #define USE_SERIAL_4WAY_BLHELI_BOOTLOADER
405 #define USE_RCDEVICE
407 #define USE_GYRO_LPF2
408 #define USE_LAUNCH_CONTROL
409 #define USE_DYN_LPF
410 #define USE_D_MIN
412 #define USE_THROTTLE_BOOST
413 #define USE_INTEGRATED_YAW_CONTROL
415 #define USE_ITERM_RELAX
416 #define USE_RC_SMOOTHING_FILTER
417 #define USE_THRUST_LINEARIZATION
418 #define USE_TPA_MODE
420 #ifdef USE_SERIALRX_SPEKTRUM
421 #define USE_SPEKTRUM_BIND
422 #define USE_SPEKTRUM_BIND_PLUG
423 #define USE_SPEKTRUM_REAL_RSSI
424 #define USE_SPEKTRUM_FAKE_RSSI
425 #define USE_SPEKTRUM_RSSI_PERCENT_CONVERSION
426 #define USE_SPEKTRUM_VTX_CONTROL
427 #define USE_SPEKTRUM_VTX_TELEMETRY
428 #define USE_SPEKTRUM_CMS_TELEMETRY
429 #endif // USE_SERIALRX_SPEKTRUM
431 #define USE_BOARD_INFO
432 #define USE_EXTENDED_CMS_MENUS
433 #define USE_RTC_TIME
434 #define USE_ESC_SENSOR_INFO
436 #define USE_RX_MSP
437 #define USE_RX_RSSI_DBM
438 #define USE_RX_RSNR
439 #define USE_RX_LINK_QUALITY_INFO
440 #define USE_RX_MSP_OVERRIDE
441 #define USE_RX_LINK_UPLINK_POWER
443 #define USE_AIRMODE_LPF
444 #define USE_CANVAS
445 #define USE_FRSKYOSD
446 #define USE_GYRO_DLPF_EXPERIMENTAL
447 #define USE_MULTI_GYRO
448 #define USE_SENSOR_NAMES
449 #define USE_UNCOMMON_MIXERS
450 #define USE_SIGNATURE
451 #define USE_ABSOLUTE_CONTROL
452 #define USE_HOTT_TEXTMODE
453 #define USE_LED_STRIP_STATUS_MODE
454 #define USE_VARIO
455 #define USE_ESC_SENSOR_TELEMETRY
456 #define USE_CMS_FAILSAFE_MENU
457 #define USE_CMS_GPS_RESCUE_MENU
458 #define USE_TELEMETRY_SENSORS_DISABLED_DETAILS
459 #define USE_PERSISTENT_STATS
460 #define USE_PROFILE_NAMES
461 #define USE_FEEDFORWARD
462 #define USE_CUSTOM_BOX_NAMES
463 #define USE_BATTERY_VOLTAGE_SAG_COMPENSATION
464 #define USE_SIMPLIFIED_TUNING
465 #define USE_CRSF_V3
466 #define USE_CRAFTNAME_MSGS
468 #ifdef USE_GPS
469 #define USE_GPS_NMEA
470 #define USE_GPS_UBLOX
471 #define USE_GPS_RESCUE
472 #endif // USE_GPS
474 #if defined(USE_OSD) || defined(USE_OSD_HD) || defined(USE_OSD_SD)
476 #ifndef USE_OSD
477 #define USE_OSD
478 #endif
480 #define USE_CMS
481 #define USE_MSP_DISPLAYPORT
482 #define USE_OSD_OVER_MSP_DISPLAYPORT
483 #define USE_OSD_ADJUSTMENTS
484 #define USE_OSD_PROFILES
485 #define USE_OSD_STICK_OVERLAY
486 #endif // defined(USE_OSD) || defined(USE_OSD_HD) || defined(USE_OSD_SD)
488 #if defined(CLOUD_BUILD)
489 // Handle the CRSF co-dependency requirements
490 #if defined(USE_TELEMETRY_CRSF)
492 // if both CRSF and CMS then enable CMS telemtry and link statistics
493 #if defined(USE_CMS)
494 #define USE_CRSF_CMS_TELEMETRY
495 #define USE_CRSF_LINK_STATISTICS
496 #endif // USE_CMS
498 #endif // USE_TELEMETRY_CRSF (CRSF co-dependency requirements).
500 #endif // CLOUD_BUILD