More generic serial port config

This commit is contained in:
Raphael Coeffic
2022-03-20 16:30:58 +01:00
parent b39baa2360
commit b5779f2a6a
27 changed files with 209 additions and 281 deletions
+2 -2
View File
@@ -211,6 +211,8 @@ enum SerialPort {
}; };
#define MAX_AUX_SERIAL (SP_AUX2 + 1) #define MAX_AUX_SERIAL (SP_AUX2 + 1)
#define STORAGE_SERIAL_PORTS 4
#define TRAINER_MODE_MIN() TRAINER_MODE_MASTER_TRAINER_JACK #define TRAINER_MODE_MIN() TRAINER_MODE_MASTER_TRAINER_JACK
@@ -228,8 +230,6 @@ enum SerialPort {
#define TRAINER_MODE_MAX() TRAINER_MODE_SLAVE_BLUETOOTH #define TRAINER_MODE_MAX() TRAINER_MODE_SLAVE_BLUETOOTH
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBNV14) #elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBNV14)
#define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE #define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
#elif defined(PCBTARANIS)
#define TRAINER_MODE_MAX() (IS_TRAINER_AUX_SERIAL() ? TRAINER_MODE_MASTER_BATTERY_COMPARTMENT : TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)
#else #else
#define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_BATTERY_COMPARTMENT #define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_BATTERY_COMPARTMENT
#endif #endif
+8 -8
View File
@@ -116,29 +116,29 @@ static inline void check_struct()
CHKSIZE(TrainerData, 16); CHKSIZE(TrainerData, 16);
#if defined(PCBXLITES) #if defined(PCBXLITES)
CHKSIZE(RadioData, 857); CHKSIZE(RadioData, 859);
CHKSIZE(ModelData, 6161); CHKSIZE(ModelData, 6161);
#elif defined(PCBXLITE) #elif defined(PCBXLITE)
CHKSIZE(RadioData, 855); CHKSIZE(RadioData, 857);
CHKSIZE(ModelData, 6161); CHKSIZE(ModelData, 6161);
#elif defined(RADIO_TPRO) #elif defined(RADIO_TPRO)
CHKSIZE(RadioData, 838); CHKSIZE(RadioData, 840);
CHKSIZE(ModelData, 6186); CHKSIZE(ModelData, 6186);
#elif defined(PCBX7) #elif defined(PCBX7)
CHKSIZE(RadioData, 861); CHKSIZE(RadioData, 863);
CHKSIZE(ModelData, 6161); CHKSIZE(ModelData, 6161);
#elif defined(PCBX9E) #elif defined(PCBX9E)
CHKSIZE(RadioData, 951); CHKSIZE(RadioData, 953);
CHKSIZE(ModelData, 6613); CHKSIZE(ModelData, 6613);
#elif defined(PCBX9D) || defined(PCBX9DP) #elif defined(PCBX9D) || defined(PCBX9DP)
CHKSIZE(RadioData, 893); CHKSIZE(RadioData, 895);
CHKSIZE(ModelData, 6605); CHKSIZE(ModelData, 6605);
#elif defined(PCBHORUS) #elif defined(PCBHORUS)
#if defined(PCBX10) #if defined(PCBX10)
CHKSIZE(RadioData, 918); CHKSIZE(RadioData, 919);
CHKSIZE(ModelData, 11025); CHKSIZE(ModelData, 11025);
#else #else
CHKSIZE(RadioData, 900); CHKSIZE(RadioData, 901);
CHKSIZE(ModelData, 11023); CHKSIZE(ModelData, 11023);
#endif #endif
#endif #endif
+5 -8
View File
@@ -787,10 +787,8 @@ PACK(struct TrainerData {
#define GYRO_FIELDS #define GYRO_FIELDS
#endif #endif
#if defined(PCBHORUS) || defined(PCBNV14) #if defined(COLORLCD)
#define EXTRA_GENERAL_FIELDS \ #define EXTRA_GENERAL_FIELDS \
NOBACKUP(uint8_t auxSerialMode:4 ENUM(UartModes)); \
NOBACKUP(uint8_t aux2SerialMode:4 ENUM(UartModes)); \
CUST_ARRAY(sticksConfig, struct_sticksConfig, stick_name_valid); \ CUST_ARRAY(sticksConfig, struct_sticksConfig, stick_name_valid); \
swconfig_t switchConfig ARRAY(2,struct_switchConfig,nullptr); \ swconfig_t switchConfig ARRAY(2,struct_switchConfig,nullptr); \
uint16_t potsConfig ARRAY(2,struct_potConfig,nullptr); /* two bits per pot */ \ uint16_t potsConfig ARRAY(2,struct_potConfig,nullptr); /* two bits per pot */ \
@@ -801,17 +799,17 @@ PACK(struct TrainerData {
NOBACKUP(uint8_t spare5:1 SKIP); \ NOBACKUP(uint8_t spare5:1 SKIP); \
NOBACKUP(uint8_t blOffBright:7); \ NOBACKUP(uint8_t blOffBright:7); \
NOBACKUP(char bluetoothName[LEN_BLUETOOTH_NAME]); NOBACKUP(char bluetoothName[LEN_BLUETOOTH_NAME]);
#elif defined(PCBTARANIS) #else
#if defined(STORAGE_BLUETOOTH) #if defined(STORAGE_BLUETOOTH)
#define BLUETOOTH_FIELDS \ #define BLUETOOTH_FIELDS \
uint8_t spare5 SKIP; \ uint8_t spare6 SKIP; \
char bluetoothName[LEN_BLUETOOTH_NAME]; char bluetoothName[LEN_BLUETOOTH_NAME];
#else #else
#define BLUETOOTH_FIELDS #define BLUETOOTH_FIELDS
#endif #endif
#define EXTRA_GENERAL_FIELDS \ #define EXTRA_GENERAL_FIELDS \
uint8_t auxSerialMode:4 ENUM(UartModes); \
uint8_t slidersConfig:4 ARRAY(1,struct_sliderConfig,nullptr); \ uint8_t slidersConfig:4 ARRAY(1,struct_sliderConfig,nullptr); \
uint8_t spare5:4 SKIP; \
uint8_t potsConfig ARRAY(2,struct_potConfig,nullptr); /* two bits per pot */\ uint8_t potsConfig ARRAY(2,struct_potConfig,nullptr); /* two bits per pot */\
uint8_t backlightColor; \ uint8_t backlightColor; \
CUST_ARRAY(sticksConfig, struct_sticksConfig, stick_name_valid); \ CUST_ARRAY(sticksConfig, struct_sticksConfig, stick_name_valid); \
@@ -819,8 +817,6 @@ PACK(struct TrainerData {
char switchNames[STORAGE_NUM_SWITCHES - NUM_FUNCTIONS_SWITCHES][LEN_SWITCH_NAME] SKIP; \ char switchNames[STORAGE_NUM_SWITCHES - NUM_FUNCTIONS_SWITCHES][LEN_SWITCH_NAME] SKIP; \
char anaNames[NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS][LEN_ANA_NAME] SKIP; \ char anaNames[NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS][LEN_ANA_NAME] SKIP; \
BLUETOOTH_FIELDS BLUETOOTH_FIELDS
#else
#define EXTRA_GENERAL_FIELDS
#endif #endif
#if defined(COLORLCD) && !defined(BACKUP) #if defined(COLORLCD) && !defined(BACKUP)
@@ -912,6 +908,7 @@ PACK(struct RadioData {
NOBACKUP(int8_t varioRepeat); NOBACKUP(int8_t varioRepeat);
CustomFunctionData customFn[MAX_SPECIAL_FUNCTIONS] FUNC(cfn_is_active); CustomFunctionData customFn[MAX_SPECIAL_FUNCTIONS] FUNC(cfn_is_active);
NOBACKUP(uint16_t serialPort ARRAY(STORAGE_SERIAL_PORTS,struct_serialConfig,nullptr));
EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS
THEME_DATA THEME_DATA
+24 -30
View File
@@ -373,38 +373,32 @@ void RadioHardwarePage::build(FormWindow * window)
} }
#endif #endif
#if defined(AUX_SERIAL) bool display_ttl_warning = false;
new StaticText(window, grid.getLabelSlot(), STR_AUX_SERIAL_MODE, 0, COLOR_THEME_PRIMARY1); for (uint8_t port_nr = 0; port_nr < MAX_SERIAL_PORTS; port_nr++) {
auto aux = auto port = serialGetPort(port_nr);
new Choice(window, grid.getFieldSlot(1, 0), STR_AUX_SERIAL_MODES, 0, if (!port) continue;
UART_MODE_MAX, GET_DEFAULT(g_eeGeneral.auxSerialMode),
[](int value) {
g_eeGeneral.auxSerialMode = value;
serialInit(SP_AUX1, value);
SET_DIRTY();
});
aux->setAvailableHandler(isAuxModeAvailable);
grid.nextLine();
#endif
#if defined(AUX2_SERIAL) display_ttl_warning = true;
new StaticText(window, grid.getLabelSlot(), STR_AUX2_SERIAL_MODE, 0, COLOR_THEME_PRIMARY1); new StaticText(window, grid.getLabelSlot(), STR_AUX_SERIAL_MODE, 0,
auto aux2 = COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(1, 0), STR_AUX_SERIAL_MODES, 0, auto aux = new Choice(
UART_MODE_MAX, GET_DEFAULT(g_eeGeneral.aux2SerialMode), window, grid.getFieldSlot(1, 0), STR_AUX_SERIAL_MODES, 0, UART_MODE_MAX,
[](int value) { [=]() { return serialGetMode(port_nr); },
g_eeGeneral.aux2SerialMode = value; [=](int value) {
serialInit(SP_AUX2, value); serialSetMode(port_nr, value);
SET_DIRTY(); serialInit(port_nr, value);
}); SET_DIRTY();
aux2->setAvailableHandler(isAux2ModeAvailable); });
grid.nextLine(); aux->setAvailableHandler(
#endif [=](int value) { return isAuxModeAvailable(port_nr, value); });
grid.nextLine();
}
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL) if (display_ttl_warning) {
new StaticText(window, grid.getFieldSlot(1,0), STR_TTL_WARNING, 0, COLOR_THEME_WARNING); new StaticText(window, grid.getFieldSlot(1, 0), STR_TTL_WARNING, 0,
grid.nextLine(); COLOR_THEME_WARNING);
#endif grid.nextLine();
}
// ADC filter // ADC filter
new StaticText(window, grid.getLabelSlot(), STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1); new StaticText(window, grid.getLabelSlot(), STR_JITTER_FILTER, 0, COLOR_THEME_PRIMARY1);
+15 -28
View File
@@ -367,29 +367,18 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
return true; return true;
} }
bool isAuxModeAvailable(int mode) int hasSerialMode(int mode)
{ {
#if defined(AUX2_SERIAL) for (int p = 0; p < MAX_SERIAL_PORTS; p++) {
if (mode == UART_MODE_SBUS_TRAINER) if (serialGetMode(p) == mode) return p;
return g_eeGeneral.aux2SerialMode != UART_MODE_SBUS_TRAINER; }
#if defined(RADIO_TX16S) return -1;
else
return (g_model.trainerData.mode != TRAINER_MODE_MASTER_BATTERY_COMPARTMENT || g_eeGeneral.aux2SerialMode == UART_MODE_SBUS_TRAINER);
#endif
#endif
return true;
} }
bool isAux2ModeAvailable(int mode) bool isAuxModeAvailable(uint8_t port_nr, int mode)
{ {
#if defined(AUX_SERIAL) auto p = hasSerialMode(mode);
if (mode == UART_MODE_SBUS_TRAINER) if (p >= 0 && p != port_nr) return false;
return g_eeGeneral.auxSerialMode != UART_MODE_SBUS_TRAINER;
#if defined(RADIO_TX16S)
else
return (g_model.trainerData.mode != TRAINER_MODE_MASTER_BATTERY_COMPARTMENT || g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER);
#endif
#endif
return true; return true;
} }
@@ -755,7 +744,8 @@ bool isRfProtocolAvailable(int protocol)
bool isTelemetryProtocolAvailable(int protocol) bool isTelemetryProtocolAvailable(int protocol)
{ {
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (protocol == PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY && g_eeGeneral.auxSerialMode != UART_MODE_TELEMETRY) { if (protocol == PROTOCOL_TELEMETRY_FRSKY_D_SECONDARY &&
hasSerialMode(UART_MODE_TELEMETRY) < 0) {
return false; return false;
} }
#endif #endif
@@ -803,16 +793,13 @@ bool isTrainerModeAvailable(int mode)
} }
#endif #endif
#if defined(RADIO_TX16S) && defined(TRAINER_BATTERY_COMPARTMENT) if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT) {
if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT) #if defined(TRAINER_BATTERY_COMPARTMENT)
return (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER || g_eeGeneral.aux2SerialMode == UART_MODE_SBUS_TRAINER); return hasSerialMode(UART_MODE_SBUS_TRAINER) >= 0;
#elif defined(PCBTARANIS) && !defined(TRAINER_BATTERY_COMPARTMENT) #else
if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
return false; return false;
#elif defined(PCBTARANIS)
if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
return g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER;
#endif #endif
}
#if defined(BLUETOOTH) && !defined(PCBX9E) #if defined(BLUETOOTH) && !defined(PCBX9E)
if (g_eeGeneral.bluetoothMode != BLUETOOTH_TRAINER && (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_SLAVE_BLUETOOTH)) if (g_eeGeneral.bluetoothMode != BLUETOOTH_TRAINER && (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_SLAVE_BLUETOOTH))
+2 -2
View File
@@ -86,8 +86,8 @@ bool isSourceAvailableInCustomSwitches(int source);
bool isSourceAvailableInResetSpecialFunction(int index); bool isSourceAvailableInResetSpecialFunction(int index);
bool isSourceAvailableInGlobalResetSpecialFunction(int index); bool isSourceAvailableInGlobalResetSpecialFunction(int index);
bool isSwitchAvailable(int swtch, SwitchContext context); bool isSwitchAvailable(int swtch, SwitchContext context);
bool isAuxModeAvailable(int mode); bool isAuxModeAvailable(uint8_t port_nr, int mode);
bool isAux2ModeAvailable(int mode); int hasSerialMode(int mode);
bool isSwitchAvailableInLogicalSwitches(int swtch); bool isSwitchAvailableInLogicalSwitches(int swtch);
bool isSwitchAvailableInCustomFunctions(int swtch); bool isSwitchAvailableInCustomFunctions(int swtch);
bool isSwitchAvailableInMixes(int swtch); bool isSwitchAvailableInMixes(int swtch);
-2
View File
@@ -44,8 +44,6 @@
#define IS_TRAINER_EXTERNAL_MODULE() false #define IS_TRAINER_EXTERNAL_MODULE() false
#endif #endif
#define IS_TRAINER_AUX_SERIAL() (g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER)
#define IS_PLAY_FUNC(func) ((func) >= FUNC_PLAY_SOUND && func <= FUNC_PLAY_VALUE) #define IS_PLAY_FUNC(func) ((func) >= FUNC_PLAY_SOUND && func <= FUNC_PLAY_VALUE)
#if defined(GVARS) #if defined(GVARS)
+49 -47
View File
@@ -84,19 +84,14 @@ extern "C" void dbgSerialCrlf()
dbgSerialPutc('\n'); dbgSerialPutc('\n');
} }
static int getSerialPortMode(uint8_t port_nr) int8_t getSerialPortMode(uint8_t port_nr)
{ {
#if !defined(BOOT) #if !defined(BOOT)
if (port_nr == 0) { if (port_nr < MAX_SERIAL_PORTS) {
return g_eeGeneral.auxSerialMode; auto cfg = g_eeGeneral.serialPort;
cfg >>= port_nr * 4; // 4 bits per port
return cfg & 0xF;
} }
// TODO: change in datastruct_private.h
#if defined(PCBHORUS) || defined(PCBNV14)
if (port_nr == 1) {
return g_eeGeneral.aux2SerialMode;
}
#endif
#endif #endif
return UART_MODE_NONE; return UART_MODE_NONE;
@@ -111,7 +106,7 @@ struct SerialPortState
static SerialPortState serialPortStates[MAX_SERIAL_PORTS]; static SerialPortState serialPortStates[MAX_SERIAL_PORTS];
static SerialPortState* getSerialPortState(int port_nr) static SerialPortState* getSerialPortState(uint8_t port_nr)
{ {
if (port_nr >= MAX_SERIAL_PORTS) return nullptr; if (port_nr >= MAX_SERIAL_PORTS) return nullptr;
return &serialPortStates[port_nr]; return &serialPortStates[port_nr];
@@ -239,11 +234,8 @@ static void serialSetupPort(int mode, etx_serial_init& params, bool& power_requi
} }
} }
void serialInit(int port_nr, int mode) const etx_serial_port_t* serialGetPort(uint8_t port_nr)
{ {
auto state = getSerialPortState(port_nr);
if (!state) return;
const etx_serial_port_t* port = nullptr; const etx_serial_port_t* port = nullptr;
if (port_nr != SP_VCP) { if (port_nr != SP_VCP) {
port = auxSerialGetPort(port_nr); port = auxSerialGetPort(port_nr);
@@ -253,11 +245,21 @@ void serialInit(int port_nr, int mode)
port = &UsbSerialPort; port = &UsbSerialPort;
} }
#endif #endif
return port;
}
void serialInit(uint8_t port_nr, int mode)
{
auto state = getSerialPortState(port_nr);
if (!state) return;
const etx_serial_port_t* port = serialGetPort(port_nr);
if (!port) return; if (!port) return;
if (state->port) { if (state->port) {
auto drv = state->port->uart; auto drv = state->port->uart;
if (drv->deinit) { if (drv && drv->deinit) {
drv->deinit(state->usart_ctx); drv->deinit(state->usart_ctx);
} }
if (state->mode != 0) { if (state->mode != 0) {
@@ -283,11 +285,15 @@ void serialInit(int port_nr, int mode)
if (params.baudrate != 0) { if (params.baudrate != 0) {
state->mode = mode; state->mode = mode;
state->port = port; state->port = port;
state->usart_ctx = port->uart->init(&params);
// Set power on/off if (port) {
if (port->set_pwr) { if (port->uart && port->uart->init)
port->set_pwr(power_required); state->usart_ctx = port->uart->init(&params);
// Set power on/off
if (port->set_pwr) {
port->set_pwr(power_required);
}
} }
// Update callbacks once the port is setup // Update callbacks once the port is setup
@@ -299,29 +305,35 @@ void initSerialPorts()
{ {
memset(serialPortStates, 0, sizeof(serialPortStates)); memset(serialPortStates, 0, sizeof(serialPortStates));
for (int port_nr = 0; port_nr < MAX_AUX_SERIAL; port_nr++) { for (uint8_t port_nr = 0; port_nr < MAX_AUX_SERIAL; port_nr++) {
auto mode = getSerialPortMode(port_nr); auto mode = getSerialPortMode(port_nr);
serialInit(port_nr, mode); serialInit(port_nr, mode);
} }
} }
uint8_t serialGetMode(int port_nr) int serialGetMode(uint8_t port_nr)
{ {
auto state = getSerialPortState(port_nr); return getSerialPortMode(port_nr);
if (!state) return UART_MODE_NONE;
return state->mode;
} }
uint8_t serialTracesEnabled(int port_nr) void serialSetMode(uint8_t port_nr, int mode)
{ {
#if defined(DEBUG) if (port_nr >= MAX_SERIAL_PORTS) return;
return serialGetMode(port_nr) == UART_MODE_DEBUG; uint16_t m = mode & 0xF;
#else g_eeGeneral.serialPort =
return false; (g_eeGeneral.serialPort & ~(0xF << port_nr * 4)) | (m << port_nr * 4);
#endif
} }
void serialStop(int port_nr) // uint8_t serialTracesEnabled(int port_nr)
// {
// #if defined(DEBUG)
// return serialGetMode(port_nr) == UART_MODE_DEBUG;
// #else
// return false;
// #endif
// }
void serialStop(uint8_t port_nr)
{ {
auto state = getSerialPortState(port_nr); auto state = getSerialPortState(port_nr);
if (!state) return; if (!state) return;
@@ -332,24 +344,14 @@ void serialStop(int port_nr)
if (drv && drv->deinit) { if (drv && drv->deinit) {
drv->deinit(state->usart_ctx); drv->deinit(state->usart_ctx);
} }
if (state->mode != 0) {
// Clear callbacks
serialSetCallBacks(state->mode, nullptr, nullptr);
}
if (port->set_pwr) { if (port->set_pwr) {
// Power OFF // Power OFF
port->set_pwr(0); port->set_pwr(0);
} }
memset(state, 0, sizeof(SerialPortState)); if (state->mode != 0) {
// Clear callbacks
serialSetCallBacks(state->mode, nullptr, nullptr);
}
} }
} memset(state, 0, sizeof(SerialPortState));
void serialPutc(int port_nr, uint8_t c)
{
auto state = getSerialPortState(port_nr);
if (!state) return;
if (state->port) {
state->port->uart->sendByte(state->usart_ctx, c);
}
} }
+8 -6
View File
@@ -23,13 +23,15 @@
#define _SERIAL_H_ #define _SERIAL_H_
#include <stdint.h> #include <stdint.h>
#include "hal/serial_port.h"
void initSerialPorts(); const etx_serial_port_t* serialGetPort(uint8_t port_nr);
uint8_t serialGetMode(int port_nr); int serialGetMode(uint8_t port_nr);
uint8_t serialTracesEnabled(int port_nr); void serialSetMode(uint8_t port_nr, int mode);
void serialInit(int port_nr, int mode);
void serialStop(int port_nr); void initSerialPorts();
void serialPutc(int port_nr, uint8_t c); void serialInit(uint8_t port_nr, int mode);
void serialStop(uint8_t port_nr);
// //
// Functions used by debug.h // Functions used by debug.h
@@ -1733,3 +1733,46 @@ static void r_jitterFilter(void* user, uint8_t* data, uint32_t bitoffs,
uint32_t i = yaml_str2uint(val, val_len); uint32_t i = yaml_str2uint(val, val_len);
yaml_put_bits(data, i, bitoffs, 1); yaml_put_bits(data, i, bitoffs, 1);
} }
//struct_serialConfig
static const struct YamlIdStr enum_SerialPort[] = {
{ SP_AUX1, "AUX1" },
{ SP_AUX2, "AUX2" },
{ SP_VCP, "VCP" },
{ 0, NULL }
};
static const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "TELEMETRY_IN" },
{ UART_MODE_SBUS_TRAINER, "SBUS_TRAINER" },
{ UART_MODE_LUA, "LUA" },
{ UART_MODE_CLI, "CLI" },
{ 0, NULL }
};
static uint32_t port_read(void* user, const char* val, uint8_t val_len)
{
(void)user;
uint32_t port = yaml_parse_enum(enum_SerialPort, val, val_len);
if (port < MAX_SERIAL_PORTS) return port;
return -1;
}
bool port_write(void* user, yaml_writer_func wf, void* opaque)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
const char* str = yaml_output_enum(idx, enum_SerialPort);
return str ? wf(opaque, str, strlen(str)) : true;
}
static const struct YamlNode struct_serialConfig[] = {
YAML_IDX_CUST( "port", sw_read, sw_write),
YAML_ENUM( "mode", 4, enum_UartModes),
YAML_END
};
@@ -85,14 +85,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" }, { FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_ZoneOptionValueEnum[] = { const struct YamlIdStr enum_ZoneOptionValueEnum[] = {
{ ZOV_Unsigned, "Unsigned" }, { ZOV_Unsigned, "Unsigned" },
{ ZOV_Signed, "Signed" }, { ZOV_Signed, "Signed" },
@@ -427,8 +419,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ENUM("aux2SerialMode", 4, enum_UartModes),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr), YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -406,8 +398,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -85,14 +85,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" }, { FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_ZoneOptionValueEnum[] = { const struct YamlIdStr enum_ZoneOptionValueEnum[] = {
{ ZOV_Unsigned, "Unsigned" }, { ZOV_Unsigned, "Unsigned" },
{ ZOV_Signed, "Signed" }, { ZOV_Signed, "Signed" },
@@ -448,8 +440,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ENUM("aux2SerialMode", 4, enum_UartModes),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr), YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -85,14 +85,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" }, { FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_ZoneOptionValueEnum[] = { const struct YamlIdStr enum_ZoneOptionValueEnum[] = {
{ ZOV_Unsigned, "Unsigned" }, { ZOV_Unsigned, "Unsigned" },
{ ZOV_Signed, "Signed" }, { ZOV_Signed, "Signed" },
@@ -446,8 +438,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ENUM("aux2SerialMode", 4, enum_UartModes),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr), YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -405,8 +397,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -444,8 +436,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -385,8 +377,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -393,8 +385,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -390,8 +382,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -392,8 +384,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
@@ -84,14 +84,6 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_RACING_MODE, "RACING_MODE" },
{ 0, NULL } { 0, NULL }
}; };
const struct YamlIdStr enum_UartModes[] = {
{ UART_MODE_NONE, "MODE_NONE" },
{ UART_MODE_TELEMETRY_MIRROR, "MODE_TELEMETRY_MIRROR" },
{ UART_MODE_TELEMETRY, "MODE_TELEMETRY" },
{ UART_MODE_SBUS_TRAINER, "MODE_SBUS_TRAINER" },
{ UART_MODE_LUA, "MODE_LUA" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = { const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" }, { TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" }, { TMRMODE_ON, "ON" },
@@ -398,8 +390,9 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ), YAML_SIGNED_CUST( "varioRange", 8, r_vPitch, w_vPitch ),
YAML_SIGNED( "varioRepeat", 8 ), YAML_SIGNED( "varioRepeat", 8 ),
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active), YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_ENUM("auxSerialMode", 4, enum_UartModes), YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr), YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr), YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
YAML_UNSIGNED( "backlightColor", 8 ), YAML_UNSIGNED( "backlightColor", 8 ),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid), YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
+24 -1
View File
@@ -753,7 +753,30 @@ const etx_serial_port_t UsbSerialPort = {
}; };
#endif #endif
const etx_serial_port_t* auxSerialGetPort(int port_nr) { return nullptr; } #if defined(AUX_SERIAL)
const etx_serial_port_t auxSerialPort = { nullptr, nullptr };
#define AUX_SERIAL_PORT &auxSerialPort
#else
#define AUX_SERIAL_PORT nullptr
#endif
#if defined(AUX2_SERIAL)
const etx_serial_port_t aux2SerialPort = { nullptr, nullptr };
#define AUX2_SERIAL_PORT &aux2SerialPort
#else
#define AUX2_SERIAL_PORT nullptr
#endif // AUX2_SERIAL
static const etx_serial_port_t* serialPorts[MAX_AUX_SERIAL] = {
AUX_SERIAL_PORT,
AUX2_SERIAL_PORT,
};
const etx_serial_port_t* auxSerialGetPort(int port_nr)
{
if (port_nr >= MAX_AUX_SERIAL) return nullptr;
return serialPorts[port_nr];
}
#if defined(HARDWARE_TOUCH) #if defined(HARDWARE_TOUCH)
struct TouchState simTouchState = {}; struct TouchState simTouchState = {};