Simple 64-bit timer for mbed. It is a drastically simplified version of Timer64 class by Tom Doyle. It is meant to be used in single-thread applications, where timer is used frequently, while standard 32-bit Timer is not enough.

Fork of Timer64 by Tom Doyle

Revision:
3:8396d3e6eb62
Parent:
2:e89b02820e93
Child:
4:9ca673a83acb
Child:
6:100cf27b43aa
diff -r e89b02820e93 -r 8396d3e6eb62 Timer64.h
--- a/Timer64.h	Sun Mar 27 20:44:54 2016 +0000
+++ b/Timer64.h	Mon Mar 28 16:31:42 2016 +0000
@@ -15,9 +15,9 @@
 #define TIMER64_WARNING_ALREADY_STOPPED             3
 #define TIMER64_WARNING_ALREADY_RELEASED            4
 
-#define TIMER64_15MINUTE_ROLLOVER_CHECK_IN_MSECS    900000
-#define TIMER64_MIN_ROLLOVER_CHECK_IN_MSECS         60000   // 0:01:00.000
-#define TIMER64_MAX_ROLLOVER_CHECK_IN_MSECS         2147483 // 0:35:47.483
+#define TIMER64_DEFAULT_ROLLOVER_CHECK_IN_MSECS     30000
+#define TIMER64_MIN_ROLLOVER_CHECK_IN_MSECS         1000
+#define TIMER64_MAX_ROLLOVER_CHECK_IN_MSECS         65535
 
 class Timer64
 {
@@ -48,17 +48,17 @@
      */
     int reset(void);
 
-    /** Get the time passed in seconds
+    /** Get the time passed in micro-seconds
      */
-    double read(int* status = NULL);
+    int read_us(uint64_t* timeInUsec = NULL);
 
     /** Get the time passed in milli-seconds
      */
-    uint64_t read_ms(int* status = NULL);
+    int read_ms(uint64_t* timeInMsec = NULL);
 
-    /** Get the time passed in micro-seconds
+    /** Get the time passed in seconds
      */
-    uint64_t read_us(int* status = NULL);
+    int read(double* timeInSec = NULL);
 
 private:
     bool _timerInitialized;
@@ -68,7 +68,10 @@
     const ticker_data_t *_ticker_data;
     RtosTimer* _rollOverCheckTimer;
     uint32_t _rollOverCheckTimerPeriodInMsec;
+    Semaphore* _sem;
+    
     static void _rollOverCheck(void const* args);
+    static uint64_t _read_us(void const* args);
 };
 
 #endif