timeout.c File Reference

Includes

  1. 1.stdio.h
  2. 2.timeout.h
  3. 3.../tmr0.h

Functions

uint32_t
dummyHandler (void *payload)

Parameters:

payload
Type: void *

Returns:

None

void
startTimerAtHead (void)

This function starts the timer queue from the beginning.

Parameters:

none

Returns:

None

INLINE void
enqueueCallback (timerStruct_t *timer)

This function moves a specific timer from the active list to the list of timers which are expired and needs their callbacks called in callNextCallback

Parameters:

*timer

Type: timerStruct_t *

- timer instance whose callback have to be called.

Returns:

None

INLINE void
setTimerDuration (uint32_t duration)

This sets the number of ticks the timer will run for.

Parameters:

duration

Type: uint32_t

- number of timer ticks

Returns:

None

INLINE uint32_t
makeAbsolute (uint32_t timeout)

This function takes a number of ticks and returns the total number of timer ticks since the last timeout occurred or the timer module was started.

Parameters:

duration

- number of timer ticks of a specific timer

Returns:

INLINE uint32_t
rebaseList (void)

This function adjusts the time base so that the timer can never wrap

Parameters:

none

Returns:

INLINE void
printList (void)

This function prints the times for each of the timer for each timer on the queue.

Parameters:

none

Returns:

None

bool
timeout_hasPendingTimeouts (void)

Call this function to check if there are any timers running or waiting to be called

Parameters:

none

Returns:

bool
timeout_hasPendingCallbacks (void)

Call this function to check if there are events that are being executed or waiting to be executed

Parameters:

none

Returns:

void
stopTimeouts (void)

This function disables all the timers without deleting them from the list. Timers can be restarted by calling startTimerAtHead

Parameters:

none

Returns:

None

uint32_t
timeout_getTimeRemaining (timerStruct_t *timer)

This function gets the number of ticks remaining before a specific timer runs out.

Parameters:

*timer

Type: timerStruct_t *

- the specific timer in question

Returns:

bool
sortedInsert (timerStruct_t *timer)

This function figures out where the specific timer will be placed on the queue.

Parameters:

timer

Type: timerStruct_t *

- instance of a timer being inserted to the queue

Returns:

void
timeout_flushAll (void)

This function cancels and removes all timers in the queue

Parameters:

none

Returns:

None

bool
timeout_deleteHelper (timerStruct_t *volatile *list, timerStruct_t *timer)

This function looks for a specific timer instance and removes it from the queue.

Parameters:

*list

Type: timerStruct_t *volatile *

- the pointer that points to the timer instance at the head of the queue

*timer

Type: timerStruct_t *

- timer instance to be removed

Returns:

void
timeout_delete (timerStruct_t *timer)

This function cancels and removes a running timer

Parameters:

*timer

Type: timerStruct_t *

- timer instance to be removed

Returns:

None

void
timeout_callNextCallback (void)

This function checks the list of expired timers and calls the first one in the list if the list is not empty. It also reschedules the timer if the callback returned a value greater than 0.It is recommended this is called from the main superloop (while(1)) in your code but by design this can also be called from the timer ISR. If you wish callbacks to happen from the ISR context you can call this as the last action in timeout_isr instead.

Parameters:

none

Returns:

None

void
timeout_initialize (void)

This function sets the timeout ISR handler as the the interrupt handler for the timer.

Parameters:

*timer

- timer instance whose callback have to be called.

Returns:

None

void
timeout_create (timerStruct_t *timer, uint32_t timeout)

This function adds to the queue and starts the timer. If the timer was already active/running it will be replaced by this and the old (active) timer will be removed/cancelled first.

Parameters:

*timer

Type: timerStruct_t *

- timer instance to be created and added to the list

timeout

Type: uint32_t

- number of timer ticks before this timer expires.

Returns:

None

void
timeout_isr (void)

This function is the handler that is called whenever the Timer peripheral interrupts. The handler counts the time elapsed and calls the next timer in the queue. It assumes that the callback is completed before the next timer tick.

Parameters:

none

Returns:

None

void
timeout_startTimer (timerStruct_t *timer)

This function is specifically used in Stopwatch/cycle counter mode. It will start a timer with maximum timeout of up to the maximum range of the timer divided by 2.

Parameters:

*timer

Type: timerStruct_t *

- timer instance that will be used in stopwatch mode.

Returns:

None

uint32_t
timeout_stopTimer (timerStruct_t *timer)

This function is specifically used in Stopwatch/cycle counter mode. It will stop the running timer and return the number of ticks it counted.

Parameters:

*timer

Type: timerStruct_t *

- timer instance that is used in stopwatch mode.

Returns: