diff --git a/src/rx/crsf.c b/src/rx/crsf.c index 87bba7617..21faebdab 100644 --- a/src/rx/crsf.c +++ b/src/rx/crsf.c @@ -6,6 +6,8 @@ #include "flight/control.h" #include "util/crc.h" +crsf_stats_t crsf_stats; + void crsf_tlm_frame_start(uint8_t *buf) { buf[0] = CRSF_SYNC_BYTE; } diff --git a/src/rx/crsf.h b/src/rx/crsf.h index 67198280c..23e71bb2c 100644 --- a/src/rx/crsf.h +++ b/src/rx/crsf.h @@ -129,6 +129,8 @@ typedef union { crsf_frame_def_t frame; } crsf_frame_t; +extern crsf_stats_t crsf_stats; + uint8_t crsf_crc8(uint8_t *data, uint16_t len); void crsf_tlm_frame_start(uint8_t *buf); diff --git a/src/rx/unified_crsf.c b/src/rx/unified_crsf.c index 1fd40d20a..d10ff0ed3 100644 --- a/src/rx/unified_crsf.c +++ b/src/rx/unified_crsf.c @@ -48,7 +48,6 @@ extern int32_t channels[16]; extern uint8_t rx_data[RX_BUFF_SIZE]; static uint8_t telemetry_counter = 0; -static uint8_t crsf_rf_mode = 0; void rx_serial_crsf_msp_send(msp_magic_t magic, uint8_t direction, uint16_t code, const uint8_t *data, uint16_t len); @@ -70,7 +69,7 @@ static bool msp_new_data = false; static bool msp_is_error = false; float rx_serial_crsf_expected_fps() { - switch (crsf_rf_mode) { + switch (crsf_stats.rf_mode) { case RATE_FLRC_1000HZ: return 1000; case RATE_FLRC_500HZ: @@ -104,7 +103,7 @@ float rx_serial_crsf_expected_fps() { } static uint16_t telemetry_interval() { - switch (crsf_rf_mode) { + switch (crsf_stats.rf_mode) { case RATE_LORA_4HZ: return 3; case RATE_LORA_25HZ: @@ -190,12 +189,10 @@ static packet_status_t rx_serial_crsf_process_frame(uint8_t frame_length) { } case CRSF_FRAMETYPE_LINK_STATISTICS: { - const crsf_stats_t *stats = (crsf_stats_t *)&rx_data[1]; - - crsf_rf_mode = stats->rf_mode; + memcpy(&crsf_stats, &rx_data[1], sizeof(crsf_stats)); if (profile.receiver.lqi_source == RX_LQI_SOURCE_DIRECT) { - rx_lqi_update_direct(stats->uplink_link_quality); + rx_lqi_update_direct(crsf_stats.uplink_link_quality); } break; }