Improved sync
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ void mixerSchedulerStart()
|
|||||||
NVIC_SetPriority(MIXER_SCHEDULER_TIMER_IRQn, 8);
|
NVIC_SetPriority(MIXER_SCHEDULER_TIMER_IRQn, 8);
|
||||||
|
|
||||||
MIXER_SCHEDULER_TIMER->SR &= TIM_SR_UIF; // clear interrupt flag
|
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;
|
MIXER_SCHEDULER_TIMER->CR1 |= TIM_CR1_CEN;
|
||||||
|
|
||||||
|
mixerSchedulerEnableTrigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mixerSchedulerStop()
|
void mixerSchedulerStop()
|
||||||
@@ -58,6 +59,7 @@ void mixerSchedulerResetTimer()
|
|||||||
|
|
||||||
void mixerSchedulerEnableTrigger()
|
void mixerSchedulerEnableTrigger()
|
||||||
{
|
{
|
||||||
|
mixerSchedulerClearTrigger();
|
||||||
MIXER_SCHEDULER_TIMER->DIER |= TIM_DIER_UIE; // enable interrupt
|
MIXER_SCHEDULER_TIMER->DIER |= TIM_DIER_UIE; // enable interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ TASK_FUNCTION(mixerTask)
|
|||||||
s_pulses_paused = true;
|
s_pulses_paused = true;
|
||||||
|
|
||||||
mixerSchedulerInit();
|
mixerSchedulerInit();
|
||||||
|
|
||||||
#if !defined(PCBSKY9X)
|
#if !defined(PCBSKY9X)
|
||||||
mixerSchedulerStart();
|
mixerSchedulerStart();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user