Added failsafe, serial, telemetry, ppm, and pwm config() macros
This commit is contained in:
parent
c175d304c2
commit
086d1f731e
|
@ -84,6 +84,11 @@
|
|||
#define armingConfig(x) (&masterConfig.armingConfig)
|
||||
#define mixerConfig(x) (&masterConfig.mixerConfig)
|
||||
#define airplaneConfig(x) (&masterConfig.airplaneConfig)
|
||||
#define failsafeConfig(x) (&masterConfig.failsafeConfig)
|
||||
#define serialConfig(x) (&masterConfig.serialConfig)
|
||||
#define telemetryConfig(x) (&masterConfig.telemetryConfig)
|
||||
#define ppmConfig(x) (&masterConfig.ppmConfig)
|
||||
#define pwmConfig(x) (&masterConfig.pwmConfig)
|
||||
|
||||
|
||||
// System-wide
|
||||
|
|
|
@ -965,7 +965,7 @@ void validateAndFixConfig(void)
|
|||
#endif
|
||||
|
||||
#if defined(COLIBRI_RACE)
|
||||
masterConfig.serialConfig.portConfigs[0].functionMask = FUNCTION_MSP;
|
||||
serialConfig()->portConfigs[0].functionMask = FUNCTION_MSP;
|
||||
if (featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureConfigured(FEATURE_RX_MSP)) {
|
||||
featureClear(FEATURE_RX_PARALLEL_PWM);
|
||||
featureClear(FEATURE_RX_MSP);
|
||||
|
|
|
@ -350,7 +350,7 @@ void initActiveBoxIds(void)
|
|||
}
|
||||
|
||||
#ifdef TELEMETRY
|
||||
if (feature(FEATURE_TELEMETRY) && masterConfig.telemetryConfig.telemetry_switch) {
|
||||
if (feature(FEATURE_TELEMETRY) && telemetryConfig()->telemetry_switch) {
|
||||
activeBoxIds[activeBoxIdCount++] = BOXTELEMETRY;
|
||||
}
|
||||
#endif
|
||||
|
@ -782,7 +782,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
sbufWriteU16(dst, motorConfig()->maxthrottle);
|
||||
sbufWriteU16(dst, motorConfig()->mincommand);
|
||||
|
||||
sbufWriteU16(dst, masterConfig.failsafeConfig.failsafe_throttle);
|
||||
sbufWriteU16(dst, failsafeConfig()->failsafe_throttle);
|
||||
|
||||
#ifdef GPS
|
||||
sbufWriteU8(dst, gpsConfig()->provider); // gps_type
|
||||
|
@ -906,12 +906,12 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
break;
|
||||
|
||||
case MSP_FAILSAFE_CONFIG:
|
||||
sbufWriteU8(dst, masterConfig.failsafeConfig.failsafe_delay);
|
||||
sbufWriteU8(dst, masterConfig.failsafeConfig.failsafe_off_delay);
|
||||
sbufWriteU16(dst, masterConfig.failsafeConfig.failsafe_throttle);
|
||||
sbufWriteU8(dst, masterConfig.failsafeConfig.failsafe_kill_switch);
|
||||
sbufWriteU16(dst, masterConfig.failsafeConfig.failsafe_throttle_low_delay);
|
||||
sbufWriteU8(dst, masterConfig.failsafeConfig.failsafe_procedure);
|
||||
sbufWriteU8(dst, failsafeConfig()->failsafe_delay);
|
||||
sbufWriteU8(dst, failsafeConfig()->failsafe_off_delay);
|
||||
sbufWriteU16(dst, failsafeConfig()->failsafe_throttle);
|
||||
sbufWriteU8(dst, failsafeConfig()->failsafe_kill_switch);
|
||||
sbufWriteU16(dst, failsafeConfig()->failsafe_throttle_low_delay);
|
||||
sbufWriteU8(dst, failsafeConfig()->failsafe_procedure);
|
||||
break;
|
||||
|
||||
case MSP_RXFAIL_CONFIG:
|
||||
|
@ -948,15 +948,15 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
|
||||
case MSP_CF_SERIAL_CONFIG:
|
||||
for (int i = 0; i < SERIAL_PORT_COUNT; i++) {
|
||||
if (!serialIsPortAvailable(masterConfig.serialConfig.portConfigs[i].identifier)) {
|
||||
if (!serialIsPortAvailable(serialConfig()->portConfigs[i].identifier)) {
|
||||
continue;
|
||||
};
|
||||
sbufWriteU8(dst, masterConfig.serialConfig.portConfigs[i].identifier);
|
||||
sbufWriteU16(dst, masterConfig.serialConfig.portConfigs[i].functionMask);
|
||||
sbufWriteU8(dst, masterConfig.serialConfig.portConfigs[i].msp_baudrateIndex);
|
||||
sbufWriteU8(dst, masterConfig.serialConfig.portConfigs[i].gps_baudrateIndex);
|
||||
sbufWriteU8(dst, masterConfig.serialConfig.portConfigs[i].telemetry_baudrateIndex);
|
||||
sbufWriteU8(dst, masterConfig.serialConfig.portConfigs[i].blackbox_baudrateIndex);
|
||||
sbufWriteU8(dst, serialConfig()->portConfigs[i].identifier);
|
||||
sbufWriteU16(dst, serialConfig()->portConfigs[i].functionMask);
|
||||
sbufWriteU8(dst, serialConfig()->portConfigs[i].msp_baudrateIndex);
|
||||
sbufWriteU8(dst, serialConfig()->portConfigs[i].gps_baudrateIndex);
|
||||
sbufWriteU8(dst, serialConfig()->portConfigs[i].telemetry_baudrateIndex);
|
||||
sbufWriteU8(dst, serialConfig()->portConfigs[i].blackbox_baudrateIndex);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
motorConfig()->maxthrottle = sbufReadU16(src);
|
||||
motorConfig()->mincommand = sbufReadU16(src);
|
||||
|
||||
masterConfig.failsafeConfig.failsafe_throttle = sbufReadU16(src);
|
||||
failsafeConfig()->failsafe_throttle = sbufReadU16(src);
|
||||
|
||||
#ifdef GPS
|
||||
gpsConfig()->provider = sbufReadU8(src); // gps_type
|
||||
|
@ -1691,12 +1691,12 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
break;
|
||||
|
||||
case MSP_SET_FAILSAFE_CONFIG:
|
||||
masterConfig.failsafeConfig.failsafe_delay = sbufReadU8(src);
|
||||
masterConfig.failsafeConfig.failsafe_off_delay = sbufReadU8(src);
|
||||
masterConfig.failsafeConfig.failsafe_throttle = sbufReadU16(src);
|
||||
masterConfig.failsafeConfig.failsafe_kill_switch = sbufReadU8(src);
|
||||
masterConfig.failsafeConfig.failsafe_throttle_low_delay = sbufReadU16(src);
|
||||
masterConfig.failsafeConfig.failsafe_procedure = sbufReadU8(src);
|
||||
failsafeConfig()->failsafe_delay = sbufReadU8(src);
|
||||
failsafeConfig()->failsafe_off_delay = sbufReadU8(src);
|
||||
failsafeConfig()->failsafe_throttle = sbufReadU16(src);
|
||||
failsafeConfig()->failsafe_kill_switch = sbufReadU8(src);
|
||||
failsafeConfig()->failsafe_throttle_low_delay = sbufReadU16(src);
|
||||
failsafeConfig()->failsafe_procedure = sbufReadU8(src);
|
||||
break;
|
||||
|
||||
case MSP_SET_RXFAIL_CONFIG:
|
||||
|
|
|
@ -665,8 +665,8 @@ void processRx(uint32_t currentTime)
|
|||
|
||||
#ifdef TELEMETRY
|
||||
if (feature(FEATURE_TELEMETRY)) {
|
||||
if ((!masterConfig.telemetryConfig.telemetry_switch && ARMING_FLAG(ARMED)) ||
|
||||
(masterConfig.telemetryConfig.telemetry_switch && IS_RC_MODE_ACTIVE(BOXTELEMETRY))) {
|
||||
if ((!telemetryConfig()->telemetry_switch && ARMING_FLAG(ARMED)) ||
|
||||
(telemetryConfig()->telemetry_switch && IS_RC_MODE_ACTIVE(BOXTELEMETRY))) {
|
||||
|
||||
releaseSharedTelemetryPorts();
|
||||
} else {
|
||||
|
|
|
@ -723,7 +723,7 @@ const clivalue_t valueTable[] = {
|
|||
|
||||
{ "fixedwing_althold_dir", VAR_INT8 | MASTER_VALUE, &airplaneConfig()->fixedwing_althold_dir, .config.minmax = { -1, 1 } },
|
||||
|
||||
{ "reboot_character", VAR_UINT8 | MASTER_VALUE, &masterConfig.serialConfig.reboot_character, .config.minmax = { 48, 126 } },
|
||||
{ "reboot_character", VAR_UINT8 | MASTER_VALUE, &serialConfig()->reboot_character, .config.minmax = { 48, 126 } },
|
||||
|
||||
#ifdef GPS
|
||||
{ "gps_provider", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &gpsConfig()->provider, .config.lookup = { TABLE_GPS_PROVIDER } },
|
||||
|
@ -776,16 +776,16 @@ const clivalue_t valueTable[] = {
|
|||
#endif
|
||||
|
||||
#ifdef TELEMETRY
|
||||
{ "telemetry_switch", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.telemetry_switch, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "telemetry_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.telemetry_inversion, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "frsky_default_lattitude", VAR_FLOAT | MASTER_VALUE, &masterConfig.telemetryConfig.gpsNoFixLatitude, .config.minmax = { -90.0, 90.0 } },
|
||||
{ "frsky_default_longitude", VAR_FLOAT | MASTER_VALUE, &masterConfig.telemetryConfig.gpsNoFixLongitude, .config.minmax = { -180.0, 180.0 } },
|
||||
{ "frsky_coordinates_format", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_coordinate_format, .config.minmax = { 0, FRSKY_FORMAT_NMEA } },
|
||||
{ "frsky_unit", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.frsky_unit, .config.lookup = { TABLE_UNIT } },
|
||||
{ "frsky_vfas_precision", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_vfas_precision, .config.minmax = { FRSKY_VFAS_PRECISION_LOW, FRSKY_VFAS_PRECISION_HIGH } },
|
||||
{ "frsky_vfas_cell_voltage", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.frsky_vfas_cell_voltage, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "hott_alarm_sound_interval", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.hottAlarmSoundInterval, .config.minmax = { 0, 120 } },
|
||||
{ "pid_values_as_telemetry", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.pidValuesAsTelemetry, .config.lookup = {TABLE_OFF_ON } },
|
||||
{ "telemetry_switch", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &telemetryConfig()->telemetry_switch, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "telemetry_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &telemetryConfig()->telemetry_inversion, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "frsky_default_lattitude", VAR_FLOAT | MASTER_VALUE, &telemetryConfig()->gpsNoFixLatitude, .config.minmax = { -90.0, 90.0 } },
|
||||
{ "frsky_default_longitude", VAR_FLOAT | MASTER_VALUE, &telemetryConfig()->gpsNoFixLongitude, .config.minmax = { -180.0, 180.0 } },
|
||||
{ "frsky_coordinates_format", VAR_UINT8 | MASTER_VALUE, &telemetryConfig()->frsky_coordinate_format, .config.minmax = { 0, FRSKY_FORMAT_NMEA } },
|
||||
{ "frsky_unit", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &telemetryConfig()->frsky_unit, .config.lookup = { TABLE_UNIT } },
|
||||
{ "frsky_vfas_precision", VAR_UINT8 | MASTER_VALUE, &telemetryConfig()->frsky_vfas_precision, .config.minmax = { FRSKY_VFAS_PRECISION_LOW, FRSKY_VFAS_PRECISION_HIGH } },
|
||||
{ "frsky_vfas_cell_voltage", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &telemetryConfig()->frsky_vfas_cell_voltage, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "hott_alarm_sound_interval", VAR_UINT8 | MASTER_VALUE, &telemetryConfig()->hottAlarmSoundInterval, .config.minmax = { 0, 120 } },
|
||||
{ "pid_values_as_telemetry", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &telemetryConfig()->pidValuesAsTelemetry, .config.lookup = {TABLE_OFF_ON } },
|
||||
#endif
|
||||
|
||||
{ "battery_capacity", VAR_UINT16 | MASTER_VALUE, &batteryConfig()->batteryCapacity, .config.minmax = { 0, 20000 } },
|
||||
|
@ -858,12 +858,12 @@ const clivalue_t valueTable[] = {
|
|||
{ "tpa_breakpoint", VAR_UINT16 | PROFILE_RATE_VALUE, &masterConfig.profile[0].controlRateProfile[0].tpa_breakpoint, .config.minmax = { PWM_RANGE_MIN, PWM_RANGE_MAX} },
|
||||
{ "airmode_activate_throttle", VAR_UINT16 | MASTER_VALUE, &rxConfig()->airModeActivateThreshold, .config.minmax = {1000, 2000 } },
|
||||
|
||||
{ "failsafe_delay", VAR_UINT8 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_delay, .config.minmax = { 0, 200 } },
|
||||
{ "failsafe_off_delay", VAR_UINT8 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_off_delay, .config.minmax = { 0, 200 } },
|
||||
{ "failsafe_throttle", VAR_UINT16 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_throttle, .config.minmax = { PWM_RANGE_MIN, PWM_RANGE_MAX } },
|
||||
{ "failsafe_kill_switch", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.failsafeConfig.failsafe_kill_switch, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "failsafe_throttle_low_delay",VAR_UINT16 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_throttle_low_delay, .config.minmax = { 0, 300 } },
|
||||
{ "failsafe_procedure", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.failsafeConfig.failsafe_procedure, .config.lookup = { TABLE_FAILSAFE } },
|
||||
{ "failsafe_delay", VAR_UINT8 | MASTER_VALUE, &failsafeConfig()->failsafe_delay, .config.minmax = { 0, 200 } },
|
||||
{ "failsafe_off_delay", VAR_UINT8 | MASTER_VALUE, &failsafeConfig()->failsafe_off_delay, .config.minmax = { 0, 200 } },
|
||||
{ "failsafe_throttle", VAR_UINT16 | MASTER_VALUE, &failsafeConfig()->failsafe_throttle, .config.minmax = { PWM_RANGE_MIN, PWM_RANGE_MAX } },
|
||||
{ "failsafe_kill_switch", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &failsafeConfig()->failsafe_kill_switch, .config.lookup = { TABLE_OFF_ON } },
|
||||
{ "failsafe_throttle_low_delay",VAR_UINT16 | MASTER_VALUE, &failsafeConfig()->failsafe_throttle_low_delay, .config.minmax = { 0, 300 } },
|
||||
{ "failsafe_procedure", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &failsafeConfig()->failsafe_procedure, .config.lookup = { TABLE_FAILSAFE } },
|
||||
|
||||
{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, &rxConfig()->rx_min_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } },
|
||||
{ "rx_max_usec", VAR_UINT16 | MASTER_VALUE, &rxConfig()->rx_max_usec, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX } },
|
||||
|
@ -3795,8 +3795,8 @@ const cliResourceValue_t resourceTable[] = {
|
|||
{ OWNER_SERVO, &servoConfig()->ioTags[0], MAX_SUPPORTED_SERVOS },
|
||||
#endif
|
||||
#if defined(USE_PWM) || defined(USE_PPM)
|
||||
{ OWNER_PPMINPUT, &masterConfig.ppmConfig.ioTag, 0 },
|
||||
{ OWNER_PWMINPUT, &masterConfig.pwmConfig.ioTags[0], PWM_INPUT_PORT_COUNT },
|
||||
{ OWNER_PPMINPUT, &ppmConfig()->ioTag, 0 },
|
||||
{ OWNER_PWMINPUT, &pwmConfig()->ioTags[0], PWM_INPUT_PORT_COUNT },
|
||||
#endif
|
||||
#ifdef SONAR
|
||||
{ OWNER_SONAR_TRIGGER, &masterConfig.sonarConfig.triggerTag, 0 },
|
||||
|
|
|
@ -755,7 +755,7 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
bstWrite16(motorConfig()->maxthrottle);
|
||||
bstWrite16(motorConfig()->mincommand);
|
||||
|
||||
bstWrite16(masterConfig.failsafeConfig.failsafe_throttle);
|
||||
bstWrite16(failsafeConfig()->failsafe_throttle);
|
||||
|
||||
#ifdef GPS
|
||||
bstWrite8(gpsConfig()->provider); // gps_type
|
||||
|
@ -883,9 +883,9 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
break;
|
||||
|
||||
case BST_FAILSAFE_CONFIG:
|
||||
bstWrite8(masterConfig.failsafeConfig.failsafe_delay);
|
||||
bstWrite8(masterConfig.failsafeConfig.failsafe_off_delay);
|
||||
bstWrite16(masterConfig.failsafeConfig.failsafe_throttle);
|
||||
bstWrite8(failsafeConfig()->failsafe_delay);
|
||||
bstWrite8(failsafeConfig()->failsafe_off_delay);
|
||||
bstWrite16(failsafeConfig()->failsafe_throttle);
|
||||
break;
|
||||
|
||||
case BST_RXFAIL_CONFIG:
|
||||
|
@ -921,15 +921,15 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
|
|||
|
||||
case BST_CF_SERIAL_CONFIG:
|
||||
for (i = 0; i < SERIAL_PORT_COUNT; i++) {
|
||||
if (!serialIsPortAvailable(masterConfig.serialConfig.portConfigs[i].identifier)) {
|
||||
if (!serialIsPortAvailable(serialConfig()->portConfigs[i].identifier)) {
|
||||
continue;
|
||||
};
|
||||
bstWrite8(masterConfig.serialConfig.portConfigs[i].identifier);
|
||||
bstWrite16(masterConfig.serialConfig.portConfigs[i].functionMask);
|
||||
bstWrite8(masterConfig.serialConfig.portConfigs[i].msp_baudrateIndex);
|
||||
bstWrite8(masterConfig.serialConfig.portConfigs[i].gps_baudrateIndex);
|
||||
bstWrite8(masterConfig.serialConfig.portConfigs[i].telemetry_baudrateIndex);
|
||||
bstWrite8(masterConfig.serialConfig.portConfigs[i].blackbox_baudrateIndex);
|
||||
bstWrite8(serialConfig()->portConfigs[i].identifier);
|
||||
bstWrite16(serialConfig()->portConfigs[i].functionMask);
|
||||
bstWrite8(serialConfig()->portConfigs[i].msp_baudrateIndex);
|
||||
bstWrite8(serialConfig()->portConfigs[i].gps_baudrateIndex);
|
||||
bstWrite8(serialConfig()->portConfigs[i].telemetry_baudrateIndex);
|
||||
bstWrite8(serialConfig()->portConfigs[i].blackbox_baudrateIndex);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
motorConfig()->maxthrottle = bstRead16();
|
||||
motorConfig()->mincommand = bstRead16();
|
||||
|
||||
masterConfig.failsafeConfig.failsafe_throttle = bstRead16();
|
||||
failsafeConfig()->failsafe_throttle = bstRead16();
|
||||
|
||||
#ifdef GPS
|
||||
gpsConfig()->provider = bstRead8(); // gps_type
|
||||
|
@ -1290,9 +1290,9 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
|
|||
}
|
||||
break;
|
||||
case BST_SET_FAILSAFE_CONFIG:
|
||||
masterConfig.failsafeConfig.failsafe_delay = bstRead8();
|
||||
masterConfig.failsafeConfig.failsafe_off_delay = bstRead8();
|
||||
masterConfig.failsafeConfig.failsafe_throttle = bstRead16();
|
||||
failsafeConfig()->failsafe_delay = bstRead8();
|
||||
failsafeConfig()->failsafe_off_delay = bstRead8();
|
||||
failsafeConfig()->failsafe_throttle = bstRead16();
|
||||
break;
|
||||
case BST_SET_RXFAIL_CONFIG:
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue