From 396f6c2819f2fd60db70ce416613f16579a33674 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 14 Jan 2014 17:23:03 +0100 Subject: [PATCH 1/5] fix debug msg --- cpu/native/hwtimer_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index ba23db9344..91cb7cdb70 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -249,7 +249,7 @@ void hwtimer_arch_set_absolute(unsigned long value, short timer) ticks2tv(value, &(native_hwtimer[timer].it_value)); - DEBUG("hwtimer_arch_set_absolute(): that is %lu s %lu us from now\n", + DEBUG("hwtimer_arch_set_absolute(): that is at %lu s %lu us\n", (unsigned long)native_hwtimer[timer].it_value.tv_sec, (unsigned long)native_hwtimer[timer].it_value.tv_usec); From 921b70d5e8632764b96e4b60f1fd8bf57794bd09 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Tue, 14 Jan 2014 17:23:15 +0100 Subject: [PATCH 2/5] fix pre-init set the internal relative time - don't rely on hwtimer_now() being called externally --- cpu/native/hwtimer_cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index 91cb7cdb70..8e73595067 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -300,6 +300,7 @@ void native_hwtimer_pre_init() /* initialize time delta */ time_null = 0; time_null = hwtimer_arch_now(); + hwtimer_arch_now(); } void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) From d3a1c1bda70f8e33f9ec9d5ca4c8cf4aa753b6a3 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 15 Jan 2014 11:24:59 +0100 Subject: [PATCH 3/5] add comment addresses https://github.com/RIOT-OS/RIOT/pull/501#discussion_r8881054 --- cpu/native/hwtimer_cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index 8e73595067..d87a64d901 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -300,6 +300,8 @@ void native_hwtimer_pre_init() /* initialize time delta */ time_null = 0; time_null = hwtimer_arch_now(); + /* need to call hwtimer_arch_now as hwtimer_arch_now uses + * time_null to delta native_hwtimer_now: */ hwtimer_arch_now(); } From dbcc898bcc5c3d39eac60deface22caaf7c06dce Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 15 Jan 2014 12:24:28 +0100 Subject: [PATCH 4/5] update internal timer on hwtimer_arch_set --- cpu/native/hwtimer_cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index d87a64d901..069c5c5da0 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -237,6 +237,7 @@ void hwtimer_arch_set(unsigned long offset, short timer) { DEBUG("hwtimer_arch_set(%lu, \033[31m%i\033[0m)\n", offset, timer); + hwtimer_arch_now(); /* update native_hwtimer_now */ offset += native_hwtimer_now; hwtimer_arch_set_absolute(offset, timer); From fc6cd24eceba2a026b226dff1dac19068cbec105 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 15 Jan 2014 12:36:58 +0100 Subject: [PATCH 5/5] reduce HWTIMERMINOFFSET --- cpu/native/hwtimer_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c index 069c5c5da0..257b815944 100644 --- a/cpu/native/hwtimer_cpu.c +++ b/cpu/native/hwtimer_cpu.c @@ -46,7 +46,7 @@ #include "debug.h" -#define HWTIMERMINOFFSET (10 * 1000UL) // 10 ms +#define HWTIMERMINOFFSET (1000UL) // 1ms static unsigned long native_hwtimer_now; static unsigned long time_null;