moved sync pulse sending to *before* periodic mixer processing

This should enable a more stable pulse sending to the module.
This commit is contained in:
Raphael Coeffic
2020-12-09 07:24:27 +01:00
parent ef3b669d38
commit 92f27a853a
3 changed files with 22 additions and 3 deletions
+13
View File
@@ -1426,6 +1426,19 @@ void doMixerCalculations()
DEBUG_TIMER_START(debugTimerEvalMixes);
evalMixes(tick10ms);
DEBUG_TIMER_STOP(debugTimerEvalMixes);
}
void doMixerPeriodicUpdates()
{
static tmr10ms_t lastTMR = 0;
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
// handle tick10ms overrun
// correct overflow handling costs a lot of code; happens only each 11 min;
// therefore forget the exact calculation and use only 1 instead; good compromise
lastTMR = tmr10ms;
DEBUG_TIMER_START(debugTimerMixes10ms);
if (tick10ms) {
+1
View File
@@ -483,6 +483,7 @@ extern uint32_t nextMixerTime[NUM_MODULES];
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms);
void evalMixes(uint8_t tick10ms);
void doMixerCalculations();
void doMixerPeriodicUpdates();
void checkTrims();
extern uint8_t currentBacklightBright;
+8 -3
View File
@@ -168,12 +168,20 @@ TASK_FUNCTION(mixerTask)
DEBUG_TIMER_START(debugTimerMixer);
RTOS_LOCK_MUTEX(mixerMutex);
doMixerCalculations();
// TODO: fix runMask
sendSynchronousPulses((1 << INTERNAL_MODULE) | (1 << EXTERNAL_MODULE));
doMixerPeriodicUpdates();
DEBUG_TIMER_START(debugTimerMixerCalcToUsage);
DEBUG_TIMER_SAMPLE(debugTimerMixerIterval);
RTOS_UNLOCK_MUTEX(mixerMutex);
DEBUG_TIMER_STOP(debugTimerMixer);
#if defined(STM32) && !defined(SIMU)
if (getSelectedUsbMode() == USB_JOYSTICK_MODE) {
usbJoystickUpdate();
@@ -202,9 +210,6 @@ TASK_FUNCTION(mixerTask)
// between protocols with multi-proto RF
if (timeout)
serialPrint("mix sched timeout!");
// TODO: fix runMask
sendSynchronousPulses((1 << INTERNAL_MODULE) | (1 << EXTERNAL_MODULE));
}
}
}