File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 2222
2323#include "clock.h"
2424#include "dwt.h"
25+ #include <sys/time.h> // for struct timeval
2526
2627#ifdef __cplusplus
2728extern "C" {
@@ -86,6 +87,27 @@ static inline void delayMicroseconds(uint32_t us)
8687#endif
8788}
8889
90+ /**
91+ * \brief gives the number of seconds and microseconds since the Epoch
92+ *
93+ * based on millisecond since last power on.
94+ *
95+ * \note The function is declared as weak to be overwritten in case of other
96+ * implementations in user file (using RTC values for example).
97+ *
98+ * \param tv argument is a struct timeval
99+ * \param tz argument is a struct timezone (unused)
100+ *
101+ * \return 0
102+ */
103+ int __attribute__((weak )) _gettimeofday (struct timeval * tv , void * tz )
104+ {
105+ (void )tz ;
106+ tv -> tv_sec = getCurrentMillis () / 1000 ;
107+ tv -> tv_usec = getCurrentMicros () - (tv -> tv_sec * 1000000 ); // get remaining microseconds
108+ return 0 ;
109+ }
110+
89111#ifdef __cplusplus
90112}
91113#endif
You can’t perform that action at this time.
0 commit comments