diff --git a/src/main/drivers/rx/rx_cc2500.c b/src/main/drivers/rx/rx_cc2500.c index 5f8e6a20a9..487b2eb780 100644 --- a/src/main/drivers/rx/rx_cc2500.c +++ b/src/main/drivers/rx/rx_cc2500.c @@ -50,20 +50,12 @@ void cc2500ReadFifo(uint8_t *dpbuffer, uint8_t len) void cc2500WriteCommand(uint8_t command, uint8_t data) { - // Burst writes require an interbyte gap, see fig. 7, pg. 22 in https://www.ti.com/lit/ds/symlink/cc2500.pdf - // As such gaps can't be inserted if DMA is being used, inhibit DMA on this bus for the duration of this call - rxSpiDmaEnable(false); rxSpiWriteCommand(command, data); - rxSpiDmaEnable(true); } void cc2500WriteCommandMulti(uint8_t command, const uint8_t *data, uint8_t length) { - // Burst writes require an interbyte gap, see fig. 7, pg. 22 in https://www.ti.com/lit/ds/symlink/cc2500.pdf - // As such gaps can't be inserted if DMA is being used, inhibit DMA on this bus for the duration of this call - rxSpiDmaEnable(false); rxSpiWriteCommandMulti(command, data, length); - rxSpiDmaEnable(true); } void cc2500WriteFifo(uint8_t *dpbuffer, uint8_t len) @@ -116,6 +108,10 @@ void cc2500SetPower(uint8_t power) uint8_t cc2500Reset(void) { + // Writes require an interbyte gap, see fig. 7, pg. 22 in https://www.ti.com/lit/ds/symlink/cc2500.pdf + // As such gaps can't be inserted if DMA is being used, inhibit DMA for this device + rxSpiDmaEnable(false); + cc2500Strobe(CC2500_SRES); delayMicroseconds(1000); // 1000us // CC2500_SetTxRxMode(TXRX_OFF); diff --git a/src/main/fc/core.c b/src/main/fc/core.c index 4eb9957ced..c6b36d749b 100644 --- a/src/main/fc/core.c +++ b/src/main/fc/core.c @@ -1262,14 +1262,6 @@ FAST_CODE bool pidLoopReady(void) return false; } -FAST_CODE bool rxFrameReady(void) -{ - if ((activePidLoopDenom == 1) || (pidUpdateCounter % activePidLoopDenom == 0)) { - return true; - } - return false; -} - FAST_CODE void taskFiltering(timeUs_t currentTimeUs) { gyroFiltering(currentTimeUs); diff --git a/src/main/fc/core.h b/src/main/fc/core.h index 32ca92c674..d955dfbe28 100644 --- a/src/main/fc/core.h +++ b/src/main/fc/core.h @@ -82,7 +82,6 @@ void updateArmingStatus(void); void taskGyroSample(timeUs_t currentTimeUs); bool gyroFilterReady(void); bool pidLoopReady(void); -bool rxFrameReady(void); void taskFiltering(timeUs_t currentTimeUs); void taskMainPidLoop(timeUs_t currentTimeUs); diff --git a/src/main/rx/cc2500_frsky_shared.c b/src/main/rx/cc2500_frsky_shared.c index 14a02c665d..2ff2d5b5d0 100644 --- a/src/main/rx/cc2500_frsky_shared.c +++ b/src/main/rx/cc2500_frsky_shared.c @@ -435,6 +435,8 @@ rx_spi_received_e frSkySpiDataReceived(uint8_t *packet) protocolState = STATE_STARTING; break; + + case STATE_STARTING: default: ret = handlePacket(packet, &protocolState); diff --git a/src/main/scheduler/scheduler.c b/src/main/scheduler/scheduler.c index 01c68f54a9..fba208b605 100644 --- a/src/main/scheduler/scheduler.c +++ b/src/main/scheduler/scheduler.c @@ -503,13 +503,13 @@ FAST_CODE void scheduler(void) if (pidLoopReady()) { taskExecutionTimeUs += schedulerExecuteTask(getTask(TASK_PID), currentTimeUs); } - if (rxFrameReady()) { - // Check for incoming RX data. Don't do this in the checker as that is called repeatedly within - // a given gyro loop, and ELRS takes a long time to process this and so can only be safely processed - // before the checkers - rxFrameCheck(currentTimeUs, cmpTimeUs(currentTimeUs, getTask(TASK_RX)->lastExecutedAtUs)); - } - // Check for failsafe conditions every 10ms, independently of the Rx Task, which runs at 33hz. + + // Check for incoming RX data. Don't do this in the checker as that is called repeatedly within + // a given gyro loop, and ELRS takes a long time to process this and so can only be safely processed + // before the checkers + rxFrameCheck(currentTimeUs, cmpTimeUs(currentTimeUs, getTask(TASK_RX)->lastExecutedAtUs)); + + // Check for failsafe conditions without reliance on the RX task being well behaved if (cmp32(millis(), lastFailsafeCheckMs) > PERIOD_RXDATA_FAILURE) { // This is very low cost taking less that 4us every 10ms failsafeCheckDataFailurePeriod(); diff --git a/src/test/unit/scheduler_unittest.cc b/src/test/unit/scheduler_unittest.cc index aea553e027..f820132d66 100644 --- a/src/test/unit/scheduler_unittest.cc +++ b/src/test/unit/scheduler_unittest.cc @@ -67,7 +67,6 @@ extern "C" { int16_t debug[1]; uint8_t debugMode = 0; - bool rxFrameReady(void) { return 0; } void rxFrameCheck(timeUs_t, timeDelta_t) {} // set up micros() to simulate time