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/>.
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"
32 #if defined(STM32F40_41xxx)
36 #define USE_DSHOT_BITBANG
37 #define USE_DSHOT_TELEMETRY
38 #define USE_DSHOT_TELEMETRY_STATS
39 #define USE_RPM_FILTER
41 #define USE_DYN_NOTCH_FILTER
42 #define USE_ADC_INTERNAL
43 #define USE_USB_CDC_HID
45 #define USE_PERSISTENT_MSC_RTC
48 #define USE_TIMER_MGMT
49 #define USE_PERSISTENT_OBJECTS
50 #define USE_CUSTOM_DEFAULTS_ADDRESS
51 #define USE_LATE_TASK_STATISTICS
53 #if defined(STM32F40_41xxx) || defined(STM32F411xE)
60 #define ITCM_RAM_OPTIMISATION "-O2", "-freorder-blocks-algorithm=simple"
63 #define USE_DSHOT_BITBANG
64 #define USE_DSHOT_TELEMETRY
65 #define USE_DSHOT_TELEMETRY_STATS
66 #define USE_RPM_FILTER
68 #define USE_DYN_NOTCH_FILTER
70 #define USE_ADC_INTERNAL
71 #define USE_USB_CDC_HID
73 #define USE_PERSISTENT_MSC_RTC
76 #define USE_TIMER_MGMT
77 #define USE_PERSISTENT_OBJECTS
78 #define USE_CUSTOM_DEFAULTS_ADDRESS
79 #define USE_LATE_TASK_STATISTICS
86 #define USE_DSHOT_BITBANG
87 #define USE_DSHOT_TELEMETRY
88 #define USE_DSHOT_TELEMETRY_STATS
89 #define USE_RPM_FILTER
91 #define USE_DYN_NOTCH_FILTER
92 #define USE_ADC_INTERNAL
93 #define USE_USB_CDC_HID
95 #define USE_TIMER_MGMT
96 #define USE_PERSISTENT_OBJECTS
100 #define USE_PERSISTENT_MSC_RTC
101 #define USE_DSHOT_CACHE_MGMT
102 #define USE_LATE_TASK_STATISTICS
108 #define USE_DSHOT_BITBANG
109 #define USE_DSHOT_TELEMETRY
110 #define USE_DSHOT_TELEMETRY_STATS
111 #define USE_RPM_FILTER
113 #define USE_OVERCLOCK
114 #define USE_DYN_NOTCH_FILTER
115 #define USE_ADC_INTERNAL
117 #define USE_USB_CDC_HID
120 #define USE_TIMER_MGMT
121 #define USE_LATE_TASK_STATISTICS
124 #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4)
125 #define TASK_GYROPID_DESIRED_PERIOD 125 // 125us = 8kHz
126 #define SCHEDULER_DELAY_LIMIT 10
128 #define TASK_GYROPID_DESIRED_PERIOD 1000 // 1000us = 1kHz
129 #define SCHEDULER_DELAY_LIMIT 100
132 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
133 #define DEFAULT_AUX_CHANNEL_COUNT MAX_AUX_CHANNEL_COUNT
135 #define DEFAULT_AUX_CHANNEL_COUNT 6
138 // Set the default cpu_overclock to the first level (108MHz) for F411
139 // Helps with looptime stability as the CPU is borderline when running native gyro sampling
140 #if defined(USE_OVERCLOCK) && defined(STM32F411xE)
141 #define DEFAULT_CPU_OVERCLOCK 1
143 #define DEFAULT_CPU_OVERCLOCK 0
147 // Move ISRs to fast ram to avoid flash latency.
148 #define FAST_IRQ_HANDLER FAST_CODE
150 #define FAST_IRQ_HANDLER
155 #if defined(ITCM_RAM_OPTIMISATION) && !defined(DEBUG)
156 #define FAST_CODE __attribute__((section(".tcm_code"))) __attribute__((optimize(ITCM_RAM_OPTIMISATION)))
158 #define FAST_CODE __attribute__((section(".tcm_code")))
160 // Handle case where we'd prefer code to be in ITCM, but it won't fit on the F745
162 #define FAST_CODE_PREF
164 #define FAST_CODE_PREF __attribute__((section(".tcm_code")))
166 #define FAST_CODE_NOINLINE NOINLINE
169 #define FAST_CODE_PREF
170 #define FAST_CODE_NOINLINE
171 #endif // USE_ITCM_RAM
174 #define CCM_CODE __attribute__((section(".ccm_code")))
180 #define FAST_DATA_ZERO_INIT __attribute__ ((section(".fastram_bss"), aligned(4)))
181 #define FAST_DATA __attribute__ ((section(".fastram_data"), aligned(4)))
183 #define FAST_DATA_ZERO_INIT
185 #endif // USE_FAST_DATA
187 #if defined(STM32F4) || defined(STM32G4)
188 // F4 can't DMA to/from CCM (core coupled memory) SRAM (where the stack lives)
189 // On G4 there is no specific DMA target memory
190 #define DMA_DATA_ZERO_INIT
192 #define STATIC_DMA_DATA_AUTO static
193 #elif defined (STM32F7)
194 // F7 has no cache coherency issues DMAing to/from DTCM, otherwise buffers must be cache aligned
195 #define DMA_DATA_ZERO_INIT FAST_DATA_ZERO_INIT
196 #define DMA_DATA FAST_DATA
197 #define STATIC_DMA_DATA_AUTO static DMA_DATA
199 // DMA to/from any memory
200 #define DMA_DATA_ZERO_INIT __attribute__ ((section(".dmaram_bss"), aligned(32)))
201 #define DMA_DATA __attribute__ ((section(".dmaram_data"), aligned(32)))
202 #define STATIC_DMA_DATA_AUTO static DMA_DATA
205 #if defined(STM32F4) || defined (STM32H7)
206 // Data in RAM which is guaranteed to not be reset on hot reboot
207 #define PERSISTENT __attribute__ ((section(".persistent_data"), aligned(4)))
212 #define DMA_RAM __attribute__((section(".DMA_RAM"), aligned(32)))
213 #define DMA_RW_AXI __attribute__((section(".DMA_RW_AXI"), aligned(32)))
214 extern uint8_t _dmaram_start__
;
215 extern uint8_t _dmaram_end__
;
216 #elif defined(STM32G4)
217 #define DMA_RAM_R __attribute__((section(".DMA_RAM_R")))
218 #define DMA_RAM_W __attribute__((section(".DMA_RAM_W")))
219 #define DMA_RAM_RW __attribute__((section(".DMA_RAM_RW")))
229 #define USE_BRUSHED_ESC_AUTODETECT // Detect if brushed motors are connected and set defaults appropriately to avoid motors spinning on boot
232 #define USE_PWM_OUTPUT
237 #define USE_SERIAL_PASSTHROUGH
238 #define USE_GYRO_REGISTER_DUMP // Adds gyroregisters command to cli to dump configured register values
241 #define USE_SERIAL_RX
242 #define USE_SERIALRX_CRSF // Team Black Sheep Crossfire protocol
243 #define USE_SERIALRX_GHST // ImmersionRC Ghost Protocol
244 #define USE_SERIALRX_IBUS // FlySky and Turnigy receivers
245 #define USE_SERIALRX_SBUS // Frsky and Futaba receivers
246 #define USE_SERIALRX_SPEKTRUM // SRXL, DSM2 and DSMX protocol
247 #define USE_SERIALRX_SUMD // Graupner Hott protocol
249 #if (TARGET_FLASH_SIZE > 128)
250 #define PID_PROFILE_COUNT 3
251 #define CONTROL_RATE_PROFILE_COUNT 6
253 #define PID_PROFILE_COUNT 2
254 #define CONTROL_RATE_PROFILE_COUNT 3
257 #if (TARGET_FLASH_SIZE > 64)
258 #define USE_ACRO_TRAINER
260 #define USE_CLI_BATCH
261 #define USE_RESOURCE_MGMT
262 #define USE_RUNAWAY_TAKEOFF // Runaway Takeoff Prevention (anti-taz)
264 #define USE_TELEMETRY
265 #define USE_TELEMETRY_FRSKY_HUB
266 #define USE_TELEMETRY_SMARTPORT
269 #if (TARGET_FLASH_SIZE > 128)
270 #define USE_GYRO_OVERFLOW_CHECK
271 #define USE_YAW_SPIN_RECOVERY
272 #define USE_DSHOT_DMAR
273 #define USE_SERIALRX_FPORT // FrSky FPort
274 #define USE_TELEMETRY_CRSF
275 #define USE_TELEMETRY_GHST
276 #define USE_TELEMETRY_SRXL
278 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 12))
280 #define USE_MSP_DISPLAYPORT
281 #define USE_MSP_OVER_TELEMETRY
282 #define USE_OSD_OVER_MSP_DISPLAYPORT
283 #define USE_LED_STRIP
286 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 11))
287 #define USE_VTX_COMMON
288 #define USE_VTX_CONTROL
289 #define USE_VTX_SMARTAUDIO
290 #define USE_VTX_TRAMP
293 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 10))
294 #define USE_VIRTUAL_CURRENT_METER
295 #define USE_CAMERA_CONTROL
296 #define USE_ESC_SENSOR
297 #define USE_SERIAL_4WAY_BLHELI_BOOTLOADER
301 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 9))
302 #define USE_GYRO_LPF2
305 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 8))
306 #define USE_LAUNCH_CONTROL
311 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 7))
312 #define USE_THROTTLE_BOOST
313 #define USE_INTEGRATED_YAW_CONTROL
316 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 6))
317 #define USE_ITERM_RELAX
318 #define USE_RC_SMOOTHING_FILTER
319 #define USE_THRUST_LINEARIZATION
323 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 5))
327 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 4))
333 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 3))
334 #ifdef USE_SERIALRX_SPEKTRUM
335 #define USE_SPEKTRUM_BIND
336 #define USE_SPEKTRUM_BIND_PLUG
337 #define USE_SPEKTRUM_REAL_RSSI
338 #define USE_SPEKTRUM_FAKE_RSSI
339 #define USE_SPEKTRUM_RSSI_PERCENT_CONVERSION
340 #define USE_SPEKTRUM_VTX_CONTROL
341 #define USE_SPEKTRUM_VTX_TELEMETRY
342 #define USE_SPEKTRUM_CMS_TELEMETRY
343 #define USE_PIN_PULL_UP_DOWN
347 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 2))
348 #define USE_TELEMETRY_HOTT
349 #define USE_TELEMETRY_LTM
350 #define USE_SERIALRX_SUMH // Graupner legacy protocol
351 #define USE_SERIALRX_XBUS // JR
354 #if ((TARGET_FLASH_SIZE > 256 && !defined(FEATURE_CUT_LEVEL)) || (FEATURE_CUT_LEVEL < 1))
355 #define USE_BOARD_INFO
356 #define USE_EXTENDED_CMS_MENUS
359 #define USE_ESC_SENSOR_INFO
360 #define USE_CRSF_CMS_TELEMETRY
361 #define USE_CRSF_LINK_STATISTICS
362 #define USE_RX_RSSI_DBM
365 #endif // TARGET_FLASH_SIZE > 128
367 #if (TARGET_FLASH_SIZE > 256)
368 #define USE_AIRMODE_LPF
373 #define USE_GPS_UBLOX
374 #define USE_GPS_RESCUE
375 #define USE_GYRO_DLPF_EXPERIMENTAL
377 #define USE_OSD_OVER_MSP_DISPLAYPORT
378 #define USE_MULTI_GYRO
379 #define USE_OSD_ADJUSTMENTS
380 #define USE_SENSOR_NAMES
381 #define USE_SERIALRX_JETIEXBUS
382 #define USE_TELEMETRY_IBUS
383 #define USE_TELEMETRY_IBUS_EXTENDED
384 #define USE_TELEMETRY_JETIEXBUS
385 #define USE_TELEMETRY_MAVLINK
386 #define USE_UNCOMMON_MIXERS
387 #define USE_SIGNATURE
388 #define USE_ABSOLUTE_CONTROL
389 #define USE_HOTT_TEXTMODE
390 #define USE_LED_STRIP_STATUS_MODE
392 #define USE_RX_LINK_QUALITY_INFO
393 #define USE_ESC_SENSOR_TELEMETRY
394 #define USE_OSD_PROFILES
395 #define USE_OSD_STICK_OVERLAY
396 #define USE_CMS_FAILSAFE_MENU
397 #define USE_CMS_GPS_RESCUE_MENU
398 #define USE_TELEMETRY_SENSORS_DISABLED_DETAILS
399 #define USE_VTX_TABLE
400 #define USE_PERSISTENT_STATS
401 #define USE_PROFILE_NAMES
402 #define USE_SERIALRX_SRXL2 // Spektrum SRXL2 protocol
403 #define USE_FEEDFORWARD
404 #define USE_CUSTOM_BOX_NAMES
405 #define USE_BATTERY_VOLTAGE_SAG_COMPENSATION
406 #define USE_RX_MSP_OVERRIDE
407 #define USE_SIMPLIFIED_TUNING
408 #define USE_RX_LINK_UPLINK_POWER
410 #define USE_CRAFTNAME_MSGS
413 #if (TARGET_FLASH_SIZE > 512)
414 #define USE_ESCSERIAL_SIMONK
415 #define USE_SERIAL_4WAY_SK_BOOTLOADER
416 #define USE_DASHBOARD
417 #define USE_EMFAT_AUTORUN
418 #define USE_EMFAT_ICON
419 #define USE_GPS_PLUS_CODES