Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
clktimer/clktimer.c@40:53666b1a5848, 2018-12-04 (annotated)
- Committer:
- andrewboyson
- Date:
- Tue Dec 04 12:26:27 2018 +0000
- Revision:
- 40:53666b1a5848
- Child:
- 46:d3d56cb47940
Renamed timer to hrtimer; added clktimer to handle utc based times.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 40:53666b1a5848 | 1 | #include <stdint.h> |
andrewboyson | 40:53666b1a5848 | 2 | #include <stdbool.h> |
andrewboyson | 40:53666b1a5848 | 3 | |
andrewboyson | 40:53666b1a5848 | 4 | #include "clock.h" |
andrewboyson | 40:53666b1a5848 | 5 | |
andrewboyson | 40:53666b1a5848 | 6 | int64_t ClkTimerSinceRepetitive(int64_t* pLastCount) |
andrewboyson | 40:53666b1a5848 | 7 | { |
andrewboyson | 40:53666b1a5848 | 8 | int64_t thisCount = ClockTime(); |
andrewboyson | 40:53666b1a5848 | 9 | int64_t period = thisCount - *pLastCount; |
andrewboyson | 40:53666b1a5848 | 10 | *pLastCount = thisCount; |
andrewboyson | 40:53666b1a5848 | 11 | return period; |
andrewboyson | 40:53666b1a5848 | 12 | } |
andrewboyson | 40:53666b1a5848 | 13 | int64_t ClkTimerSince(int64_t lastCount) |
andrewboyson | 40:53666b1a5848 | 14 | { |
andrewboyson | 40:53666b1a5848 | 15 | return ClockTime() - lastCount; |
andrewboyson | 40:53666b1a5848 | 16 | } |
andrewboyson | 40:53666b1a5848 | 17 | |
andrewboyson | 40:53666b1a5848 | 18 | bool ClkTimerRepetitiveTick(int64_t* pLastCount, int64_t interval) |
andrewboyson | 40:53666b1a5848 | 19 | { |
andrewboyson | 40:53666b1a5848 | 20 | if (ClockTime() - *pLastCount >= interval) |
andrewboyson | 40:53666b1a5848 | 21 | { |
andrewboyson | 40:53666b1a5848 | 22 | *pLastCount += interval; |
andrewboyson | 40:53666b1a5848 | 23 | return true; |
andrewboyson | 40:53666b1a5848 | 24 | } |
andrewboyson | 40:53666b1a5848 | 25 | return false; |
andrewboyson | 40:53666b1a5848 | 26 | } |