Make sure that frequency is at a valid value (>0)
authorRomain Forlot <romain.forlot@iot.bzh>
Tue, 16 May 2017 10:44:06 +0000 (12:44 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 19 May 2017 09:36:43 +0000 (11:36 +0200)
Else we got infinite value if 0 and negative value doesn't make sense here.

Change-Id: Id65f0aa94cae32f1fea2c5c80028e328e6958a13
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/utils/timer.cpp

index 8c6215b..7edb0d5 100644 (file)
@@ -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