From 07e75e81aa605500c3be848277d397718f14b868 Mon Sep 17 00:00:00 2001 From: dopefishh Date: Mon, 28 Sep 2015 12:57:06 +0200 Subject: [PATCH] Added ex09b --- natanael/ex09/ex09a1.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/natanael/ex09/ex09a1.c b/natanael/ex09/ex09a1.c index cb7257d..86c80e6 100644 --- a/natanael/ex09/ex09a1.c +++ b/natanael/ex09/ex09a1.c @@ -8,7 +8,9 @@ RT_INTR keypress; RT_TASK key_isr; -#define KEYBOARD_IRQ 1 +#define PARPORT_IRQ 7 + +unsigned char byte; void key_handler(void *arg) { @@ -26,10 +28,12 @@ void key_handler(void *arg) //startup code void startup() { - rt_intr_create(&keypress, NULL, KEYBOARD_IRQ, I_PROPAGATE); + 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() { @@ -40,6 +44,21 @@ 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" ); @@ -52,4 +71,6 @@ int main(int argc, char* argv[]) // wait for CTRL-c is typed to end the program pause(); -} \ No newline at end of file + + disable_interupt(); +} -- 2.20.1