mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 03:19:53 +03:00
Fix
This commit is contained in:
parent
ef90933f66
commit
5ad3f95cdc
3 changed files with 24 additions and 4 deletions
|
@ -68,9 +68,13 @@ void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs)
|
||||||
mixerSchedules[moduleIdx].period = periodUs;
|
mixerSchedules[moduleIdx].period = periodUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs)
|
void mixerSchedulerClearTrigger()
|
||||||
{
|
{
|
||||||
RTOS_CLEAR_FLAG(mixerFlag);
|
RTOS_CLEAR_FLAG(mixerFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs)
|
||||||
|
{
|
||||||
return RTOS_WAIT_FLAG(mixerFlag, timeoutMs);
|
return RTOS_WAIT_FLAG(mixerFlag, timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ void mixerSchedulerResetTimer();
|
||||||
// Set the scheduling period for a given module
|
// Set the scheduling period for a given module
|
||||||
void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs);
|
void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs);
|
||||||
|
|
||||||
|
// Clear the flag before waiting
|
||||||
|
void mixerSchedulerClearTrigger();
|
||||||
|
|
||||||
// Wait for the scheduler timer to trigger
|
// Wait for the scheduler timer to trigger
|
||||||
// returns true if timeout, false otherwise
|
// returns true if timeout, false otherwise
|
||||||
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs);
|
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs);
|
||||||
|
@ -66,6 +69,7 @@ void mixerSchedulerISRTrigger();
|
||||||
#define mixerSchedulerStop()
|
#define mixerSchedulerStop()
|
||||||
#define mixerSchedulerResetTimer()
|
#define mixerSchedulerResetTimer()
|
||||||
#define mixerSchedulerSetPeriod(m,p)
|
#define mixerSchedulerSetPeriod(m,p)
|
||||||
|
#define mixerSchedulerClearTrigger()
|
||||||
|
|
||||||
static inline bool mixerSchedulerWaitForTrigger(uint8_t timeout)
|
static inline bool mixerSchedulerWaitForTrigger(uint8_t timeout)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,21 +140,33 @@ TASK_FUNCTION(mixerTask)
|
||||||
mixerSchedulerStart();
|
mixerSchedulerStart();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// clear the flag before first loop
|
||||||
|
mixerSchedulerClearTrigger();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (int timeout = 0; timeout < MIXER_MAX_PERIOD; timeout += MIXER_FREQUENT_ACTIONS_PERIOD) {
|
int timeout = 0;
|
||||||
bool interruptedByTimeout = mixerSchedulerWaitForTrigger(MIXER_FREQUENT_ACTIONS_PERIOD);
|
for (; timeout < MIXER_MAX_PERIOD; timeout += MIXER_FREQUENT_ACTIONS_PERIOD) {
|
||||||
|
|
||||||
|
// run periodicals before waiting for the trigger
|
||||||
|
// to keep the delay short
|
||||||
execMixerFrequentActions();
|
execMixerFrequentActions();
|
||||||
if (!interruptedByTimeout) {
|
|
||||||
|
// mixer flag triggered?
|
||||||
|
if (!mixerSchedulerWaitForTrigger(MIXER_FREQUENT_ACTIONS_PERIOD)) {
|
||||||
break;
|
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);
|
||||||
GPIO_ResetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN);
|
GPIO_ResetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PCBSKY9X)
|
#if !defined(PCBSKY9X)
|
||||||
|
// clear the flag ASAP to avoid missing a tick
|
||||||
|
mixerSchedulerClearTrigger();
|
||||||
|
|
||||||
// re-enable trigger
|
// re-enable trigger
|
||||||
mixerSchedulerEnableTrigger();
|
mixerSchedulerEnableTrigger();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue