expose WsfTimerNextExpiration in the wsf api

pull/13228/head
Paul Szczeanek 2020-06-08 18:26:06 +01:00 committed by Vincent Coubard
parent 313651bb2e
commit 59528d6a18
2 changed files with 21 additions and 3 deletions

View File

@ -112,6 +112,19 @@ void WsfTimerStop(wsfTimer_t *pTimer);
/*************************************************************************************************/
void WsfTimerUpdate(wsfTimerTicks_t ticks);
/*************************************************************************************************/
/*!
* \brief Return the number of ticks until the next timer expiration. Note that this
* function can return zero even if a timer is running, indicating the timer
* has expired but has not yet been serviced.
*
* \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running.
*
* \return The number of ticks until the next timer expiration.
*/
/*************************************************************************************************/
wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning);
/*************************************************************************************************/
/*!
* \brief Service expired timers for the given task. This function is typically called only

View File

@ -201,10 +201,12 @@ static uint32_t wsfTimerTicksToRtc(wsfTimerTicks_t wsfTicks)
* function can return zero even if a timer is running, indicating a timer
* has expired but has not yet been serviced.
*
* \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running.
*
* \return The number of ticks until the next timer expiration.
*/
/*************************************************************************************************/
static wsfTimerTicks_t wsfTimerNextExpiration(void)
wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning)
{
wsfTimerTicks_t ticks;
@ -213,10 +215,12 @@ static wsfTimerTicks_t wsfTimerNextExpiration(void)
if (wsfTimerTimerQueue.pHead == NULL)
{
*pTimerRunning = FALSE;
ticks = 0;
}
else
{
*pTimerRunning = TRUE;
ticks = ((wsfTimer_t *) wsfTimerTimerQueue.pHead)->ticks;
}
@ -391,9 +395,10 @@ void WsfTimerSleep(void)
return;
}
nextExpiration = wsfTimerNextExpiration();
bool_t running;
nextExpiration = WsfTimerNextExpiration(&running);
if (nextExpiration > 0)
if (running)
{
uint32_t awake = wsfTimerTicksToRtc(nextExpiration);
uint32_t rtcCurrentTicks = PalRtcCounterGet();