设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
注册
快捷导航
平台
Portal
论坛
BBS
文库
项目
群组
Group
我的博客
Space
搜索
搜索
热搜:
shell
linux
mysql
本版
用户
LinuxSir.cn,穿越时空的Linuxsir!
»
论坛
›
编程开发讨论区 —— LinuxSir.cn
›
Linux 程序设计专题讨论
›
对并口的理解,即(调试并口程序)
返回列表
查看:
861
|
回复:
3
对并口的理解,即(调试并口程序)
[复制链接]
wide288
wide288
当前离线
积分
2736
IP卡
狗仔卡
发表于 2003-10-25 18:35:03
|
显示全部楼层
|
阅读模式
好像明白了些什么,如果你不会写正确的软件,那怎样才能弄好并口呢。所以想到要可以自由改变所有的状态位,数据位,控制位,就行了。
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
显身卡
无双
无双
当前离线
积分
1799
IP卡
狗仔卡
发表于 2003-10-25 22:06:52
|
显示全部楼层
再放上一些源码就更好了
回复
支持
反对
使用道具
举报
显身卡
wide288
wide288
当前离线
积分
2736
IP卡
狗仔卡
楼主
|
发表于 2003-10-26 20:56:15
|
显示全部楼层
我也想,努力看书中
正在想在用户空间能不能实现中断功能。
回复
支持
反对
使用道具
举报
显身卡
wide288
wide288
当前离线
积分
2736
IP卡
狗仔卡
楼主
|
发表于 2003-10-26 21:46:22
|
显示全部楼层
端口介绍:
http://www.doc.ic.ac.uk/~ih/doc/par/
Input from digital joystick to PC parallel port
Borland C/C++ version
/* program readjs - input from digital joystick to PC parallel port
*
* compiled with Borland C++ version 3.1 under MS-DOS 6.22
*
* Copyright (c) 1997, Ian Harries and Imperial College, London, UK
*
* IBM-PC Parallel Printer Port Data & Status Registers
* ====================================================
* 7 6 5 4 3 2 1 0 I/O Port
* +---+---+---+---+---+---+---+---+
* Data | W | E | S | N | B | x | x | x | Base = 278/378/3BC Hex
* +---+---+---+---+---+---+---+---+
* Status |~W | E | S | N | B | - | - | - | Base + 1
* +---+---+---+---+---+---+---+---+
*/
#include <stdio.h>
#include <conio.h> /* required only for function declarations */
#define Data 0x378
#define Status Data + 1
#define BS 8 /* ASCII BackSpace */
void main() {
int JShigh, JSlow, i, oldbyte, newbyte;
char backspace = BS;
printf("\n");
printf("Ian's Parallel Port JoyStick Reader\n");
printf("===================================\n");
printf("\n");
printf("<Centre + Button> to Quit\n");
printf("\n");
oldbyte = 0xff; /* different from newbyte */
outportb(Data,0xf8); /* output TTL High on enable lines */
do {
newbyte = inportb(Status);
if (newbyte != oldbyte) { /* new joystick status */
oldbyte = newbyte;
for (i = 1; i <= 20; i++) { /* clear the previous status report */
printf("%c",backspace); printf(" "); printf("%c",backspace);
}
JSlow = (newbyte & 0x0f) >> 3; /* Button Signal */
JShigh = (newbyte ^ 0x80) >> 4; /* Direction Signal */
switch (JShigh) {
case 0: printf("Centre");
break;
case 1: printf("North");
break;
case 2: printf("South");
break;
case 4: printf("East");
break;
case 5: printf("NorthEast");
break;
case 6: printf("SouthEast");
break;
case 8: printf("West");
break;
case 9: printf("NorthWest");
break;
case 10: printf("SouthWest");
}
if (JSlow == 1)
printf(" + Button");
}
}
while ((JSlow != 1) || (JShigh != 0));
printf("\n");
}
复制代码
回复
支持
反对
使用道具
举报
显身卡
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
注册
本版积分规则
发表回复
回帖后跳转到最后一页
浏览过的版块
Debian Linux
Gentoo Linux
Redhat/Fedora/CentOS Linux
开源软件专题讨论
Mandriva Linux
Copyright © 2002-2023
LinuxSir.cn
(http://www.linuxsir.cn/) 版权所有 All Rights Reserved.
Powered by
RedflagLinux!
技术支持:
中科红旗
|
京ICP备19024520号
快速回复
返回顶部
返回列表