mbed library sources(for async_print)
Fork of mbed-src by
Revision 452:a2b30f7d1bc5, committed 2015-01-26
- Comitter:
- mbed_official
- Date:
- Mon Jan 26 14:15:07 2015 +0000
- Parent:
- 451:ea2f0f5bda68
- Child:
- 453:a290c6acf95e
- Commit message:
- Synchronized with git revision e979bd60eb6de65d0db5993b547adbd692b91e9f
Full URL: https://github.com/mbedmicro/mbed/commit/e979bd60eb6de65d0db5993b547adbd692b91e9f/
switching timestamp_t back to 32-bits.
Changed in this revision
--- a/common/us_ticker_api.c Mon Jan 26 07:00:07 2015 +0000 +++ b/common/us_ticker_api.c Mon Jan 26 14:15:07 2015 +0000 @@ -70,7 +70,7 @@ ticker_event_t *prev = NULL, *p = head; while (p != NULL) { /* check if we come before p */ - if ((int64_t)(timestamp - p->timestamp) < 0) { + if ((signedTimestamp_t)(timestamp - p->timestamp) < 0) { break; } /* go to the next element */
--- a/hal/us_ticker_api.h Mon Jan 26 07:00:07 2015 +0000 +++ b/hal/us_ticker_api.h Mon Jan 26 14:15:07 2015 +0000 @@ -22,7 +22,8 @@ extern "C" { #endif -typedef uint64_t timestamp_t; +typedef uint32_t timestamp_t; +typedef int32_t signedTimestamp_t; /* The signed version of the above declaration. */ uint32_t us_ticker_read(void);
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c Mon Jan 26 07:00:07 2015 +0000 +++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c Mon Jan 26 14:15:07 2015 +0000 @@ -18,6 +18,7 @@ #include "cmsis.h" #include "PeripheralNames.h" #include "app_timer.h" +#include "projectconfig.h" static bool us_ticker_inited = false; static volatile bool us_ticker_appTimerRunning = false; @@ -29,7 +30,7 @@ return; } - APP_TIMER_INIT(0 /*CFG_TIMER_PRESCALER*/ , 1 /*CFG_TIMER_MAX_INSTANCE*/, 1 /*CFG_TIMER_OPERATION_QUEUE_SIZE*/, false /*CFG_SCHEDULER_ENABLE*/); + APP_TIMER_INIT(CFG_TIMER_PRESCALER, CFG_TIMER_MAX_INSTANCE, CFG_TIMER_OPERATION_QUEUE_SIZE, CFG_SCHEDULER_ENABLE); us_ticker_inited = true; } @@ -40,7 +41,7 @@ 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 +73,7 @@ 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; @@ -94,13 +95,17 @@ void us_ticker_disable_interrupt(void) { if (us_ticker_appTimerRunning) { - app_timer_stop(us_ticker_appTimerID); + if (app_timer_stop(us_ticker_appTimerID) == NRF_SUCCESS) { + us_ticker_appTimerRunning = false; + } } } void us_ticker_clear_interrupt(void) { if (us_ticker_appTimerRunning) { - app_timer_stop(us_ticker_appTimerID); + if (app_timer_stop(us_ticker_appTimerID) == NRF_SUCCESS) { + us_ticker_appTimerRunning = false; + } } }