Hardware Defines - ExpressLRS/ExpressLRS GitHub Wiki
UART Pin definition
#define GPIO_PIN_RCSIGNAL_RX
#define GPIO_PIN_RCSIGNAL_TX
Receiver
If left undefined or UNDEF_PIN
or -1
, then the default serial port of the device is used.
Transmitter
These may be defined as the same pin if the hardware permits. On ESP32 devices, the TX and RX are swapped using pin control commands.
On STM32 devices, either an external buffer is used (see GPIO_PIN_BUFFER_OE
below) or the UART operates in half-duplex mode.
Optional
#define GPIO_PIN_BUFFER_OE // If a buffer is used to control serial TX pin output, then set the output enable pin here
#define GPIO_PIN_BUFFER_OE_INVERTED // Set to 1 if OE pin LOW enables serial TX output
On STM32 based transmitter modules, the above defines are used if the target uses a buffer to control the output of the TX pin to the Radio. If a buffer is not used to control TX pin output and the pins are defined to the same pin then half-duplex mode used.
Radio transceiver definition
SPI and other control pins connected to the transceiver chip, SX120 or SX127x
#define GPIO_PIN_SCK
#define GPIO_PIN_MISO
#define GPIO_PIN_MOSI
#define GPIO_PIN_NSS
#define GPIO_PIN_RST
#define GPIO_PIN_DIO0 // Used by SX127x based targets, attached to interrupt for callback when TX/RX done.
#define GPIO_PIN_DIO1 // Used by SX1280 based targets, attached to interrupt for callback when TX/RX done.
#define GPIO_PIN_BUSY // Connected to BUSY pin of SX1280 targets.
I2C bus
#define GPIO_PIN_SCL
#define GPIO_PIN_SDA
I2C Pins used to set output power of DAC controlled power amplifier and/or read an external EEPROM for config.
These pins are optional only need to be defined if a Power Amp DAC or external EEPROM is used.
I2C EEPROM
#define TARGET_USE_EEPROM
#define TARGET_EEPROM_ADDR
If an external EEPROM is used to store the configuration then you must define TARGET_USE_EEPROM
and also TARGET_EEPROM_ADDR
with the I2C address of the EEPROM chip.
LED
Standard LEDs used to signal status information.
#define GPIO_PIN_LED
#define GPIO_PIN_LED_RED
#define GPIO_LED_RED_INVERTED
#define GPIO_PIN_LED_GREEN
#define GPIO_LED_GREEN_INVERTED
LED is on of pin is HIGH unless *_INVERTED
is also defined (if available).
If GPIO_PIN_LED
is undefined then it defaults to GPIO_PIN_LED_RED
if defined.
See the ExpressLRS documentation web site for details of the LED status indication.
RGB LED
Pin used to drive a WS2812 RGB LED. For STM32 devices, the FAST
pin must also be defined.
#define GPIO_PIN_LED_WS2812
#define GPIO_PIN_LED_WS2812_FAST
#define WS2812_IS_GRB // optional
If the RGB LED is a GRB LED vs an RGB LED then also define WS2812_IS_GRB
Button
Pin used to detect button press, if used.
#define GPIO_PIN_BUTTON
#define GPIO_BUTTON_INVERTED // If the pin is HIGH when pressed, then this should be 1 otherwise 0.
Joystick
Analog joystick configuration values (recommended)
#define GPIO_PIN_JOYSTICK // this is an analog pin number, not a digital pin number.
/* Joystick values {UP, DOWN, LEFT, RIGHT, ENTER, IDLE}*/
#define JOY_ADC_VALUES {459, 509, 326, 182, 91, 1021}
Digital joystick configuration (NOT recommended)
#define GPIO_PIN_FIVE_WAY_INPUT1
#define GPIO_PIN_FIVE_WAY_INPUT2
#define GPIO_PIN_FIVE_WAY_INPUT3
These are combined to for a 3-bit number for the switch position where INPUT1 is the MSB and INPUT3 is the LSB
Value | Position |
---|---|
0 | |
1 | |
2 | INPUT_KEY_LEFT_PRESS |
3 | INPUT_KEY_UP_PRESS |
4 | INPUT_KEY_RIGHT_PRESS |
5 | INPUT_KEY_DOWN_PRESS |
6 | INPUT_KEY_OK_PRESS |
7 | INPUT_KEY_NO_PRESS |
Buzzer
Defines the pin that a buzzer is connected to, if used.
#define GPIO_PIN_BUZZER
OLED Screen
Defines for pins used by TX OLED displays.
#define GPIO_PIN_OLED_SCK // SPI or I2C clock pin
#define GPIO_PIN_OLED_RST // SPI or I2C reset pin
#define GPIO_PIN_OLED_SDA // I2C SDA pin
#define GPIO_PIN_OLED_MOSI // SPI MOSI
#define GPIO_PIN_OLED_CS // SPI CS pin
#define GPIO_PIN_OLED_DC // SPI Data/Command pin
Power Output
#define GPIO_PIN_PA_ENABLE // Pin used to enable the power amplifier, active HIGH (optional)
#define GPIO_PIN_RX_ENABLE // Enable the RX side of the PA, active HIGH (optional, if not specified then RX active when TX_ENABLE LOW)
#define GPIO_PIN_TX_ENABLE // Enable the TX side of the PA, active HIGH (optional, if not specified then TX active when RX_ENABLE LOW)
#define GPIO_PIN_ANT_CTRL_1 // Connect Antenna 1 to the PA, active HIGH (optional)
#define GPIO_PIN_ANT_CTRL_2 // Connect Antenna 2 to the PA, active HIGH (optional)
One of the following should be set to determine how the output power is set. If not are set the the default is to use the Radio.setOutputPower()
function.
#define POWER_OUTPUT_DAC // use external I2C DAC to set output power, this define contains the I2C address of the DAC chip
#define POWER_OUTPUT_DACWRITE // use internal dacWrite function to set value on GPIO_PIN_RFamp_APC2
#define POWER_OUTPUT_ANALOG // use internal analogWrite function to set value on GPIO_PIN_RFamp_APC2
#define GPIO_PIN_RFamp_APC1 // Set to 2.7V output when using POWER_OUTPUT_ANALOG, unused otherwise
#define GPIO_PIN_RFamp_APC2 // Analog pin to set voltage to control power amplifier
The above defines are used to specify which analog pins are used to set the voltage levels used to drive a power amplifier if using either POWER_OUTPUT_DACWRITE
or POWER_OUTPUT_ANALOG
mode.
Available Power Levels
The following defines are used to set the min, max and higher power thresholds. Valid values are:
PWR_10mW
, PWR_25mW
, PWR_50mW
, PWR_100mW
, PWR_250mW
, PWR_500mW
, PWR_1000mW
, PWR_2000mW
.
#define MinPower // The minimum selectable power level supported by the hardware
#define HighPower // This is used as MaxPower unless UNLOCK_HIGHER_POWER is enabled by the user
#define MaxPower // The absolute maximum power level supported by the hardware
#define POWER_OUTPUT_VALUES // Values used to set power level
#define POWER_OUTPUT_FIXED // Single value to set the output power
POWER_OUTPUT_VALUES
is a list of values from MinPower
to MaxPower
that is used as the parameter to the power output function.
e.g.
#define POWER_OUTPUT_VALUES {8,12,15}
POWER_OUTPUT_FIXED
is a single value that overrides the POWER_OUTPUT_VALUES
setting above, and generally used on RXes that
only have a single output power level, but can be used with TXes with a fixed power level too.
Fan control
#define GPIO_PIN_FAN_EN
Active HIGH pin used to enable module fan if output power >= 250mW.
Diversity Antenna
Pin connected to analog switch controlling which antenna is connected to the transceiver on an RX module with antenna diversity.
#define GPIO_PIN_ANTENNA_SELECT
Debug serial port
Extra (optional) serial port pins
#define GPIO_PIN_DEBUG_RX
#define GPIO_PIN_DEBUG_TX
Vendor Specific
Siyi FM30 TX
/*
* Inverter enable pins.
*/
#define GPIO_PIN_UART1TX_INVERT
#define GPIO_PIN_UART1RX_INVERT
#define GPIO_PIN_UART3RX_INVERT
/*
* If a bluetooth module is connected this pin defines the pin to enable/power on the bluetooth module.
* The module is enabled when the pin is LOW.
*/
#define GPIO_PIN_BLUETOOTH_EN
/*
* Other LEDs that are not used
*/
#define GPIO_PIN_LED_GREEN_RED // These are FM30 TX LEDs and are set to off
#define GPIO_PIN_LED_RED_GREEN // These are FM30 TX LEDs and are set to off
BETAFPV TX
#define GPIO_PIN_LED_BLUE // BETAFPV TX LED
If BLUE
and GREEN
are defined then these show the power Level
Output Power | LED state |
---|---|
<=100mW | BLUE on, GREEN off |
250mW | BLUE on, GREEN on |
500mW | BLUE off, GREEN on |