[riot-notifications] [RIOT-OS/RIOT] tests/periph_uart_mode: Drop dep to periph_timer (#16637)

Marian Buschsieweke notifications at github.com
Wed Jul 14 13:18:44 CEST 2021


@maribu commented on this pull request.



> +{
+    if (IS_USED(MODULE_XTIMER)) {
+        xtimer_usleep(DELAY_US);
+    }
+    else {
+        /*
+         * As fallback for freshly ported boards with no timer drivers written
+         * yet, we just use the CPU to delay execution and assume that roughly
+         * 20 CPU cycles are spend per loop iteration.
+         *
+         * Note that the volatile qualifier disables compiler optimizations for
+         * all accesses to the counter variable. Without volatile, modern
+         * compilers would detect that the loop is only wasting CPU cycles and
+         * optimize it out - but here the wasting of CPU cycles is desired.
+         */
+        for (volatile uint32_t i = 0; i < CLOCK_CORECLOCK / 20; i++) { }

Maybe even one that prefers to call into ztimer / xtimer instead, if already used.

-- 
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/16637#discussion_r669519316
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210714/23902f21/attachment.htm>


More information about the notifications mailing list