Merge pull request #8474 from opentx/3djc/fix-sbus-trainer

Run some task more frequently
This commit is contained in:
Bertrand Songis
2021-05-05 14:52:11 +02:00
committed by GitHub
+23 -16
View File
@@ -110,18 +110,11 @@ void sendSynchronousPulses(uint8_t runMask)
#endif #endif
} }
uint32_t nextMixerTime[NUM_MODULES]; constexpr uint8_t MIXER_FREQUENT_ACTIONS_PERIOD = 5 /*ms*/;
constexpr uint8_t MIXER_MAX_PERIOD = 30 /*ms*/;
TASK_FUNCTION(mixerTask) void execMixerFrequentActions()
{ {
s_pulses_paused = true;
mixerSchedulerInit();
#if !defined(PCBSKY9X)
mixerSchedulerStart();
#endif
while (true) {
#if defined(SBUS_TRAINER) #if defined(SBUS_TRAINER)
// SBUS trainer // SBUS trainer
processSbusInput(); processSbusInput();
@@ -134,9 +127,27 @@ TASK_FUNCTION(mixerTask)
#if defined(BLUETOOTH) #if defined(BLUETOOTH)
bluetooth.wakeup(); bluetooth.wakeup();
#endif #endif
}
// run mixer at least every 30ms uint32_t nextMixerTime[NUM_MODULES];
bool timeout = mixerSchedulerWaitForTrigger(30);
TASK_FUNCTION(mixerTask)
{
s_pulses_paused = true;
mixerSchedulerInit();
#if !defined(PCBSKY9X)
mixerSchedulerStart();
#endif
while (true) {
for (int timeout = 0; timeout < MIXER_MAX_PERIOD; timeout += MIXER_FREQUENT_ACTIONS_PERIOD) {
bool interruptedByTimeout = mixerSchedulerWaitForTrigger(MIXER_FREQUENT_ACTIONS_PERIOD);
execMixerFrequentActions();
if (!interruptedByTimeout) {
break;
}
}
#if defined(DEBUG_MIXER_SCHEDULER) #if defined(DEBUG_MIXER_SCHEDULER)
GPIO_SetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN); GPIO_SetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN);
@@ -205,10 +216,6 @@ TASK_FUNCTION(mixerTask)
// TODO: // TODO:
// - check the cause of timeouts when switching // - check the cause of timeouts when switching
// between protocols with multi-proto RF // between protocols with multi-proto RF
#if defined(DEBUG)
if (timeout)
serialPrint("mix sched timeout!");
#endif
} }
} }
} }