Commit 95efe326 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

make sure at least one operand is (signed) 64-bit when multiplication is...

make sure at least one operand is (signed) 64-bit when multiplication is applied within a time conversion macro
parent 44ae1067
......@@ -32,32 +32,32 @@
#define TIME_HS_TIMER_H_
#define HS_TIMER_FREQUENCY 8000000 // High speed timer (htim2) cycles per second
#define HS_TIMER_FREQUENCY_MS 8000 // High speed timer (htim2) cycles per ms
#define HS_TIMER_FREQUENCY_US 8 // High speed timer (htim2) cycles per us
#define HS_TIMER_FREQUENCY 8000000LL // High speed timer (htim2) cycles per second
#define HS_TIMER_FREQUENCY_MS 8000 // High speed timer (htim2) cycles per ms
#define HS_TIMER_FREQUENCY_US 8 // High speed timer (htim2) cycles per us
#define HS_TIMER_GUARD_TIME 800 // 100us; worst case time needed so set the timer correctly (schedule and generic)
#define HS_TIMER_GUARD_TIME 800 // 100us; worst case time needed so set the timer correctly (schedule and generic)
#ifndef HS_TIMER_COMPENSATE_DRIFT
#define HS_TIMER_COMPENSATE_DRIFT 1
#define HS_TIMER_COMPENSATE_DRIFT 1
#endif /* HS_TIMER_COMPENSATE_DRIFT */
#ifndef HS_TIMER_INIT_FROM_RTC
#define HS_TIMER_INIT_FROM_RTC 1
#define HS_TIMER_INIT_FROM_RTC 1
#endif /* HS_TIMER_INIT_FROM_RTC */
#define HS_TIMER_TICKS_TO_LPTIMER(hs_ticks) ((hs_ticks) * LPTIMER_FREQUENCY / HS_TIMER_FREQUENCY)
#define HS_TIMER_TICKS_TO_S(hs_ticks) ((hs_ticks) / HS_TIMER_FREQUENCY)
#define HS_TIMER_TICKS_TO_MS(hs_ticks) ((hs_ticks) / HS_TIMER_FREQUENCY_MS)
#define HS_TIMER_TICKS_TO_US(hs_ticks) ((hs_ticks) / HS_TIMER_FREQUENCY_US)
#define HS_TIMER_TICKS_TO_NS(hs_ticks) ((hs_ticks) * 1000 / HS_TIMER_FREQUENCY_US)
#define HS_TIMER_S_TO_TICKS(s) ((s) * HS_TIMER_FREQUENCY)
#define HS_TIMER_MS_TO_TICKS(ms) ((ms) * HS_TIMER_FREQUENCY_MS)
#define HS_TIMER_US_TO_TICKS(us) ((us) * HS_TIMER_FREQUENCY_US)
#define HS_TIMER_NS_TO_TICKS(ns) ((ns) * HS_TIMER_FREQUENCY_US / 1000)
#define HS_TIMER_TICKS_TO_LPTIMER(t) ((t) * (int64_t)LPTIMER_FREQUENCY / HS_TIMER_FREQUENCY)
#define HS_TIMER_TICKS_TO_S(t) ((t) / HS_TIMER_FREQUENCY)
#define HS_TIMER_TICKS_TO_MS(t) ((t) / HS_TIMER_FREQUENCY_MS)
#define HS_TIMER_TICKS_TO_US(t) ((t) / HS_TIMER_FREQUENCY_US)
#define HS_TIMER_TICKS_TO_NS(t) ((t) * 1000LL / HS_TIMER_FREQUENCY_US)
#define HS_TIMER_S_TO_TICKS(s) ((s) * (int64_t)HS_TIMER_FREQUENCY)
#define HS_TIMER_MS_TO_TICKS(ms) ((ms) * (int64_t)HS_TIMER_FREQUENCY_MS)
#define HS_TIMER_US_TO_TICKS(us) ((us) * (int64_t)HS_TIMER_FREQUENCY_US)
#define HS_TIMER_NS_TO_TICKS(ns) ((ns) * (int64_t)HS_TIMER_FREQUENCY_US / 1000)
#define hs_timer_now hs_timer_get_current_timestamp // Alias
#define hs_timer_now hs_timer_get_current_timestamp // Alias
typedef void (* hs_timer_cb_t)(void);
......
......@@ -57,13 +57,13 @@
/* returns relative time (elapsed time since MCU start) in seconds */
#define LPTIMER_NOW_SEC() (uint32_t)(lptimer_now() / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_HS_TIMER(t) ((t) * HS_TIMER_FREQUENCY / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_US(t) ((t) * 1000000 / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_MS(t) ((t) * 1000 / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_HS_TIMER(t) ((t) * (int64_t)HS_TIMER_FREQUENCY / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_US(t) ((t) * 1000000LL / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_MS(t) ((t) * 1000LL / LPTIMER_SECOND)
#define LPTIMER_TICKS_TO_S(t) ((t) / LPTIMER_SECOND)
#define LPTIMER_US_TO_TICKS(us) ((us) * LPTIMER_SECOND / 1000000)
#define LPTIMER_MS_TO_TICKS(ms) ((ms) * LPTIMER_SECOND / 1000)
#define LPTIMER_S_TO_TICKS(s) ((s) * LPTIMER_SECOND)
#define LPTIMER_US_TO_TICKS(us) ((us) * (int64_t)LPTIMER_SECOND / 1000000LL)
#define LPTIMER_MS_TO_TICKS(ms) ((ms) * (int64_t)LPTIMER_SECOND / 1000LL)
#define LPTIMER_S_TO_TICKS(s) ((s) * (int64_t)LPTIMER_SECOND)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment