fix: Corrupt data using soft serial driver (#3329)
* restore bit start detection IRQ for soft serial * restore bit start detection IRQ for softserial (target Taranis and Horus) * target Taranis: EXTI9_5 is a shared interrupt for Rotary Encoder and Heartbeat for X7, X7-ACCESS und TPRO radios. Changed IRQ priority accordingly * fix crashes where the heartbeat ISR running at interrupt priorities higher than 5 interferes with FreeRTOS calls made from within the heartbeat ISR. * changed mixer scheduler timer initialization to allow for software generated update events to avoid freeRTOS calls from now prio 0 heartbeat ISR. * resolved review feedback: using defines for IRQ prio settings * following review by @raphaelcoeffic: - new function void mixerSchedulerSoftTrigger() (to be called by heartbeat driver) - defines in hal.h for targets horus and taranis * following @raphaelcoeffics review - changed all but telemetry EXIT IRQ (soft serial) definition back to their original state and added define to override EXIT IRQ (soft serial) prio
This commit is contained in:
@@ -41,8 +41,7 @@ static void trigger_intmodule_heartbeat()
|
||||
heartbeatCapture.count++;
|
||||
#endif
|
||||
|
||||
mixerSchedulerResetTimer();
|
||||
mixerSchedulerISRTrigger();
|
||||
mixerSchedulerSoftTrigger();
|
||||
}
|
||||
|
||||
void init_intmodule_heartbeat()
|
||||
|
||||
@@ -30,13 +30,11 @@
|
||||
void mixerSchedulerStart()
|
||||
{
|
||||
MIXER_SCHEDULER_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
|
||||
MIXER_SCHEDULER_TIMER->CR1 = TIM_CR1_URS; // do not generate interrupt on soft update
|
||||
MIXER_SCHEDULER_TIMER->PSC = MIXER_SCHEDULER_TIMER_FREQ / 1000000 - 1; // 1uS (1Mhz)
|
||||
MIXER_SCHEDULER_TIMER->CCER = 0;
|
||||
MIXER_SCHEDULER_TIMER->CCMR1 = 0;
|
||||
MIXER_SCHEDULER_TIMER->ARR = getMixerSchedulerPeriod() - 1;
|
||||
MIXER_SCHEDULER_TIMER->EGR = TIM_EGR_UG; // reset timer
|
||||
MIXER_SCHEDULER_TIMER->CNT = 0; // reset counter
|
||||
|
||||
NVIC_EnableIRQ(MIXER_SCHEDULER_TIMER_IRQn);
|
||||
NVIC_SetPriority(MIXER_SCHEDULER_TIMER_IRQn,
|
||||
@@ -53,13 +51,6 @@ void mixerSchedulerStop()
|
||||
NVIC_DisableIRQ(MIXER_SCHEDULER_TIMER_IRQn);
|
||||
}
|
||||
|
||||
void mixerSchedulerResetTimer()
|
||||
{
|
||||
mixerSchedulerDisableTrigger();
|
||||
MIXER_SCHEDULER_TIMER->CNT = 0;
|
||||
mixerSchedulerEnableTrigger();
|
||||
}
|
||||
|
||||
void mixerSchedulerEnableTrigger()
|
||||
{
|
||||
MIXER_SCHEDULER_TIMER->DIER |= TIM_DIER_UIE; // enable interrupt
|
||||
@@ -70,6 +61,15 @@ void mixerSchedulerDisableTrigger()
|
||||
MIXER_SCHEDULER_TIMER->DIER &= ~TIM_DIER_UIE; // disable interrupt
|
||||
}
|
||||
|
||||
void mixerSchedulerSoftTrigger() {
|
||||
// Generate a timer update event (TIM_EGR_UG) to reload the Prescaler and the repetition
|
||||
// counter value immediately to avoid making FreeRTOS calls within this ISR:
|
||||
// - fires MIXER_SCHEDULER_TIMER interrupt after returning from this ISR
|
||||
// - MIXER_SCHEDULER_TIMER_IRQHandler(void) takes care of making FreeRTOS calls
|
||||
// to ensure switching to highest priority task.
|
||||
MIXER_SCHEDULER_TIMER->EGR = TIM_EGR_UG;
|
||||
}
|
||||
|
||||
extern "C" void MIXER_SCHEDULER_TIMER_IRQHandler(void)
|
||||
{
|
||||
MIXER_SCHEDULER_TIMER->SR &= ~TIM_SR_UIF; // clear flag
|
||||
|
||||
Reference in New Issue
Block a user