stm32 tickless: stop assertion when calling up_timer_gettime before initialised

up_timer_gettime can be called before module is initialised when
CONFIG_SCHED_IRQMONITOR is enabled.

This fix aligns with stm32f7 implementation.
This commit is contained in:
Richard Tucker
2023-06-17 17:30:17 +10:00
committed by Alan Carvalho de Assis
parent 69756f277e
commit 225d347306
+11 -1
View File
@@ -614,7 +614,16 @@ int up_timer_gettime(struct timespec *ts)
int pending;
irqstate_t flags;
DEBUGASSERT(g_tickless.tch && ts);
DEBUGASSERT(ts);
/* Timer not initialized yet, return zero */
if (g_tickless.tch == 0)
{
ts->tv_nsec = 0;
ts->tv_sec = 0;
return OK;
}
/* Temporarily disable the overflow counter. NOTE that we have to be
* careful here because stm32_tc_getpending() will reset the pending
@@ -938,6 +947,7 @@ int up_timer_start(const struct timespec *ts)
/* Set interval compare value. Rollover is fine,
* channel will trigger on the next period.
*/
#ifdef HAVE_32BIT_TICKLESS
DEBUGASSERT(period <= UINT32_MAX);
g_tickless.period = (uint32_t)(period + count);