5 #include <native/intr.h>
7 #include <native/task.h>
11 #define KEYBOARD_IRQ 1
13 void key_handler(void *arg
)
16 int nr_interrupts_waiting
;
18 rt_printf("%d\n",count
++);
19 nr_interrupts_waiting
= rt_intr_wait(&keypress
,TM_INFINITE
);
20 if (nr_interrupts_waiting
>0)
29 rt_intr_create(&keypress
, NULL
, KEYBOARD_IRQ
, I_PROPAGATE
);
31 rt_task_create(&key_isr
, NULL
,0,50,0);
32 rt_task_start(&key_isr
, &key_handler
, NULL
);
36 /* Avoids memory swapping for this program */
37 mlockall(MCL_CURRENT
|MCL_FUTURE
);
39 /* Perform auto-init of rt_print buffers if the task doesn't do so */
40 rt_print_auto_init(1);
43 int main(int argc
, char* argv
[])
45 printf("\nType CTRL-C to end this program\n\n" );
47 // code to set things to run xenomai
53 // wait for CTRL-c is typed to end the program