0b699ba951a93118879142b4fa474f88347c4fe9
5 #include <native/intr.h>
7 #include <native/task.h>
9 const RTIME period
= 100000;
10 const int nsamples
= 10000;
14 RTIME time_diff
[10000];
20 void enable_interupt()
24 byte
= byte
| 0x10; /* hex 10 = 00010000 */
30 byte
= byte
| 0x10; /* hex 10 = 00010000 */
34 void disable_interupt()
37 byte
= byte
& 0xEF; /* hex EF = binary 11101111 */
41 void write_RTIMES(char * filename
, unsigned int number_of_values
,
45 file
= fopen(filename
,"w");
46 while (n
<number_of_values
) {
47 fprintf(file
,"%u,%llu\n",n
,time_values
[n
]);
51 rt_printf("File saved\n");
54 void send_parallel_port_intrp()
56 outb(inb(0x378) & 0xEF, 0x378);
57 outb(inb(0x378) | 0x10, 0x378); /* enable interrupt */
60 void do_task(void *arg
)
64 rt_task_set_periodic(NULL
, TM_NOW
, period
);
66 for(i
=0; i
<nsamples
; i
++)
68 write_time
= rt_timer_read();
70 send_parallel_port_intrp();
72 rt_intr_wait(&intr
,TM_INFINITE
);
74 time_diff
[i
] = rt_timer_read() - write_time
;
76 rt_task_wait_period(NULL
);
78 write_RTIMES("time_diff_d.csv",nsamples
,time_diff
);
84 rt_intr_create(&intr
, NULL
, PARPORT_IRQ
, I_PROPAGATE
);
87 rt_task_create(&task
, NULL
,0,50,0);
88 rt_task_start(&task
, &do_task
, NULL
);
92 /* Avoids memory swapping for this program */
93 mlockall(MCL_CURRENT
|MCL_FUTURE
);
95 /* Perform auto-init of rt_print buffers if the task doesn't do so */
96 rt_print_auto_init(1);
98 int main(int argc
, char* argv
[])
100 printf("\nType CTRL-C to end this program\n\n" );
102 // code to set things to run xenomai
108 // wait for CTRL-c is typed to end the program