[riot-notifications] [RIOT-OS/RIOT] rtt_rtc: add rtc_settimeofday() & rtc_gettimeofday() (#16682)

benpicco notifications at github.com
Mon Jul 26 23:30:31 CEST 2021


@benpicco commented on this pull request.



> +    rtc_now      = s;
+    rtt_set_counter(now);
+    /* calculate next wake-up period */
+    _update_alarm(0);
+}
+
+void rtc_gettimeofday(uint32_t *s, uint32_t *us)
+{
+    uint32_t prev = rtc_now;
+
+    /* repeat calculation if an alarm triggered in between */
+    do {
+        uint32_t now = rtt_get_counter();
+        *s  = _rtc_now(now);
+        *us = ((uint64_t)SUBSECONDS(now - last_alarm) * US_PER_SEC) / RTT_SECOND;
+    } while (prev != rtc_now);

Huh good catch! This had slipped in earlier for `rtc_get_time()` as well.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16682#discussion_r676958044
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210726/700a2be8/attachment.htm>


More information about the notifications mailing list