File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 22
22
23
23
#include "clock.h"
24
24
#include "dwt.h"
25
+ #include <sys/time.h> // for struct timeval
25
26
26
27
#ifdef __cplusplus
27
28
extern "C" {
@@ -86,6 +87,27 @@ static inline void delayMicroseconds(uint32_t us)
86
87
#endif
87
88
}
88
89
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
+
89
111
#ifdef __cplusplus
90
112
}
91
113
#endif
You can’t perform that action at this time.
0 commit comments