aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding/utils/timer.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-16 12:44:06 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-19 11:36:43 +0200
commit8e67e90410d448d2dc3340795ca8de414d1fe3a9 (patch)
tree1f7d228973a4598bb3aeb34877c84c63037f4ce9 /CAN-binder/low-can-binding/utils/timer.cpp
parent6d7ae0d5683b89e5d64718f4f6bf71b335709ff5 (diff)
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils/timer.cpp')
-rw-r--r--CAN-binder/low-can-binding/utils/timer.cpp5
1 files changed, 4 insertions, 1 deletions
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