mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
add gettimeofday function
This commit is contained in:
parent
0c68b9fba5
commit
19fd519209
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue