lpt_irq.c
来自「fsmlabs的real time linux的内核」· C语言 代码 · 共 39 行
C
39 行
/* * Written by Der Herr Hofrat, der.herr@hofr.at * (C) 2002 FSMLabs * License: GPL Version 2 */#include <stdio.h>#include <unistd.h>#include <stdlib.h> /* exit */#include <sys/io.h>#define LPT 0x378int main(void){ int in; if (ioperm(LPT, 3 , 1) < 0) { fprintf(stderr,"ioperm: error accessing to IO-ports. Root Privileges required"); exit(-1); } /* wait for ACK to go low (logic 1) on the paralellport * and then produce a HI/LOW on D0-D8 to trigger an * interrupt as response , see PLIP.txt for pin-out */ while(1) { in=inb(LPT+1); in = in >> 3; in = in & 0x0f; if(in==0){ printf("got interrupt on LPT\n"); outb(0xff,LPT); /* logic 0 on LPT*/ usleep(100); outb(0x0,LPT); /* logic 1 on LPT*/ } } exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?