diff --git a/cores/arduino/wiring_time.h b/cores/arduino/wiring_time.h index 74b1978c92..4b32537629 100644 --- a/cores/arduino/wiring_time.h +++ b/cores/arduino/wiring_time.h @@ -22,6 +22,7 @@ #include "clock.h" #include "dwt.h" +#include // for struct timeval #ifdef __cplusplus extern "C" { @@ -86,6 +87,27 @@ static inline void delayMicroseconds(uint32_t us) #endif } +/** + * \brief gives the number of seconds and microseconds since the Epoch + * + * based on millisecond since last power on. + * + * \note The function is declared as weak to be overwritten in case of other + * implementations in user file (using RTC values for example). + * + * \param tv argument is a struct timeval + * \param tz argument is a struct timezone (unused) + * + * \return 0 + */ +int __attribute__((weak)) _gettimeofday(struct timeval *tv, void *tz) +{ + (void)tz; + tv->tv_sec = getCurrentMillis() / 1000; + tv->tv_usec = getCurrentMicros() - (tv->tv_sec * 1000000); // get remaining microseconds + return 0; +} + #ifdef __cplusplus } #endif pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy