RT_INTR keypress;
RT_TASK key_isr;
-#define PARPORT_IRQ 7
-
-unsigned char byte;
+#define KEYBOARD_IRQ 1
void key_handler(void *arg)
{
//startup code
void startup()
{
- rt_intr_create(&keypress, NULL, PARPORT_IRQ, I_PROPAGATE);
- enable_interupt();
+ rt_intr_create(&keypress, NULL, KEYBOARD_IRQ, I_PROPAGATE);
rt_task_create(&key_isr, NULL,0,50,0);
rt_task_start(&key_isr, &key_handler, NULL);
-
}
void init_xenomai() {
rt_print_auto_init(1);
}
-void enable_interupt()
-{
- ioperm(0x37A, 1, 1);
- byte = inb(0x37A);
- byte = byte | 0x10; /* hex 10 = 00010000 */
- outb(byte, 0x37A);
-}
-
-void disable_interupt()
-{
- byte = inb(0x37A);
- byte = byte & 0xEF; /* hex EF = binary 11101111 */
- outb(byte, 0x37A);
-}
-
int main(int argc, char* argv[])
{
printf("\nType CTRL-C to end this program\n\n" );
// wait for CTRL-c is typed to end the program
pause();
-
- disable_interupt();
-}
+}
\ No newline at end of file
--- /dev/null
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <native/intr.h>
+#include <sys/io.h>
+#include <native/task.h>
+
+RT_INTR keypress;
+RT_TASK key_isr;
+#define PARPORT_IRQ 7
+
+unsigned char byte;
+
+void key_handler(void *arg)
+{
+ int count = 0;
+ int nr_interrupts_waiting;
+ while(1) {
+ rt_printf("%d\n",count++);
+ nr_interrupts_waiting = rt_intr_wait(&keypress,TM_INFINITE);
+ if (nr_interrupts_waiting>0)
+ {
+ }
+ }
+}
+
+//startup code
+void startup()
+{
+ rt_intr_create(&keypress, NULL, PARPORT_IRQ, I_PROPAGATE);
+ enable_interupt();
+
+ rt_task_create(&key_isr, NULL,0,50,0);
+ rt_task_start(&key_isr, &key_handler, NULL);
+
+}
+
+void init_xenomai() {
+ /* Avoids memory swapping for this program */
+ mlockall(MCL_CURRENT|MCL_FUTURE);
+
+ /* Perform auto-init of rt_print buffers if the task doesn't do so */
+ rt_print_auto_init(1);
+}
+
+void enable_interupt()
+{
+ ioperm(0x37A, 1, 1);
+ byte = inb(0x37A);
+ byte = byte | 0x10; /* hex 10 = 00010000 */
+ outb(byte, 0x37A);
+}
+
+void disable_interupt()
+{
+ byte = inb(0x37A);
+ byte = byte & 0xEF; /* hex EF = binary 11101111 */
+ outb(byte, 0x37A);
+}
+
+int main(int argc, char* argv[])
+{
+ printf("\nType CTRL-C to end this program\n\n" );
+
+ // code to set things to run xenomai
+ init_xenomai();
+
+ //startup code
+ startup();
+
+ // wait for CTRL-c is typed to end the program
+ pause();
+
+ disable_interupt();
+}