A coarse global timer that can be used to track time intervals.
The timer is accurate to 10ths of a millisecond.
|
file | coarse_timer.h |
| Provides a coarse timer for determining the elapsed time between two events.
|
|
Return the interval between two times.
- Parameters
-
start_time | The time to measure from. |
end_time | The time to measure to. |
- Returns
- The time between the start and end time, measured in 10ths of a millisecond.
Accuracy is to within 10ths of a millisecond. Be careful if using this to trigger events. as the events may then trigger up to 0.1ms before they were supposed to.
Return the interval since the start_time.
- Parameters
-
start_time | The time to measure from. |
- Returns
- The time since the start_time, measured in 10ths of a millisecond.
Accuracy is to within 10ths of a millisecond. Be careful if using this to trigger events. as the events may then trigger up to 0.1ms before they were supposed to.
Check if a time interval has passed.
- Parameters
-
start_time | The time to measure from. |
interval | The time interval in 10ths of a millisecond. |
- Returns
- true if the interval has elapsed since the start_time.
Initialize the timer.
- Parameters
-
settings | The timer settings. |
The settings should match the interrupt vector used to call CoarseTimer_TimerEvent().
- Example
1 CoarseTimer_Settings timer_settings = {
3 .interrupt_source = INT_SOURCE_TIMER_2
6 CoarseTimer_Initialize(&timer_settings);
void CoarseTimer_SetCounter |
( |
uint32_t |
count | ) |
|
Manually set the internal counter.
- Parameters
-
count | the new value of the internal counter. |
- Note
- This function should be used for testing only.
void CoarseTimer_TimerEvent |
( |
| ) |
|
Update the timer.
This should be called from within an ISR.
- Example
1 void __ISR(_TIMER_2_VECTOR, ipl6) TimerEvent() {
2 CoarseTimer_TimerEvent();
The interrupt vector should match what was supplied to CoarseTimer_Initialize().