feat: async 10ms timer handler (#5424)
This commit is contained in:
+27
-1
@@ -157,7 +157,7 @@ void checkValidMCU(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void per10ms()
|
void timer_10ms()
|
||||||
{
|
{
|
||||||
DEBUG_TIMER_START(debugTimerPer10ms);
|
DEBUG_TIMER_START(debugTimerPer10ms);
|
||||||
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
|
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
|
||||||
@@ -226,6 +226,32 @@ void per10ms()
|
|||||||
DEBUG_TIMER_STOP(debugTimerPer10ms);
|
DEBUG_TIMER_STOP(debugTimerPer10ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(SIMU)
|
||||||
|
// Handle 10ms timer asynchronously
|
||||||
|
#include <FreeRTOS/include/FreeRTOS.h>
|
||||||
|
#include <FreeRTOS/include/timers.h>
|
||||||
|
|
||||||
|
static void _timer_10ms_cb(void *pvParameter1, uint32_t ulParameter2)
|
||||||
|
{
|
||||||
|
(void)pvParameter1;
|
||||||
|
(void)ulParameter2;
|
||||||
|
timer_10ms();
|
||||||
|
}
|
||||||
|
|
||||||
|
void per10ms()
|
||||||
|
{
|
||||||
|
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
||||||
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
xTimerPendFunctionCallFromISR(_timer_10ms_cb, nullptr, 0, &xHigherPriorityTaskWoken);
|
||||||
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // !defined(SIMU)
|
||||||
|
void per10ms() { timer_10ms(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FlightModeData *flightModeAddress(uint8_t idx)
|
FlightModeData *flightModeAddress(uint8_t idx)
|
||||||
{
|
{
|
||||||
return &g_model.flightModeData[idx];
|
return &g_model.flightModeData[idx];
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "hal/watchdog_driver.h"
|
#include "hal/watchdog_driver.h"
|
||||||
|
|
||||||
|
#include "FreeRTOSConfig.h"
|
||||||
|
|
||||||
static volatile uint32_t _ms_ticks;
|
static volatile uint32_t _ms_ticks;
|
||||||
|
|
||||||
static void _init_1ms_timer()
|
static void _init_1ms_timer()
|
||||||
@@ -41,8 +43,9 @@ static void _init_1ms_timer()
|
|||||||
MS_TIMER->EGR = 0;
|
MS_TIMER->EGR = 0;
|
||||||
MS_TIMER->CR1 = TIM_CR1_CEN | TIM_CR1_URS;
|
MS_TIMER->CR1 = TIM_CR1_CEN | TIM_CR1_URS;
|
||||||
MS_TIMER->DIER = TIM_DIER_UIE;
|
MS_TIMER->DIER = TIM_DIER_UIE;
|
||||||
|
|
||||||
NVIC_EnableIRQ(MS_TIMER_IRQn);
|
NVIC_EnableIRQ(MS_TIMER_IRQn);
|
||||||
NVIC_SetPriority(MS_TIMER_IRQn, 4);
|
NVIC_SetPriority(MS_TIMER_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timersInit()
|
void timersInit()
|
||||||
|
|||||||
Reference in New Issue
Block a user