core/hwtimer: add HWTIMER_WAIT_OVERHEAD

dev/timer
Ludwig Ortmann 9 years ago
parent 19cb5bd153
commit f677f70836

@ -129,9 +129,7 @@ void hwtimer_wait(unsigned long ticks)
mutex_t mutex = MUTEX_INIT;
mutex_lock(&mutex);
/* TODO: introduce HWTIMER_INSTRUCTIONS_PER_TICK?
* -2 is to adjust the real value */
int res = hwtimer_set(ticks - 2, hwtimer_releasemutex, &mutex);
int res = hwtimer_set(ticks - (HWTIMER_WAIT_OVERHEAD), hwtimer_releasemutex, &mutex);
if (res == -1) {
mutex_unlock(&mutex);
hwtimer_spin(ticks);

@ -60,6 +60,23 @@ per second for the current architecture."
#define HWTIMER_SPIN_BARRIER (6)
#endif
/**
* @brief Overhead of the `hwtimer_wait` function
*
* @verbatim This value is used to decrease the number of ticks that
* `hwtimer_wait` uses to set the actual hardware timer.
*
* The goal is to make sure the number of ticks spent in the
* function corresponds to the ticks argument it was given.
*
* Boards should override this.
*
* @def HWTIMER_WAIT_OVERHEAD
*/
#ifndef HWTIMER_WAIT_OVERHEAD
#define HWTIMER_WAIT_OVERHEAD (2)
#endif
/**
* @brief Convert microseconds to kernel timer ticks
* @param[in] us number of microseconds

Loading…
Cancel
Save