aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/include
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-27 14:04:10 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-27 14:04:10 -0400
commit0e7a40c7b790f13daec1b8a73f20d1dda57134f9 (patch)
treeb4d16f74946dd73d55baf1436448f65ea8b35d91 /wirish/include
parent1ea491a3ed723b9895d2827deb235fdace870ea4 (diff)
downloadlibrambutan-0e7a40c7b790f13daec1b8a73f20d1dda57134f9.tar.gz
librambutan-0e7a40c7b790f13daec1b8a73f20d1dda57134f9.zip
Clean up micros().
Don't leave US_PER_MS user-visible. Remove an unnecessary variable. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish/include')
-rw-r--r--wirish/include/wirish/wirish_time.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/wirish/include/wirish/wirish_time.h b/wirish/include/wirish/wirish_time.h
index 1520b1e..eb6c68f 100644
--- a/wirish/include/wirish/wirish_time.h
+++ b/wirish/include/wirish/wirish_time.h
@@ -37,8 +37,6 @@
#include <wirish/boards.h>
-#define US_PER_MS 1000
-
/**
* Returns time (in milliseconds) since the beginning of program
* execution. On overflow, restarts at 0.
@@ -56,19 +54,18 @@ static inline uint32 millis(void) {
static inline uint32 micros(void) {
uint32 ms;
uint32 cycle_cnt;
- uint32 res;
do {
ms = millis();
cycle_cnt = systick_get_count();
} while (ms != millis());
+#define US_PER_MS 1000
/* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it
* actually takes to complete a SysTick reload */
- res = (ms * US_PER_MS) +
- (SYSTICK_RELOAD_VAL + 1 - cycle_cnt) / CYCLES_PER_MICROSECOND;
-
- return res;
+ return ((ms * US_PER_MS) +
+ (SYSTICK_RELOAD_VAL + 1 - cycle_cnt) / CYCLES_PER_MICROSECOND);
+#undef US_PER_MS
}
/**