Added time functions

This commit is contained in:
dario 2024-05-17 01:44:19 +02:00
parent 71ba6af7e1
commit 0fc3f71d5a
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#ifndef STA_DEVICES_ARDUINO_TIME_HPP
#define STA_DEVICES_ARDUINO_TIME_HPP
#include <sta/config.hpp>
#ifdef STA_PLATFORM_ARDUINO
#include <cstdint>
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

View File

@ -0,0 +1,19 @@
#include <sta/devices/arduino/time.hpp>
#ifdef STA_PLATFORM_ARDUINO
#include <sta/devices/arduino/hal.hpp>
namespace sta
{
uint32_t now()
{
return millis();
}
uint32_t nowUs()
{
return micros();
}
} // namespace sta
#endif // STA_PLATFORM_ARDUINO