Merge pull request #1709 from benpicco/hwtimer_fix
allow HWTIMER_SPEED > 1000000
This commit is contained in:
commit
07fe5bcc9f
@ -86,14 +86,22 @@ per second for the current architecture."
|
||||
* @param[in] us number of microseconds
|
||||
* @return kernel timer ticks
|
||||
*/
|
||||
#if HWTIMER_SPEED > 1000000L
|
||||
#define HWTIMER_TICKS(us) ((us) * (HWTIMER_SPEED / 1000000L))
|
||||
#else
|
||||
#define HWTIMER_TICKS(us) ((us) / (1000000L / HWTIMER_SPEED))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Convert ticks to microseconds
|
||||
* @param[in] ticks number of ticks
|
||||
* @return microseconds
|
||||
*/
|
||||
#if HWTIMER_SPEED > 1000000L
|
||||
#define HWTIMER_TICKS_TO_US(ticks) ((ticks) / (HWTIMER_SPEED / 1000000L))
|
||||
#else
|
||||
#define HWTIMER_TICKS_TO_US(ticks) ((ticks) * (1000000L / HWTIMER_SPEED))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum hwtimer tick count (before overflow)
|
||||
@ -107,7 +115,11 @@ number of ticks countable on the current architecture."
|
||||
/**
|
||||
* @brief microseconds before hwtimer overflow
|
||||
*/
|
||||
#if HWTIMER_SPEED > 1000000L
|
||||
#define HWTIMER_OVERFLOW_MICROS() (HWTIMER_MAXTICKS / HWTIMER_SPEED * 1000000L)
|
||||
#else
|
||||
#define HWTIMER_OVERFLOW_MICROS() (1000000L / HWTIMER_SPEED * HWTIMER_MAXTICKS)
|
||||
#endif
|
||||
|
||||
typedef uint32_t timer_tick_t; /**< data type for hwtimer ticks */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user