Improved sync
This commit is contained in:
@@ -68,9 +68,13 @@ void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs)
|
||||
mixerSchedules[moduleIdx].period = periodUs;
|
||||
}
|
||||
|
||||
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs)
|
||||
void mixerSchedulerClearTrigger()
|
||||
{
|
||||
RTOS_CLEAR_FLAG(mixerFlag);
|
||||
}
|
||||
|
||||
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs)
|
||||
{
|
||||
return RTOS_WAIT_FLAG(mixerFlag, timeoutMs);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ void mixerSchedulerResetTimer();
|
||||
// Set the scheduling period for a given module
|
||||
void mixerSchedulerSetPeriod(uint8_t moduleIdx, uint16_t periodUs);
|
||||
|
||||
// Clear the flag before waiting
|
||||
void mixerSchedulerClearTrigger();
|
||||
|
||||
// Wait for the scheduler timer to trigger
|
||||
// returns true if timeout, false otherwise
|
||||
bool mixerSchedulerWaitForTrigger(uint8_t timeoutMs);
|
||||
@@ -66,6 +69,7 @@ void mixerSchedulerISRTrigger();
|
||||
#define mixerSchedulerStop()
|
||||
#define mixerSchedulerResetTimer()
|
||||
#define mixerSchedulerSetPeriod(m,p)
|
||||
#define mixerSchedulerClearTrigger()
|
||||
|
||||
static inline bool mixerSchedulerWaitForTrigger(uint8_t timeout)
|
||||
{
|
||||
|
||||
@@ -39,8 +39,9 @@ void mixerSchedulerStart()
|
||||
NVIC_SetPriority(MIXER_SCHEDULER_TIMER_IRQn, 8);
|
||||
|
||||
MIXER_SCHEDULER_TIMER->SR &= TIM_SR_UIF; // clear interrupt flag
|
||||
MIXER_SCHEDULER_TIMER->DIER |= TIM_DIER_UIE; // enable interrupt
|
||||
MIXER_SCHEDULER_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
mixerSchedulerEnableTrigger();
|
||||
}
|
||||
|
||||
void mixerSchedulerStop()
|
||||
@@ -58,6 +59,7 @@ void mixerSchedulerResetTimer()
|
||||
|
||||
void mixerSchedulerEnableTrigger()
|
||||
{
|
||||
mixerSchedulerClearTrigger();
|
||||
MIXER_SCHEDULER_TIMER->DIER |= TIM_DIER_UIE; // enable interrupt
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ TASK_FUNCTION(mixerTask)
|
||||
s_pulses_paused = true;
|
||||
|
||||
mixerSchedulerInit();
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
mixerSchedulerStart();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user