From 847e050955fb1dfcef7f8021c38abae8efbf73bb Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 20 May 2018 00:55:07 +1200 Subject: [PATCH] Reorganised static variables in SmartPort code. --- src/main/telemetry/smartport.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index c12b20bc3..aca287780 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -455,6 +455,13 @@ static void smartPortSendMspResponse(uint8_t *data) { void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clearToSend, const uint32_t *requestTimeout) { + static uint8_t smartPortIdCycleCnt = 0; + static uint8_t t1Cnt = 0; + static uint8_t t2Cnt = 0; +#ifdef USE_ESC_SENSOR + static uint8_t smartPortIdOffset = 0; +#endif + if (payload) { // do not check the physical ID here again // unless we start receiving other sensors' packets @@ -493,14 +500,12 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear // we can send back any data we want, our tables keep track of the order and frequency of each data type we send frSkyTableInfo_t * tableInfo = &frSkyDataIdTableInfo; - static uint8_t smartPortIdCycleCnt = 0; if (smartPortIdCycleCnt % SENSOR_REST_PERIOD == 0) { smartPortIdCycleCnt++; return; } #ifdef USE_ESC_SENSOR - static uint8_t smartPortIdOffset = 0; if (smartPortIdCycleCnt >= ESC_SENSOR_PERIOD) { // send ESC sensors tableInfo = &frSkyEscDataIdTableInfo; @@ -534,8 +539,6 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear int32_t tmpi; uint32_t tmp2 = 0; - static uint8_t t1Cnt = 0; - static uint8_t t2Cnt = 0; uint16_t vfasVoltage; uint8_t cellCount;