From 91927c988b2d665c99d1958cad35458675f514c5 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sun, 5 Dec 2021 11:55:56 +0100 Subject: [PATCH] examples/blinky: use coreclk() instead of CLOCK_CORECLOCK --- examples/blinky/Makefile | 6 ------ examples/blinky/main.c | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/blinky/Makefile b/examples/blinky/Makefile index 904e9ead10..2d58be2d6b 100644 --- a/examples/blinky/Makefile +++ b/examples/blinky/Makefile @@ -19,9 +19,3 @@ QUIET ?= 1 FEATURES_OPTIONAL += periph_timer include $(RIOTBASE)/Makefile.include - -ifeq (native,$(BOARD)) - # For the native board, CLOCK_CORECLOCK is undefined. But we need - # a valid number to get the example compiled - CFLAGS += -DCLOCK_CORECLOCK=1000000000 -endif diff --git a/examples/blinky/main.c b/examples/blinky/main.c index 038cd27d6d..ac90ccbc15 100644 --- a/examples/blinky/main.c +++ b/examples/blinky/main.c @@ -20,6 +20,7 @@ #include +#include "clk.h" #include "board.h" #include "periph_conf.h" #include "timex.h" @@ -41,7 +42,8 @@ static void delay(void) * 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++) { } + uint32_t loops = coreclk() / 20; + for (volatile uint32_t i = 0; i < loops; i++) { } } }