From: asterix Date: Tue, 20 May 2008 09:15:35 +0000 (+0000) Subject: Move timer posix module in emul dir. X-Git-Tag: 2.0.0~645 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=c579caa5998bcdf6c7620b9547da68caec9e658a;p=bertos.git Move timer posix module in emul dir. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1289 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/timer_posix.c b/bertos/drv/timer_posix.c deleted file mode 100644 index e6149cea..00000000 --- a/bertos/drv/timer_posix.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * - * - * \version $Id$ - * - * \author Bernardo Innocenti - * - * \brief Low-level timer module for Qt emulator (implementation). - */ -#include // hptime.t -#include - -#include // sigaction() -#include // setitimer() -#include // memset() - - -// Forward declaration for the user interrupt server routine. -void timer_isr(int); - -/// HW dependent timer initialization. -static void timer_hw_init(void) -{ - struct sigaction sa; - memset(&sa, 0, sizeof(sa)); - - // Setup interrupt callback - sa.sa_handler = timer_isr; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGALRM); - sa.sa_flags = SA_RESTART; - sigaction(SIGALRM, &sa, NULL); - - // Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC. - static struct itimerval itv = - { - { 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */ - { 0, 1000000 / TIMER_TICKS_PER_SEC } /* it_value */ - }; - setitimer(ITIMER_REAL, &itv, NULL); -} - -INLINE hptime_t timer_hw_hpread(void) -{ - return hptime_get(); -} diff --git a/bertos/drv/timer_posix.h b/bertos/drv/timer_posix.h deleted file mode 100644 index fd2e9c60..00000000 --- a/bertos/drv/timer_posix.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file - * - * - * \version $Id$ - * - * \author Bernardo Innocenti - * - * \brief Low-level timer module for POSIX systems (interface). - */ -#ifndef DRV_TIMER_POSIX_H -#define DRV_TIMER_POSIX_H - -// HW dependent timer initialization - -#define DEFINE_TIMER_ISR void timer_isr(UNUSED_ARG(int, arg)) - -/** Most Linux kernels can't do better than this (CONFIG_HZ=250). */ -#define TIMER_TICKS_PER_SEC 250 - -#define TIMER_HW_CNT (1<<31) /* We assume 32bit integers here */ - -#include - -/// Frequency of the hardware high-precision timer. -#define TIMER_HW_HPTICKS_PER_SEC HPTIME_TICKS_PER_SECOND - -/// Not needed. -#define timer_hw_irq() do {} while (0) - -#endif /* DRV_TIMER_POSIX_H */ diff --git a/bertos/emul/timer_posix.c b/bertos/emul/timer_posix.c new file mode 100644 index 00000000..e6149cea --- /dev/null +++ b/bertos/emul/timer_posix.c @@ -0,0 +1,75 @@ +/** + * \file + * + * + * \version $Id$ + * + * \author Bernardo Innocenti + * + * \brief Low-level timer module for Qt emulator (implementation). + */ +#include // hptime.t +#include + +#include // sigaction() +#include // setitimer() +#include // memset() + + +// Forward declaration for the user interrupt server routine. +void timer_isr(int); + +/// HW dependent timer initialization. +static void timer_hw_init(void) +{ + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + + // Setup interrupt callback + sa.sa_handler = timer_isr; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGALRM); + sa.sa_flags = SA_RESTART; + sigaction(SIGALRM, &sa, NULL); + + // Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC. + static struct itimerval itv = + { + { 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */ + { 0, 1000000 / TIMER_TICKS_PER_SEC } /* it_value */ + }; + setitimer(ITIMER_REAL, &itv, NULL); +} + +INLINE hptime_t timer_hw_hpread(void) +{ + return hptime_get(); +} diff --git a/bertos/emul/timer_posix.h b/bertos/emul/timer_posix.h new file mode 100644 index 00000000..fd2e9c60 --- /dev/null +++ b/bertos/emul/timer_posix.h @@ -0,0 +1,59 @@ +/** + * \file + * + * + * \version $Id$ + * + * \author Bernardo Innocenti + * + * \brief Low-level timer module for POSIX systems (interface). + */ +#ifndef DRV_TIMER_POSIX_H +#define DRV_TIMER_POSIX_H + +// HW dependent timer initialization + +#define DEFINE_TIMER_ISR void timer_isr(UNUSED_ARG(int, arg)) + +/** Most Linux kernels can't do better than this (CONFIG_HZ=250). */ +#define TIMER_TICKS_PER_SEC 250 + +#define TIMER_HW_CNT (1<<31) /* We assume 32bit integers here */ + +#include + +/// Frequency of the hardware high-precision timer. +#define TIMER_HW_HPTICKS_PER_SEC HPTIME_TICKS_PER_SECOND + +/// Not needed. +#define timer_hw_irq() do {} while (0) + +#endif /* DRV_TIMER_POSIX_H */