4 * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
10 * \author Bernardo Innocenti <bernie@develer.com>
12 * \brief Low-level timer module for Qt emulator (implementation).
17 *#* Revision 1.3 2006/02/10 12:34:52 bernie
18 *#* Remove spurious EXTERN_C.
20 *#* Revision 1.2 2006/01/16 03:30:21 bernie
21 *#* Make header C++ friendly.
23 *#* Revision 1.1 2005/11/27 03:58:18 bernie
24 *#* Add POSIX timer emulator.
26 *#* Revision 1.1 2005/11/27 03:06:36 bernie
27 *#* Qt timer emulation.
31 #include <cfg/compiler.h> // hptime.t
32 #include <os/hptime.h>
34 #include <signal.h> // sigaction()
35 #include <sys/time.h> // setitimer()
36 #include <string.h> // memset()
39 // Forward declaration for the user interrupt server routine.
42 /// HW dependent timer initialization.
43 static void timer_hw_init(void)
46 memset(&sa, 0, sizeof(sa));
48 // Setup interrupt callback
49 sa.sa_handler = timer_isr;
50 sigemptyset(&sa.sa_mask);
51 sigaddset(&sa.sa_mask, SIGALRM);
52 sa.sa_flags = SA_RESTART;
53 sigaction(SIGALRM, &sa, NULL);
55 // Setup POSIX realtime timer to interrupt every 10ms.
56 static struct itimerval itv =
58 { 0, 1000 }, /* it_interval */
59 { 0, 1000 } /* it_value */
61 setitimer(ITIMER_REAL, &itv, NULL);
64 INLINE hptime_t timer_hw_hpread(void)