User controllable serial port power.

Thx to @raphaelcoeffic for numerous tips with YAML.
Tested with TX16S mkII.
This commit is contained in:
rotorman
2022-04-18 13:19:33 +02:00
parent f39f7a87ed
commit b1a3bc834f
22 changed files with 115 additions and 59 deletions
@@ -1854,6 +1854,7 @@ static bool port_write(void* user, yaml_writer_func wf, void* opaque)
static const struct YamlNode struct_serialConfig[] = {
YAML_IDX_CUST( "port", port_read, port_write),
YAML_ENUM( "mode", 4, enum_UartModes),
YAML_UNSIGNED( "power", 1 ),
YAML_END
};
@@ -1876,6 +1877,7 @@ static void r_serialMode(void* user, uint8_t* data, uint32_t bitoffs,
auto m = yaml_parse_enum(yaml_conv_220::enum_UartModes, val, val_len);
if (!m) return;
auto serialPort = reinterpret_cast<uint16_t*>(data);
*serialPort = (*serialPort & ~(0xF << port_nr * 4)) | (m << port_nr * 4);
auto serialPort = reinterpret_cast<uint32_t*>(data);
*serialPort = (*serialPort & ~(0xF << port_nr * SERIAL_CONF_BITS_PER_PORT)) |
(m << port_nr * SERIAL_CONF_BITS_PER_PORT);
}
@@ -423,7 +423,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -439,7 +439,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_UNSIGNED( "stickDeadZone", 3 ),
YAML_PADDING( 2 ),
YAML_PADDING( 3 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -402,7 +402,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -413,7 +413,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 144 ),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -444,7 +444,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -459,7 +459,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRUCT("themeData", 480, struct_OpenTxTheme__PersistentData, NULL),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -442,7 +442,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 72, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, 4, struct_sticksConfig, stick_name_valid),
YAML_ARRAY("switchConfig", 2, 16, struct_switchConfig, nullptr),
YAML_ARRAY("potsConfig", 2, 8, struct_potConfig, nullptr),
@@ -457,7 +457,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRUCT("themeData", 480, struct_OpenTxTheme__PersistentData, NULL),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -401,7 +401,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -414,7 +414,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -440,7 +440,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -453,7 +453,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -381,7 +381,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -392,7 +392,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 120 ),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -389,7 +389,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -402,7 +402,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -386,7 +386,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -399,7 +399,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -388,7 +388,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -403,7 +403,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_SIGNED( "gyroMax", 8 ),
YAML_SIGNED( "gyroOffset", 8 ),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {
@@ -394,7 +394,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("customFn", 88, 64, struct_CustomFunctionData, cfn_is_active),
YAML_CUSTOM("auxSerialMode",r_serialMode,nullptr),
YAML_CUSTOM("aux2SerialMode",r_serialMode,nullptr),
YAML_ARRAY("serialPort", 4, 4, struct_serialConfig, nullptr),
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("slidersConfig", 1, 4, struct_sliderConfig, nullptr),
YAML_PADDING( 4 ),
YAML_ARRAY("potsConfig", 2, 4, struct_potConfig, nullptr),
@@ -407,7 +407,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_STRING("bluetoothName", 10),
YAML_STRING("ownerRegistrationID", 8),
YAML_SIGNED( "uartSampleMode", 2 ),
YAML_PADDING( 5 ),
YAML_PADDING( 6 ),
YAML_END
};
static const struct YamlNode struct_unsigned_8[] = {