mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 17:18:54 +08:00
PX4IO Firmware: promote rssi to static storage
The controls_tick() rate exceeds the rate at which RC receivers provide digital rssi. As such, most ticks set PX4IO_P_RAW_RC_NRSSI to 0. This change promotes the controls_tick() local variable 'rssi' to static storage so that it doesn't have to be updated every tick to keep the correct value in PX4IO_P_RAW_RC_NRSSI.
This commit is contained in:
committed by
Lorenz Meier
parent
b1d3bb0403
commit
7a5a135739
@@ -72,6 +72,10 @@ static uint16_t rc_value_override = 0;
|
||||
static unsigned _rssi_adc_counts = 0;
|
||||
#endif
|
||||
|
||||
/* receive signal strenght indicator (RSSI). 0 = no connection, 100 (RC_INPUT_RSSI_MAX): perfect connection */
|
||||
/* Note: this is static because RC-provided telemetry does not occur every tick */
|
||||
static uint16_t _rssi = 0;
|
||||
|
||||
bool dsm_port_input(uint16_t *rssi, bool *dsm_updated, bool *st24_updated, bool *sumd_updated)
|
||||
{
|
||||
perf_begin(c_gather_dsm);
|
||||
@@ -209,9 +213,6 @@ controls_tick()
|
||||
* other. Don't do that.
|
||||
*/
|
||||
|
||||
/* receive signal strenght indicator (RSSI). 0 = no connection, 255: perfect connection */
|
||||
uint16_t rssi = 0;
|
||||
|
||||
#ifdef ADC_RSSI
|
||||
|
||||
if (r_setup_features & PX4IO_P_SETUP_FEATURES_ADC_RSSI) {
|
||||
@@ -223,10 +224,10 @@ controls_tick()
|
||||
/* use 1:1 scaling on 3.3V, 12-Bit ADC input */
|
||||
unsigned mV = _rssi_adc_counts * 3300 / 4095;
|
||||
/* scale to 0..100 (RC_INPUT_RSSI_MAX == 100) */
|
||||
rssi = (mV * RC_INPUT_RSSI_MAX / 3300);
|
||||
_rssi = (mV * RC_INPUT_RSSI_MAX / 3300);
|
||||
|
||||
if (rssi > RC_INPUT_RSSI_MAX) {
|
||||
rssi = RC_INPUT_RSSI_MAX;
|
||||
if (_rssi > RC_INPUT_RSSI_MAX) {
|
||||
_rssi = RC_INPUT_RSSI_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +236,7 @@ controls_tick()
|
||||
|
||||
/* zero RSSI if signal is lost */
|
||||
if (!(r_raw_rc_flags & (PX4IO_P_RAW_RC_FLAGS_RC_OK))) {
|
||||
rssi = 0;
|
||||
_rssi = 0;
|
||||
}
|
||||
|
||||
perf_begin(c_gather_sbus);
|
||||
@@ -266,7 +267,7 @@ controls_tick()
|
||||
|
||||
/* set RSSI to an emulated value if ADC RSSI is off */
|
||||
if (!(r_setup_features & PX4IO_P_SETUP_FEATURES_ADC_RSSI)) {
|
||||
rssi = sbus_rssi;
|
||||
_rssi = sbus_rssi;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -295,7 +296,7 @@ controls_tick()
|
||||
if (!((r_status_flags & PX4IO_P_STATUS_FLAGS_RC_SBUS) || (r_status_flags & PX4IO_P_STATUS_FLAGS_RC_PPM))) {
|
||||
perf_begin(c_gather_dsm);
|
||||
|
||||
(void)dsm_port_input(&rssi, &dsm_updated, &st24_updated, &sumd_updated);
|
||||
(void)dsm_port_input(&_rssi, &dsm_updated, &st24_updated, &sumd_updated);
|
||||
|
||||
if (dsm_updated) {
|
||||
PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_DSM);
|
||||
@@ -318,7 +319,7 @@ controls_tick()
|
||||
}
|
||||
|
||||
/* store RSSI */
|
||||
r_page_raw_rc_input[PX4IO_P_RAW_RC_NRSSI] = rssi;
|
||||
r_page_raw_rc_input[PX4IO_P_RAW_RC_NRSSI] = _rssi;
|
||||
|
||||
/*
|
||||
* In some cases we may have received a frame, but input has still
|
||||
|
||||
Reference in New Issue
Block a user