
附录
104-1816CL2NA
- 37 -
5.附录
5.1 数字I/O编程指引
本主板提供8路可编程数字I/O引脚,其中4路为输入,4路为输出。
以下用C语言形式提供了数字I/0的编程范例,对数字I/O的编程需遵循以下
步骤:
(说明书中的GPIO1~8分别对应Super IO的GPIO32,23,33,31,36,35,
34,40;现以GPIO1,2,3,4配置成输入<输入为只读的>,GPIO5,6,7,8配置
成输出<输出为可读可写的>为例)
初始化数字I/O
输入输出编程
1.
初始化数字I/O
#define INDEX_PORT
0x2E
#define DATA_PORT
0x2F
#define bit0
0x01
#define bit1
0x02
#define bit2
0x04
#define bit3
0x08
#define bit4
0x010
#define bit5
0x020
#define bit6
0x040
#define bit7
0x080
//启用GPIO
Int temp;
outportb(INDEX_PORT,0x87);
outportb(INDEX_PORT,0x87);
outportb(INDEX_PORT,0x07);
outportb(DATA_PORT,0x07);