X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Femul%2Ftimer_posix.c;h=ede534063a3fd05100acebe729dc5ed2b18a02ae;hb=780f975602d282f0d2599e6601d7fee29d493762;hp=b83480571ac8c830f903a8707429bf8e720875a4;hpb=33327d3ad4d417bd91894562ba11467744751a3c;p=bertos.git diff --git a/bertos/emul/timer_posix.c b/bertos/emul/timer_posix.c index b8348057..ede53406 100644 --- a/bertos/emul/timer_posix.c +++ b/bertos/emul/timer_posix.c @@ -26,14 +26,12 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2005,2008 Develer S.r.l. (http://www.develer.com/) - * + * Copyright 2005, 2008 Develer S.r.l. (http://www.develer.com/) * --> * * \version $Id$ * * \author Bernie Innocenti - * * \brief Low-level timer module for Qt emulator (implementation). */ #include // hptime.t @@ -50,6 +48,9 @@ void timer_isr(int); /// HW dependent timer initialization. static void timer_hw_init(void) { +#if CONFIG_KERN_IRQ + irq_register(SIGALRM, timer_isr); +#else // ! CONFIG_KERN_IRQ struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -59,9 +60,10 @@ static void timer_hw_init(void) sigaddset(&sa.sa_mask, SIGALRM); sa.sa_flags = SA_RESTART; sigaction(SIGALRM, &sa, NULL); +#endif // CONFIG_KERN_IRQ // Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC. - static struct itimerval itv = + static const struct itimerval itv = { { 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */ { 0, 1000000 / TIMER_TICKS_PER_SEC } /* it_value */ @@ -69,6 +71,16 @@ static void timer_hw_init(void) setitimer(ITIMER_REAL, &itv, NULL); } +static void timer_hw_cleanup(void) +{ + static const struct itimerval itv = + { + { 0, 0 }, /* it_interval */ + { 0, 0 } /* it_value */ + }; + setitimer(ITIMER_REAL, &itv, NULL); +} + INLINE hptime_t timer_hw_hpread(void) { return hptime_get();