1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests: use coreclk() instead of CLOCK_CORECLOCK

This commit is contained in:
Alexandre Abadie 2021-12-05 11:55:35 +01:00
parent 2eb800cb8b
commit ea3c59f41a
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
9 changed files with 19 additions and 24 deletions

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include "macros/units.h"
#include "thread.h"
#include "clk.h"
#include "msg.h"
#include "xtimer.h"
@ -80,10 +81,8 @@ int main(void)
}
printf("{ \"result\" : %"PRIu32, n);
#ifdef CLOCK_CORECLOCK
printf(", \"ticks\" : %"PRIu32,
(uint32_t)((TEST_DURATION_US/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
#endif
(uint32_t)((TEST_DURATION_US/US_PER_MS) * (coreclk()/KHZ(1)))/n);
puts(" }");
return 0;

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include "macros/units.h"
#include "clk.h"
#include "mutex.h"
#include "thread.h"
#include "xtimer.h"
@ -79,10 +80,8 @@ int main(void)
}
printf("{ \"result\" : %"PRIu32, n);
#ifdef CLOCK_CORECLOCK
printf(", \"ticks\" : %"PRIu32,
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
#endif
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
puts(" }");
return 0;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include "macros/units.h"
#include "clk.h"
#include "thread.h"
#include "xtimer.h"
@ -53,10 +54,8 @@ int main(void)
}
printf("{ \"result\" : %"PRIu32, n);
#ifdef CLOCK_CORECLOCK
printf(", \"ticks\" : %"PRIu32,
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
#endif
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
puts(" }");
return 0;

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include "macros/units.h"
#include "clk.h"
#include "thread.h"
#include "thread_flags.h"
@ -76,10 +77,8 @@ int main(void)
}
printf("{ \"result\" : %"PRIu32, n);
#ifdef CLOCK_CORECLOCK
printf(", \"ticks\" : %"PRIu32,
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
#endif
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
puts(" }");
return 0;

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include "macros/units.h"
#include "clk.h"
#include "thread.h"
#include "xtimer.h"
@ -73,10 +74,8 @@ int main(void)
}
printf("{ \"result\" : %"PRIu32, n);
#ifdef CLOCK_CORECLOCK
printf(", \"ticks\" : %"PRIu32,
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
#endif
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
puts(" }");
return 0;

View File

@ -21,14 +21,11 @@
#include <stdio.h>
#include <stdint.h>
#include "clk.h"
#include "board.h"
#include "periph_conf.h"
#ifdef CLOCK_CORECLOCK
#define DELAY_SHORT (CLOCK_CORECLOCK / 50)
#else
#define DELAY_SHORT (500000UL)
#endif
#define DELAY_SHORT (coreclk() / 50)
#define DELAY_LONG (DELAY_SHORT * 4)
void dumb_delay(uint32_t delay)

View File

@ -37,7 +37,7 @@ BOARDS_TIMER_32kHz := \
stk3700 \
#
BOARDS_TIMER_CLOCK_CORECLOCK := \
BOARDS_TIMER_SYSCLK := \
cc2538dk \
openmote-b \
openmote-cc2538 \
@ -52,8 +52,8 @@ else ifneq (,$(filter $(BOARDS_TIMER_250kHz),$(BOARD)))
TIMER_SPEED ?= 250000
else ifneq (,$(filter $(BOARDS_TIMER_32kHz),$(BOARD)))
TIMER_SPEED ?= 32768
else ifneq (,$(filter $(BOARDS_TIMER_CLOCK_CORECLOCK),$(BOARD)))
TIMER_SPEED ?= CLOCK_CORECLOCK
else ifneq (,$(filter $(BOARDS_TIMER_SYSCLK),$(BOARD)))
TIMER_SPEED ?= coreclk\(\)
endif
TIMER_SPEED ?= 1000000

View File

@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "clk.h"
#include "periph/timer.h"
/**

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
#include "clk.h"
#include "board.h"
#include "periph/uart.h"
#include "periph_conf.h"
@ -69,7 +70,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++) { }
}
}