Microchip® Advanced Software Framework

timer.c File Reference

D21 implementation of the timer interface.

Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.

Functions

void countdown (Timer *timer, unsigned int timeout)
 count down timer function. More...
 
void countdown_ms (Timer *timer, unsigned int timeout)
 count down timer function. More...
 
char expired (Timer *timer)
 Timer expiry check function. More...
 
uint32_t getTimeInMillis (void)
 Get time in milliseconds. More...
 
void InitTimer (Timer *timer)
 Timer intialization function. More...
 
int left_ms (Timer *timer)
 Time avaible for timer expiry function. More...
 

Variables

volatile uint32_t ms_ticks
 SysTick counter to avoid busy wait delay. More...
 

void countdown ( Timer timer,
unsigned int  timeout 
)

count down timer function.

Create a timer (seconds)

Parameters
[in]timerTimer to be started.
[in]timeouttimeout in seconds.
Returns
None.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by addToAckWaitList(), cycle(), keepalive(), MQTTConnect(), and subscribeToShadowActionAcks().

void countdown_ms ( Timer timer,
unsigned int  timeout 
)

count down timer function.

Create a timer (milliseconds)

Parameters
[in]timerTimer to be started.
[in]timeouttimeout in milliseconds.
Returns
None.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by handleReconnect(), keepalive(), MQTTConnect(), MQTTDisconnect(), MQTTPublish(), MQTTResubscribe(), MQTTSubscribe(), MQTTUnsubscribe(), and MQTTYield().

char expired ( Timer timer)

Timer expiry check function.

Check if a timer is expired.

Parameters
[in]timerTimer to be checked.
Returns
time to expiry.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by HandleExpiredResponseCallbacks(), handleReconnect(), keepalive(), MQTTYield(), sendPacket(), subscribeToShadowActionAcks(), and waitfor().

uint32_t getTimeInMillis ( void  )

Get time in milliseconds.

Returns
milli second ticks count.

References ms_ticks.

Referenced by countdown(), countdown_ms(), expired(), and left_ms().

void InitTimer ( Timer timer)

Timer intialization function.

Initialize a timer.

Parameters
[in]timerTimer to be intialized.
Returns
None.

References Timer::end_time, and Timer::offset.

Referenced by addToAckWaitList(), keepalive(), MQTTClient(), MQTTConnect(), MQTTDisconnect(), MQTTPublish(), MQTTResubscribe(), MQTTSubscribe(), MQTTUnsubscribe(), MQTTYield(), and subscribeToShadowActionAcks().

int left_ms ( Timer timer)

Time avaible for timer expiry function.

Check the time remaining on a give timer.

Parameters
[in]timerTimer to be started.
Returns
Time for expiry in milliseconds.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by readPacket(), and sendPacket().

volatile uint32_t ms_ticks

SysTick counter to avoid busy wait delay.

TLS read functionality.

Referenced by button_press_duration(), getTimeInMillis(), and SysTick_Handler().