mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Fix issues impacting RX_STATE_MODES state duration and add DEBUG_RX_STATE_TIME
This commit is contained in:
parent
8d52a36150
commit
c05ad2ec9b
7 changed files with 31 additions and 2 deletions
|
@ -182,9 +182,10 @@ bool taskUpdateRxMainInProgress()
|
|||
|
||||
static void taskUpdateRxMain(timeUs_t currentTimeUs)
|
||||
{
|
||||
static timeUs_t rxStateDurationFracUs[RX_STATE_COUNT];
|
||||
timeUs_t executeTimeUs;
|
||||
static timeDelta_t rxStateDurationFracUs[RX_STATE_COUNT];
|
||||
timeDelta_t executeTimeUs;
|
||||
rxState_e oldRxState = rxState;
|
||||
timeDelta_t anticipatedExecutionTime;
|
||||
|
||||
// Where we are using a state machine call schedulerIgnoreTaskExecRate() for all states bar one
|
||||
if (rxState != RX_STATE_UPDATE) {
|
||||
|
@ -230,6 +231,12 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
|
|||
|
||||
executeTimeUs = micros() - currentTimeUs + RX_TASK_MARGIN;
|
||||
|
||||
// If the scheduler has reduced the anticipatedExecutionTime due to task aging, pick that up
|
||||
anticipatedExecutionTime = schedulerGetNextStateTime();
|
||||
if (anticipatedExecutionTime != (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
|
||||
rxStateDurationFracUs[oldRxState] = anticipatedExecutionTime << RX_TASK_DECAY_SHIFT;
|
||||
}
|
||||
|
||||
if (executeTimeUs > (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
|
||||
rxStateDurationFracUs[oldRxState] = executeTimeUs << RX_TASK_DECAY_SHIFT;
|
||||
} else {
|
||||
|
@ -237,6 +244,10 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
|
|||
rxStateDurationFracUs[oldRxState]--;
|
||||
}
|
||||
|
||||
if (debugMode == DEBUG_RX_STATE_TIME) {
|
||||
debug[oldRxState] = rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT;
|
||||
}
|
||||
|
||||
schedulerSetNextStateTime(rxStateDurationFracUs[rxState] >> RX_TASK_DECAY_SHIFT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue