From 0fc3f71d5aa2ccf24478f986114b4b0b87e200bd Mon Sep 17 00:00:00 2001 From: dario Date: Fri, 17 May 2024 01:44:19 +0200 Subject: [PATCH] Added time functions --- include/sta/devices/arduino/time.hpp | 28 ++++++++++++++++++++++++++++ src/devices/arduino/time.cpp | 19 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 include/sta/devices/arduino/time.hpp create mode 100644 src/devices/arduino/time.cpp diff --git a/include/sta/devices/arduino/time.hpp b/include/sta/devices/arduino/time.hpp new file mode 100644 index 0000000..8d811e3 --- /dev/null +++ b/include/sta/devices/arduino/time.hpp @@ -0,0 +1,28 @@ +#ifndef STA_DEVICES_ARDUINO_TIME_HPP +#define STA_DEVICES_ARDUINO_TIME_HPP + +#include +#ifdef STA_PLATFORM_ARDUINO + +#include + +namespace sta +{ + /** + * @brief The current time in milliseconds. + * + * @return uint32_t Returns current time in milliseconds. + */ + uint32_t now(); + + /** + * @brief The current time in microseconds. + * + * @return uint32_t Returns the current time in microseconds. + */ + uint32_t nowUs(); +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO + +#endif // STA_DEVICES_ARDUINO_TIME_HPP \ No newline at end of file diff --git a/src/devices/arduino/time.cpp b/src/devices/arduino/time.cpp new file mode 100644 index 0000000..8597c6c --- /dev/null +++ b/src/devices/arduino/time.cpp @@ -0,0 +1,19 @@ +#include + +#ifdef STA_PLATFORM_ARDUINO +#include + +namespace sta +{ + uint32_t now() + { + return millis(); + } + + uint32_t nowUs() + { + return micros(); + } +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO