mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 01:23:49 +01:00
tests: use coreclk() instead of CLOCK_CORECLOCK
This commit is contained in:
parent
2eb800cb8b
commit
ea3c59f41a
@ -23,6 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "macros/units.h"
|
#include "macros/units.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "clk.h"
|
||||||
|
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
@ -80,10 +81,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("{ \"result\" : %"PRIu32, n);
|
printf("{ \"result\" : %"PRIu32, n);
|
||||||
#ifdef CLOCK_CORECLOCK
|
|
||||||
printf(", \"ticks\" : %"PRIu32,
|
printf(", \"ticks\" : %"PRIu32,
|
||||||
(uint32_t)((TEST_DURATION_US/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
|
(uint32_t)((TEST_DURATION_US/US_PER_MS) * (coreclk()/KHZ(1)))/n);
|
||||||
#endif
|
|
||||||
puts(" }");
|
puts(" }");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "macros/units.h"
|
#include "macros/units.h"
|
||||||
|
#include "clk.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
@ -79,10 +80,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("{ \"result\" : %"PRIu32, n);
|
printf("{ \"result\" : %"PRIu32, n);
|
||||||
#ifdef CLOCK_CORECLOCK
|
|
||||||
printf(", \"ticks\" : %"PRIu32,
|
printf(", \"ticks\" : %"PRIu32,
|
||||||
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
|
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
|
||||||
#endif
|
|
||||||
puts(" }");
|
puts(" }");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "macros/units.h"
|
#include "macros/units.h"
|
||||||
|
#include "clk.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
@ -53,10 +54,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("{ \"result\" : %"PRIu32, n);
|
printf("{ \"result\" : %"PRIu32, n);
|
||||||
#ifdef CLOCK_CORECLOCK
|
|
||||||
printf(", \"ticks\" : %"PRIu32,
|
printf(", \"ticks\" : %"PRIu32,
|
||||||
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
|
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
|
||||||
#endif
|
|
||||||
puts(" }");
|
puts(" }");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "macros/units.h"
|
#include "macros/units.h"
|
||||||
|
#include "clk.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
#include "thread_flags.h"
|
#include "thread_flags.h"
|
||||||
@ -76,10 +77,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("{ \"result\" : %"PRIu32, n);
|
printf("{ \"result\" : %"PRIu32, n);
|
||||||
#ifdef CLOCK_CORECLOCK
|
|
||||||
printf(", \"ticks\" : %"PRIu32,
|
printf(", \"ticks\" : %"PRIu32,
|
||||||
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
|
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
|
||||||
#endif
|
|
||||||
puts(" }");
|
puts(" }");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "macros/units.h"
|
#include "macros/units.h"
|
||||||
|
#include "clk.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
|
|
||||||
@ -73,10 +74,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("{ \"result\" : %"PRIu32, n);
|
printf("{ \"result\" : %"PRIu32, n);
|
||||||
#ifdef CLOCK_CORECLOCK
|
|
||||||
printf(", \"ticks\" : %"PRIu32,
|
printf(", \"ticks\" : %"PRIu32,
|
||||||
(uint32_t)((TEST_DURATION/US_PER_MS) * (CLOCK_CORECLOCK/KHZ(1)))/n);
|
(uint32_t)((TEST_DURATION/US_PER_MS) * (coreclk()/KHZ(1)))/n);
|
||||||
#endif
|
|
||||||
puts(" }");
|
puts(" }");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -21,14 +21,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "clk.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "periph_conf.h"
|
#include "periph_conf.h"
|
||||||
|
|
||||||
#ifdef CLOCK_CORECLOCK
|
#define DELAY_SHORT (coreclk() / 50)
|
||||||
#define DELAY_SHORT (CLOCK_CORECLOCK / 50)
|
|
||||||
#else
|
|
||||||
#define DELAY_SHORT (500000UL)
|
|
||||||
#endif
|
|
||||||
#define DELAY_LONG (DELAY_SHORT * 4)
|
#define DELAY_LONG (DELAY_SHORT * 4)
|
||||||
|
|
||||||
void dumb_delay(uint32_t delay)
|
void dumb_delay(uint32_t delay)
|
||||||
|
|||||||
@ -37,7 +37,7 @@ BOARDS_TIMER_32kHz := \
|
|||||||
stk3700 \
|
stk3700 \
|
||||||
#
|
#
|
||||||
|
|
||||||
BOARDS_TIMER_CLOCK_CORECLOCK := \
|
BOARDS_TIMER_SYSCLK := \
|
||||||
cc2538dk \
|
cc2538dk \
|
||||||
openmote-b \
|
openmote-b \
|
||||||
openmote-cc2538 \
|
openmote-cc2538 \
|
||||||
@ -52,8 +52,8 @@ else ifneq (,$(filter $(BOARDS_TIMER_250kHz),$(BOARD)))
|
|||||||
TIMER_SPEED ?= 250000
|
TIMER_SPEED ?= 250000
|
||||||
else ifneq (,$(filter $(BOARDS_TIMER_32kHz),$(BOARD)))
|
else ifneq (,$(filter $(BOARDS_TIMER_32kHz),$(BOARD)))
|
||||||
TIMER_SPEED ?= 32768
|
TIMER_SPEED ?= 32768
|
||||||
else ifneq (,$(filter $(BOARDS_TIMER_CLOCK_CORECLOCK),$(BOARD)))
|
else ifneq (,$(filter $(BOARDS_TIMER_SYSCLK),$(BOARD)))
|
||||||
TIMER_SPEED ?= CLOCK_CORECLOCK
|
TIMER_SPEED ?= coreclk\(\)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TIMER_SPEED ?= 1000000
|
TIMER_SPEED ?= 1000000
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "clk.h"
|
||||||
#include "periph/timer.h"
|
#include "periph/timer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "clk.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "periph/uart.h"
|
#include "periph/uart.h"
|
||||||
#include "periph_conf.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
|
* compilers would detect that the loop is only wasting CPU cycles and
|
||||||
* optimize it out - but here the wasting of CPU cycles is desired.
|
* 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++) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user