Make event queue use RTOS tick count

Event queue was using its own Timer or LowPowerTimer objects to derive
millisecond tick counts. This is unnecessary in RTOS builds, where the
RTOS is maintaining a tick count.

It also makes more sense to use the actual RTOS tick count, as the
values are being used to compute tick timeouts for RTOS calls. Computing
these RTOS tick delays with a separate timer could conceivably lead to
rounding errors.

Fixes: #5378
pull/6693/head
Kevin Bracey 2018-04-20 10:58:19 +03:00
parent 42d77ecd13
commit d979c59118
2 changed files with 11 additions and 2 deletions

View File

@ -23,6 +23,15 @@
#include <stdbool.h>
#include "mbed.h"
// Ticker operations
#if MBED_CONF_RTOS_PRESENT
unsigned equeue_tick() {
return osKernelGetTickCount();
}
#else
#if MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER
#define ALIAS_TIMER LowPowerTimer
#define ALIAS_TICKER LowPowerTicker
@ -33,7 +42,6 @@
#define ALIAS_TIMEOUT Timeout
#endif
// Ticker operations
static bool equeue_tick_inited = false;
static volatile unsigned equeue_minutes = 0;
static unsigned equeue_timer[
@ -77,6 +85,7 @@ unsigned equeue_tick() {
return minutes + ms;
}
#endif
// Mutex operations
int equeue_mutex_create(equeue_mutex_t *m) { return 0; }

View File

@ -23,7 +23,7 @@
"value": 256
},
"use-lowpower-timer-ticker": {
"help": "Enable use of low power timer and ticker classes. May reduce the accuracy of the event queue.",
"help": "Enable use of low power timer and ticker classes in non-RTOS builds. May reduce the accuracy of the event queue. In RTOS builds, the RTOS tick count is used, and this configuration option has no effect.",
"value": 0
}
}