2 #if !defined TARGET_NATIVE
8 /// General Features ///
9 #define LED_MAX_BRIGHTNESS 50 //0..255 for max led brightness
11 /////////////////////////
13 #define WORD_ALIGNED_ATTR __attribute__((aligned(4)))
14 #define WORD_PADDED(size) (((size)+3) & ~3)
17 /* ICACHE_RAM_ATTR1 is always linked into RAM */
18 #define ICACHE_RAM_ATTR1 __section(".ram_code")
19 /* ICACHE_RAM_ATTR2 is linked into RAM only if enough space */
21 #define ICACHE_RAM_ATTR2
23 #define ICACHE_RAM_ATTR2 __section(".ram_code")
25 #define ICACHE_RAM_ATTR //nothing//
27 #undef ICACHE_RAM_ATTR //fix to allow both esp32 and esp8266 to use ICACHE_RAM_ATTR for mapping to IRAM
28 #define ICACHE_RAM_ATTR IRAM_ATTR
31 #if defined(TARGET_NATIVE)
42 * define features based on pins before defining pins as UNDEF_PIN
44 #if defined(GPIO_PIN_FAN_EN)
47 #if defined(USE_OLED_I2C) || defined(USE_OLED_SPI) || defined(USE_OLED_SPI_SMALL) || defined(HAS_TFT_SCREEN)
50 #if defined(GPIO_PIN_SPI_VTX_NSS)
51 #if !defined(HAS_VTX_SPI)
54 #define OPT_HAS_VTX_SPI true
57 #define OPT_HAS_VTX_SPI false
60 #ifndef USE_TX_BACKPACK
61 #define OPT_USE_TX_BACKPACK false
62 #elif !defined(OPT_USE_TX_BACKPACK)
63 #define OPT_USE_TX_BACKPACK true
67 #define OPT_HAS_THERMAL false
68 #define OPT_HAS_THERMAL_LM75A false
69 #elif !defined(OPT_HAS_THERMAL)
70 #define OPT_HAS_THERMAL true
74 #define OPT_HAS_GSENSOR false
75 #elif !defined(OPT_HAS_GSENSOR)
76 #define OPT_HAS_GSENSOR true
79 #if defined(GPIO_PIN_SDA) && defined(GPIO_PIN_SCL)
82 #define GPIO_PIN_SDA UNDEF_PIN
83 #define GPIO_PIN_SCL UNDEF_PIN
86 #ifndef GPIO_PIN_BUFFER_OE
87 #define GPIO_PIN_BUFFER_OE UNDEF_PIN
90 #define GPIO_PIN_SCK UNDEF_PIN
92 #ifndef GPIO_PIN_NSS_2
93 #define GPIO_PIN_NSS_2 UNDEF_PIN
96 #define GPIO_PIN_RST UNDEF_PIN
98 #ifndef GPIO_PIN_RST_2
99 #define GPIO_PIN_RST_2 UNDEF_PIN
101 #ifndef GPIO_PIN_BUSY
102 #define GPIO_PIN_BUSY UNDEF_PIN
104 #ifndef GPIO_PIN_BUSY_2
105 #define GPIO_PIN_BUSY_2 UNDEF_PIN
107 #ifndef GPIO_PIN_DIO0
108 #define GPIO_PIN_DIO0 UNDEF_PIN
110 #ifndef GPIO_PIN_DIO0_2
111 #define GPIO_PIN_DIO0_2 UNDEF_PIN
113 #ifndef GPIO_PIN_DIO1
114 #define GPIO_PIN_DIO1 UNDEF_PIN
116 #ifndef GPIO_PIN_DIO1_2
117 #define GPIO_PIN_DIO1_2 UNDEF_PIN
119 #ifndef GPIO_PIN_DIO2
120 #define GPIO_PIN_DIO2 UNDEF_PIN
122 #ifndef GPIO_PIN_PA_ENABLE
123 #define GPIO_PIN_PA_ENABLE UNDEF_PIN
125 #ifndef GPIO_PIN_RX_ENABLE
126 #define GPIO_PIN_RX_ENABLE UNDEF_PIN
128 #ifndef GPIO_PIN_RX_ENABLE_2
129 #define GPIO_PIN_RX_ENABLE_2 UNDEF_PIN
131 #ifndef GPIO_PIN_TX_ENABLE
132 #define GPIO_PIN_TX_ENABLE UNDEF_PIN
134 #ifndef GPIO_PIN_TX_ENABLE_2
135 #define GPIO_PIN_TX_ENABLE_2 UNDEF_PIN
137 #ifndef GPIO_PIN_ANT_CTRL
138 #define GPIO_PIN_ANT_CTRL UNDEF_PIN
140 #ifndef GPIO_PIN_ANT_CTRL_COMPL
141 #define GPIO_PIN_ANT_CTRL_COMPL UNDEF_PIN
143 #ifndef GPIO_PIN_RFamp_APC1
144 #define GPIO_PIN_RFamp_APC1 UNDEF_PIN
146 #ifndef GPIO_PIN_RFamp_APC2
147 #define GPIO_PIN_RFamp_APC2 UNDEF_PIN
149 #ifndef POWER_OUTPUT_FIXED
150 #define POWER_OUTPUT_FIXED -99
152 #ifndef GPIO_PIN_FAN_EN
153 #define GPIO_PIN_FAN_EN UNDEF_PIN
155 #ifndef GPIO_PIN_FAN_PWM
156 #define GPIO_PIN_FAN_PWM UNDEF_PIN
158 #ifndef GPIO_PIN_FAN_TACHO
159 #define GPIO_PIN_FAN_TACHO UNDEF_PIN
161 #ifndef GPIO_PIN_OLED_MOSI
162 #define GPIO_PIN_OLED_MOSI UNDEF_PIN
164 #ifndef GPIO_PIN_OLED_CS
165 #define GPIO_PIN_OLED_CS UNDEF_PIN
167 #ifndef GPIO_PIN_OLED_DC
168 #define GPIO_PIN_OLED_DC UNDEF_PIN
172 #ifndef GPIO_PIN_FIVE_WAY_INPUT1
173 #define GPIO_PIN_FIVE_WAY_INPUT1 UNDEF_PIN
175 #ifndef GPIO_PIN_FIVE_WAY_INPUT2
176 #define GPIO_PIN_FIVE_WAY_INPUT2 UNDEF_PIN
178 #ifndef GPIO_PIN_FIVE_WAY_INPUT3
179 #define GPIO_PIN_FIVE_WAY_INPUT3 UNDEF_PIN
183 #ifndef GPIO_PIN_OLED_SCK
184 #define GPIO_PIN_OLED_SCK GPIO_PIN_SCL
186 #ifndef GPIO_PIN_OLED_SDA
187 #define GPIO_PIN_OLED_SDA GPIO_PIN_SDA
190 #if !defined(BACKPACK_LOGGING_BAUD)
191 #define BACKPACK_LOGGING_BAUD 460800
193 #ifndef GPIO_PIN_BACKPACK_BOOT
194 #define GPIO_PIN_BACKPACK_BOOT UNDEF_PIN
197 #ifndef GPIO_PIN_SPI_VTX_NSS
198 #define GPIO_PIN_SPI_VTX_NSS UNDEF_PIN
202 #if defined(TARGET_TX)
203 #if defined(PLATFORM_ESP32)
204 #ifndef GPIO_PIN_DEBUG_RX
205 #define GPIO_PIN_DEBUG_RX 3
207 #ifndef GPIO_PIN_DEBUG_TX
208 #define GPIO_PIN_DEBUG_TX 1
210 #elif defined(PLATFORM_ESP8266)
211 #ifndef GPIO_PIN_DEBUG_RX
212 #define GPIO_PIN_DEBUG_RX UNDEF_PIN
214 #ifndef GPIO_PIN_DEBUG_TX
215 #define GPIO_PIN_DEBUG_TX UNDEF_PIN
218 #if !defined(TARGET_UNIFIED_TX)
219 #if defined(DEBUG_LOG) || defined(DEBUG_LOG_VERBOSE) || defined(USE_TX_BACKPACK)
220 #if GPIO_PIN_RCSIGNAL_TX == GPIO_PIN_DEBUG_TX || GPIO_PIN_RCSIGNAL_TX == GPIO_PIN_DEBUG_RX
221 #error "Cannot debug out the RC signal port!"
223 #if !defined(GPIO_PIN_DEBUG_RX) || !defined(GPIO_PIN_DEBUG_TX) || GPIO_PIN_DEBUG_RX == UNDEF_PIN || GPIO_PIN_DEBUG_TX == UNDEF_PIN
224 #error "When using DEBUG_LOG, DEBUG_LOG_VERBOSE or USE_TX_BACKPACK you must define both GPIO_PIN_DEBUG_RX and GPIO_PIN_DEBUG_TX"
229 #ifndef GPIO_PIN_RCSIGNAL_TX_SBUS
230 #define GPIO_PIN_RCSIGNAL_TX_SBUS UNDEF_PIN
232 #ifndef GPIO_PIN_RCSIGNAL_RX_SBUS
233 #define GPIO_PIN_RCSIGNAL_RX_SBUS UNDEF_PIN
235 #if defined(PLATFORM_ESP8266)
236 #ifndef GPIO_PIN_DEBUG_RX
237 #define GPIO_PIN_DEBUG_RX 3
239 #ifndef GPIO_PIN_DEBUG_TX
240 #define GPIO_PIN_DEBUG_TX 1
245 // Using these DEBUG_* imply that no SerialIO will be used so the output is readable
246 #if !defined(DEBUG_CRSF_NO_OUTPUT) && defined(TARGET_RX) && (defined(DEBUG_RCVR_LINKSTATS) || defined(DEBUG_RX_SCOREBOARD) || defined(DEBUG_RCVR_SIGNAL_STATS))
247 #define DEBUG_CRSF_NO_OUTPUT
250 #if defined(DEBUG_CRSF_NO_OUTPUT)
251 #define OPT_CRSF_RCVR_NO_SERIAL true
252 #elif defined(TARGET_UNIFIED_RX)
253 extern bool pwmSerialDefined
;
255 #define OPT_CRSF_RCVR_NO_SERIAL (GPIO_PIN_RCSIGNAL_RX == UNDEF_PIN && GPIO_PIN_RCSIGNAL_TX == UNDEF_PIN && !pwmSerialDefined)
257 #define OPT_CRSF_RCVR_NO_SERIAL false
260 #if defined(USE_ANALOG_VBAT) && !defined(GPIO_ANALOG_VBAT)
261 #define GPIO_ANALOG_VBAT A0
262 #if !defined(ANALOG_VBAT_SCALE)
263 #define ANALOG_VBAT_SCALE 1
267 #if defined(RADIO_SX128X)
268 #define Regulatory_Domain_ISM_2400 1
269 // ISM 2400 band is in use => undefine other requlatory domain defines
270 #undef Regulatory_Domain_AU_915
271 #undef Regulatory_Domain_EU_868
272 #undef Regulatory_Domain_IN_866
273 #undef Regulatory_Domain_FCC_915
274 #undef Regulatory_Domain_AU_433
275 #undef Regulatory_Domain_EU_433
276 #undef Regulatory_Domain_US_433
277 #undef Regulatory_Domain_US_433_WIDE
279 #elif defined(RADIO_SX127X) || defined(RADIO_LR1121)
280 #if !(defined(Regulatory_Domain_AU_915) || defined(Regulatory_Domain_FCC_915) || \
281 defined(Regulatory_Domain_EU_868) || defined(Regulatory_Domain_IN_866) || \
282 defined(Regulatory_Domain_AU_433) || defined(Regulatory_Domain_EU_433) || \
283 defined(Regulatory_Domain_US_433) || defined(Regulatory_Domain_US_433_WIDE) || \
285 #error "Regulatory_Domain is not defined for 900MHz device. Check user_defines.txt!"
288 #error "Either RADIO_SX127X, RADIO_LR1121 or RADIO_SX128X must be defined!"
291 #if defined(TARGET_UNIFIED_TX) || defined(TARGET_UNIFIED_RX)
292 #if defined(PLATFORM_ESP32)
293 #include <soc/uart_pins.h>
295 #if !defined(U0RXD_GPIO_NUM)
296 #define U0RXD_GPIO_NUM (3)
298 #if !defined(U0TXD_GPIO_NUM)
299 #define U0TXD_GPIO_NUM (1)
301 #include "hardware.h"