timer_posix.c
Go to the documentation of this file.00001
00039 #include <cfg/compiler.h>
00040 #include <os/hptime.h>
00041
00042 #include <signal.h>
00043 #include <sys/time.h>
00044 #include <string.h>
00045
00046
00047
00048 void timer_isr(int);
00049
00051 static void timer_hw_init(void)
00052 {
00053 struct sigaction sa;
00054 memset(&sa, 0, sizeof(sa));
00055
00056
00057 sa.sa_handler = timer_isr;
00058 sigemptyset(&sa.sa_mask);
00059 sigaddset(&sa.sa_mask, SIGALRM);
00060 sa.sa_flags = SA_RESTART;
00061 sigaction(SIGALRM, &sa, NULL);
00062
00063
00064 static struct itimerval itv =
00065 {
00066 { 0, 1000000 / TIMER_TICKS_PER_SEC },
00067 { 0, 1000000 / TIMER_TICKS_PER_SEC }
00068 };
00069 setitimer(ITIMER_REAL, &itv, NULL);
00070 }
00071
00072 INLINE hptime_t timer_hw_hpread(void)
00073 {
00074 return hptime_get();
00075 }