Skip to content
Snippets Groups Projects
Commit 21238b2c authored by Kaspar Schleiser's avatar Kaspar Schleiser
Browse files

Merge pull request #3347 from benoit-canet/timer

native: timer: synchronize HWTIMER_SPIN_BARRIER with native timer min resolution
parents 3d994566 e0132979
Branches
No related tags found
No related merge requests found
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
* @} * @}
*/ */
#include "periph_conf.h"
#ifndef HWTIMER_CPU_H_ #ifndef HWTIMER_CPU_H_
#define HWTIMER_CPU_H_ #define HWTIMER_CPU_H_
...@@ -24,7 +26,7 @@ extern "C" { ...@@ -24,7 +26,7 @@ extern "C" {
#define HWTIMER_MAXTIMERS 1 #define HWTIMER_MAXTIMERS 1
#define HWTIMER_SPEED 1000000 #define HWTIMER_SPEED 1000000
#define HWTIMER_MAXTICKS (0xFFFFFFFF) #define HWTIMER_MAXTICKS (0xFFFFFFFF)
#define HWTIMER_SPIN_BARRIER 20 #define HWTIMER_SPIN_BARRIER NATIVE_TIMER_MIN_RES
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
extern "C" { extern "C" {
#endif #endif
/**
* @name hardware timer clock skew avoidance
* @{
*/
#define NATIVE_TIMER_MIN_RES 200
/** @} */
/** /**
* @name Random Number Generator configuration * @name Random Number Generator configuration
* @{ * @{
......
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
#define NATIVE_TIMER_SPEED 1000000 #define NATIVE_TIMER_SPEED 1000000
#define NATIVE_TIMER_MIN_RES 200
static unsigned long time_null; static unsigned long time_null;
static void (*_callback)(int); static void (*_callback)(int);
......
...@@ -32,7 +32,7 @@ int main(void) ...@@ -32,7 +32,7 @@ int main(void)
" this test was successful."); " this test was successful.");
puts("If you do not see that message, something went wrong.\n"); puts("If you do not see that message, something went wrong.\n");
for (unsigned long r = 10000; r > 0; r--) { for (unsigned long r = 1000; r > 0; r--) {
for (unsigned long i = HWTIMER_SPIN_BARRIER; i > 0; i--) { for (unsigned long i = HWTIMER_SPIN_BARRIER; i > 0; i--) {
hwtimer_wait(i); hwtimer_wait(i);
} }
......
...@@ -29,7 +29,7 @@ int main(void) ...@@ -29,7 +29,7 @@ int main(void)
puts("This is a regression test for a race condition in hwtimer_wait."); puts("This is a regression test for a race condition in hwtimer_wait.");
puts("When the race condition is hit, the timer will wait for a very very long time."); puts("When the race condition is hit, the timer will wait for a very very long time.");
long iterations = 10000; long iterations = 1000;
long start_duration = (HWTIMER_SPIN_BARRIER + 1) << 5; long start_duration = (HWTIMER_SPIN_BARRIER + 1) << 5;
long duration = iterations * start_duration * 2L; long duration = iterations * start_duration * 2L;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment