summaryrefslogtreecommitdiffstats
path: root/watch-library
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-01-15 12:22:42 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-01-15 12:26:17 -0500
commit19fd519209d20cb9ee4099715f7086b3b476e60c (patch)
tree9fb28f2fb9d4b5df4848ed45a5bb17d3e256d0c0 /watch-library
parent0c68b9fba520d0e28cf570eeeaee4e3207b9e21f (diff)
downloadSensor-Watch-19fd519209d20cb9ee4099715f7086b3b476e60c.tar.gz
Sensor-Watch-19fd519209d20cb9ee4099715f7086b3b476e60c.tar.bz2
Sensor-Watch-19fd519209d20cb9ee4099715f7086b3b476e60c.zip
add gettimeofday function
Diffstat (limited to 'watch-library')
-rw-r--r--watch-library/watch/watch_private.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/watch-library/watch/watch_private.c b/watch-library/watch/watch_private.c
index b52c8e4c..ae2589e7 100644
--- a/watch-library/watch/watch_private.c
+++ b/watch-library/watch/watch_private.c
@@ -23,6 +23,7 @@
*/
#include "watch_private.h"
+#include "watch_utility.h"
#include "tusb.h"
void _watch_init(void) {
@@ -97,6 +98,17 @@ int getentropy(void *buf, size_t buflen) {
return 0;
}
+int _gettimeofday(struct timeval *tv, void *tzvp) {
+ (void)tzvp;
+ watch_date_time date_time = watch_rtc_get_date_time();
+
+ // FIXME: this assumes the system time is UTC! Will break for any other time zone.
+ tv->tv_sec = watch_utility_date_time_to_unix_time(date_time, 0);
+ tv->tv_usec = 0;
+
+ return 0;
+}
+
void _watch_enable_tcc(void) {
// clock TCC0 with the main clock (8 MHz) and enable the peripheral clock.
hri_gclk_write_PCHCTRL_reg(GCLK, TCC0_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK0_Val | GCLK_PCHCTRL_CHEN);