Functions | |
int | FastTimer_SetActive (bool active) |
Controls the active state of the Fast Timer system. | |
int | FastTimer_GetActive () |
Returns whether the timer subsystem is active or not. | |
void | FastTimer_InitializeEntry (FastTimerEntry *fastTimerEntry, void(*timerCallback)(int id), int id, int timeUs, bool repeat) |
Initializes a fast timer entry structure. | |
void | FastTimer_SetTime (FastTimerEntry *fastTimerEntry, int timeUs) |
Change the requeted time of an entry. | |
int | FastTimer_Set (FastTimerEntry *fastTimerEntry) |
Sets the requested entry to run. | |
int | FastTimer_Cancel (FastTimerEntry *fastTimerEntry) |
Stops the requested fast timer entry from running. |
If you don't need such high resolution timing, check the Timer
The Fast Timer subsystem is based on a collection of FastTimerEntries. To start a new timer, create a new FastTimerEntry structure, initialize it with FastTimer_InitializeEntry( ), and start it with FastTimer_Set( ).
There are currently one main limitation to the Fast Timer system:
int FastTimer_Cancel | ( | FastTimerEntry * | fastTimerEntry | ) |
Stops the requested fast timer entry from running.
fastTimerEntry | pointer to the FastTimerEntry to be cancelled. |
Definition at line 229 of file fasttimer.c.
int FastTimer_GetActive | ( | void | ) |
Returns whether the timer subsystem is active or not.
Definition at line 94 of file fasttimer.c.
void FastTimer_InitializeEntry | ( | FastTimerEntry * | fastTimerEntry, | |
void(*)(int id) | timerCallback, | |||
int | id, | |||
int | timeUs, | |||
bool | repeat | |||
) |
Initializes a fast timer entry structure.
The event is signified by a callback to the function provided, after the interval specified. The specified ID is passed back to the function to permit one function to work for many events. Pass repeat = true to make the event continue to create callbacks until it is canceled. Note that the timer entry structure needs to be created and managed by the caller. The longest period for a fast timer entry is 2^32 / 1000000 = 4294s.
fastTimerEntry | pointer to the FastTimerEntry to be intialized. | |
timerCallback | pointer to the callback function. The function must be of the form void callback( int id ) | |
id | An integer specifying the ID the callback function is to be provided with. | |
timeUs | The time in microseconds desired for the callback. | |
repeat | Set whether the timer repeats or is a one-time event. |
TimerEntry myTimer; // our TimerEntry FastTimer_InitializeEntry( &myTimer, myCallback, 0, 250, true ); FastTimer_Set( &myTimer ); // start our timer void myCallback( int id ) // our code that will get called by the timer every 250 microseconds. { // do something here }
Definition at line 126 of file fasttimer.c.
int FastTimer_Set | ( | FastTimerEntry * | fastTimerEntry | ) |
Sets the requested entry to run.
This routine adds the entry to the running queue and then decides if it needs to start the timer (if it's not running) or alter the timer's clock for a shorter period.
fastTimerEntry | A pointer to the FastTimerEntry to be run. |
Definition at line 160 of file fasttimer.c.
int FastTimer_SetActive | ( | bool | active | ) |
Controls the active state of the Fast Timer system.
active | whether the FastTimer subsystem is active or not |
Definition at line 65 of file fasttimer.c.
void FastTimer_SetTime | ( | FastTimerEntry * | fastTimerEntry, | |
int | timeUs | |||
) |
Change the requeted time of an entry.
This must only be called within a callback caused by the Entry specified or when the entry is not being used. If you need to change the duration of a timer, you need to cancel it and re-add it, or alter the time inside a callback.
fastTimerEntry | A pointer to the FastTimerEntry to be intialized. | |
timeUs | The time in microseconds desired for the callback. |
Definition at line 147 of file fasttimer.c.