X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Ftimer.c;h=d832059086a563134303e16f87146f5cd1691bba;hb=fbb255258c626502f8d7ba583ca138f903e03b75;hp=f282478aa361a42e77e69762ffab5f8fbabbf968;hpb=111a5049211f2adee08a0e483bfd560f3ee88e14;p=bertos.git diff --git a/bertos/drv/timer.c b/bertos/drv/timer.c index f282478a..d8320590 100644 --- a/bertos/drv/timer.c +++ b/bertos/drv/timer.c @@ -40,7 +40,8 @@ #include "cfg/cfg_timer.h" #include "cfg/cfg_wdt.h" -#include "cfg/cfg_kern.h" +#include "cfg/cfg_proc.h" +#include "cfg/cfg_signal.h" #include #include #include @@ -48,22 +49,27 @@ #include #include #include +#include // cpu_relax() /* * Include platform-specific binding code if we're hosted. * Try the CPU specific one for bare-metal environments. */ #if OS_HOSTED - #include OS_CSOURCE(timer) + //#include OS_CSOURCE(timer) + #include #else - #include CPU_CSOURCE(timer) + #ifndef WIZ_AUTOGEN + #warning Deprecated: now you should include timer_ directly in the makefile. Remove this line and the following once done. + #include CPU_CSOURCE(timer) + #endif #endif /* * Sanity check for config parameters required by this module. */ -#if !defined(CONFIG_KERNEL) || ((CONFIG_KERNEL != 0) && CONFIG_KERNEL != 1) - #error CONFIG_KERNEL must be set to either 0 or 1 in config.h +#if !defined(CONFIG_KERN) || ((CONFIG_KERN != 0) && CONFIG_KERN != 1) + #error CONFIG_KERN must be set to either 0 or 1 in config.h #endif #if !defined(CONFIG_WATCHDOG) || ((CONFIG_WATCHDOG != 0) && CONFIG_WATCHDOG != 1) #error CONFIG_WATCHDOG must be set to either 0 or 1 in config.h @@ -73,12 +79,10 @@ #include #endif -#if CONFIG_KERNEL - #if CONFIG_KERN_SIGNALS - #include /* sig_wait(), sig_check() */ - #include /* proc_current() */ - #include /* BV() */ - #endif +#if defined (CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS + #include /* sig_wait(), sig_check() */ + #include /* proc_current() */ + #include /* BV() */ #endif @@ -121,7 +125,7 @@ REGISTER static List timers_queue; void timer_add(Timer *timer) { Timer *node; - cpuflags_t flags; + cpu_flags_t flags; /* Inserting timers twice causes mayhem. */ @@ -181,7 +185,7 @@ Timer *timer_abort(Timer *timer) void timer_delayTicks(ticks_t delay) { /* We shouldn't sleep with interrupts disabled */ - ASSERT_IRQ_ENABLED(); + IRQ_ASSERT_ENABLED(); #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS Timer t; @@ -198,11 +202,7 @@ void timer_delayTicks(ticks_t delay) /* Busy wait */ while (timer_clock() - start < delay) - { -#if CONFIG_WATCHDOG - wdt_reset(); -#endif - } + cpu_relax(); #endif /* !CONFIG_KERN_SIGNALS */ } @@ -324,11 +324,15 @@ MOD_DEFINE(timer) */ void timer_init(void) { - TIMER_STROBE_INIT; + #if CONFIG_KERN_IRQ + MOD_CHECK(irq); + #endif -#if CONFIG_TIMER_EVENTS - LIST_INIT(&timers_queue); -#endif + #if CONFIG_TIMER_EVENTS + LIST_INIT(&timers_queue); + #endif + + TIMER_STROBE_INIT; _clock = 0;