Skip to content

Commit f459bc0

Browse files
committed
Potential fix for gettimeofday for Arduino
1 parent c6d562e commit f459bc0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/utils.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ int add_iso8601_utc_datetime(char* buf, size_t size) {
184184

185185
#endif
186186

187+
#ifdef ARDUINO
188+
189+
int64_t usec_now()
190+
{
191+
return micros();
192+
}
193+
194+
void get_time(uint32_t *seconds, uint32_t *micro_seconds)
195+
{
196+
*micro_seconds = micros();
197+
*seconds = *micro_seconds / 1000000;
198+
*micro_seconds %= 1000000;
199+
}
200+
201+
#else
202+
187203
int64_t usec_now()
188204
{
189205
int64_t usec;
@@ -204,6 +220,8 @@ void get_time(uint32_t *seconds, uint32_t *micro_seconds)
204220
*micro_seconds = tv.tv_usec;
205221
}
206222

223+
#endif
224+
207225
int64_t usec_since(int64_t last)
208226
{
209227
return usec_now() - last;

0 commit comments

Comments
 (0)