diff options
| author | Jeff Epler <jeff@adafruit.com> | 2020-06-01 08:16:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-01 08:16:59 -0500 |
| commit | cd5577c4d9b024ee1fe20f8f43c506d6b82eee2d (patch) | |
| tree | a01c9a35f1254abc080665bb02c90e3adcacc6a8 | |
| parent | 47efd595fce11240f92efecf768800e8d81fa702 (diff) | |
| parent | ce337eaa27805428b1245502b75e56ae63b8422d (diff) | |
Merge pull request #2987 from kamtom480/spresense-raw-ticks
spresense: Fix port_get_raw_ticks
| -rw-r--r-- | ports/cxd56/supervisor/port.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index 9ec9dbfdf..a7e9c30a3 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -29,6 +29,8 @@ #include <sys/boardctl.h> #include <sys/time.h> +#include <cxd56_rtc.h> + #include "sched/sched.h" #include "boards/board.h" @@ -45,7 +47,8 @@ safe_mode_t port_init(void) { boardctl(BOARDIOC_INIT, 0); - board_init(); + // Wait until RTC is available + while (g_rtc_enabled == false); if (board_requests_safe_mode()) { return USER_SAFE_MODE; @@ -121,14 +124,10 @@ void board_timerhook(void) } uint64_t port_get_raw_ticks(uint8_t* subticks) { - struct timeval tv; - gettimeofday(&tv, NULL); - long computed_subticks = tv.tv_usec * 1024 * 32 / 1000000; - if (subticks != NULL) { - *subticks = computed_subticks % 32; - } + uint64_t count = cxd56_rtc_count(); + *subticks = count % 32; - return tv.tv_sec * 1024 + computed_subticks / 32; + return count / 32; } // Enable 1/1024 second tick. |
