diff --git a/firmware/drivers/ptimer/ptimer.cpp b/firmware/drivers/ptimer/ptimer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09c510c1363cf62a0420a456d18d3f93e1db64fd --- /dev/null +++ b/firmware/drivers/ptimer/ptimer.cpp @@ -0,0 +1,11 @@ +#include <ptimer.hpp> + +unsigned long PTimer::start_t_ = 0; + +void PTimer::start(){ + start_t_ = micros(); +} + +unsigned long PTimer::elapsed(){ + return static_cast<unsigned long>(micros - start_t_);; +} diff --git a/firmware/drivers/ptimer/ptimer.hpp b/firmware/drivers/ptimer/ptimer.hpp new file mode 100644 index 0000000000000000000000000000000000000000..de4f84342b8e7861a9bf05c817cf4e827306760b --- /dev/null +++ b/firmware/drivers/ptimer/ptimer.hpp @@ -0,0 +1,11 @@ +#ifndef PTIMER_HPP_INCLUDED +#define PTIMER_HPP_INCLUDED +class PTimer{ +public: + static void start(); + //returns the elapsed time in microseconds + static unsigned long elapsed() const; +private: + static unsigned long start_t_; +}; +#endif