diff options
author | Paul Selkirk <paul@psgd.org> | 2015-10-31 23:05:05 -0400 |
---|---|---|
committer | Paul Selkirk <paul@psgd.org> | 2015-10-31 23:05:05 -0400 |
commit | 085e7317b3749c9f2a6339366a0b964b72b71973 (patch) | |
tree | 9a1a55b79064efc1c49aa2d157cf37ff5984b9ce /libc | |
parent | 9278e9bafd96105b64f9946eb94f5618f01649d3 (diff) |
add new test cases, add gettimeofday
Diffstat (limited to 'libc')
-rw-r--r-- | libc/gettimeofday.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/gettimeofday.c b/libc/gettimeofday.c new file mode 100644 index 0000000..b0561c3 --- /dev/null +++ b/libc/gettimeofday.c @@ -0,0 +1,26 @@ +#include <stdint.h> + +#include "stm32f4xx_hal.h" + +/* Don't #include <sys/time.h> because of conflicting prototype in newlib. */ + +/* from the manpage: */ +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of DST correction */ +}; + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + uint32_t tick = HAL_GetTick(); /* uptime in ms */ + + tv->tv_sec = tick / 1000; + tv->tv_usec = (tick % 1000) * 1000; + + return 0; +} |