From 8e67e90410d448d2dc3340795ca8de414d1fe3a9 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 16 May 2017 12:44:06 +0200 Subject: Make sure that frequency is at a valid value (>0) Else we got infinite value if 0 and negative value doesn't make sense here. Change-Id: Id65f0aa94cae32f1fea2c5c80028e328e6958a13 Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/utils/timer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'CAN-binder/low-can-binding/utils/timer.cpp') diff --git a/CAN-binder/low-can-binding/utils/timer.cpp b/CAN-binder/low-can-binding/utils/timer.cpp index 8c6215b..7edb0d5 100644 --- a/CAN-binder/low-can-binding/utils/timer.cpp +++ b/CAN-binder/low-can-binding/utils/timer.cpp @@ -57,7 +57,10 @@ frequency_clock_t::frequency_clock_t() frequency_clock_t::frequency_clock_t(float frequency) : unit_{1000000}, frequency_{frequency}, last_tick_{0}, time_function_{nullptr} -{} +{ + if(frequency_ <= 0) + frequency_ = 1; +} /// @brief Return the period in ms given the frequency in hertz. /// @param[in] frequency - Frequency to convert, in hertz -- cgit 1.2.3-korg