F´ Flight Software - C/C++ Documentation  NASA-v2.0.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IntervalTimer.cpp
Go to the documentation of this file.
1 
14 #include <Os/IntervalTimer.hpp>
15 #include <Fw/Types/Assert.hpp>
16 #include <string.h>
17 
18 namespace Os {
19 
20  // Adapted from: http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
21  // should be t1In - t2In
22  U32 IntervalTimer::getDiffUsec(const RawTime& t1In, const RawTime& t2In) {
23  RawTime result = {t1In.upper - t2In.upper, 0};
24  if (t1In.lower < t2In.lower) {
25  result.upper -= 1; // subtract nsec carry to seconds
26  result.lower = t1In.lower + (1000000000 - t2In.lower);
27  } else {
28  result.lower = t1In.lower - t2In.lower;
29  }
30  return (result.upper * 1000000) + (result.lower / 1000);
31  }
32 }
Os
Definition: File.cpp:7
IntervalTimer.hpp
Os::IntervalTimer::getDiffUsec
U32 getDiffUsec(void)
Definition: IntervalTimerCommon.cpp:34
Assert.hpp