From c18633dcf27645e42c299b504a045f900921f27a Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Tue, 25 Nov 2014 09:17:57 +0000 Subject: [PATCH] switching timestamp_t back to 32-bits. The underlying us_tickers used for comparison are still 32-bits; keeping a 64-bit timestamp isn't going to be useful. fixes #838 --- libraries/mbed/hal/us_ticker_api.h | 2 +- .../targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/mbed/hal/us_ticker_api.h b/libraries/mbed/hal/us_ticker_api.h index ea62d7c06f..b7df3b57a1 100644 --- a/libraries/mbed/hal/us_ticker_api.h +++ b/libraries/mbed/hal/us_ticker_api.h @@ -22,7 +22,7 @@ extern "C" { #endif -typedef uint64_t timestamp_t; +typedef uint32_t timestamp_t; uint32_t us_ticker_read(void); diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c index d544106d25..aea896a9c3 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c @@ -40,7 +40,7 @@ uint32_t us_ticker_read() us_ticker_init(); } - timestamp_t value; + uint64_t value; app_timer_cnt_get(&value); /* This returns the RTC counter (which is fed by the 32khz crystal clock source) */ return ((value * 1000000) / (uint32_t)APP_TIMER_CLOCK_FREQ); /* Return a pseudo microsecond counter value. * This is only as precise as the 32khz low-freq @@ -72,7 +72,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp) return; } - timestamp_t currentCounter64; + uint64_t currentCounter64; app_timer_cnt_get(¤tCounter64); uint32_t currentCounter = currentCounter64 & MAX_RTC_COUNTER_VAL; uint32_t targetCounter = ((uint32_t)((timestamp * (uint64_t)APP_TIMER_CLOCK_FREQ) / 1000000) + 1) & MAX_RTC_COUNTER_VAL;