【发布时间】:2019-03-11 06:01:05
【问题描述】:
我有一台Cincoze DE-1000 工业PC,它配备Fintek F81866A 芯片组。我必须管理 DIO 引脚以读取物理按钮的输入并设置开/关 LED。我有 C++ 编程经验,但不是低/硬件级别的。
在PC随附的文档中,有如下C代码:
#define AddrPort 0x4E
#define DataPort 0x4F
//<Enter the Extended Function Mode>
WriteByte(AddrPort, 0x87)
WriteByte(AddrPort, 0x87) //Must write twice to entering Extended mode
//<Select Logic Device>
WriteByte(AddrPort, 0x07)
WriteByte(DataPort, 0x06)
//Select logic device 06h
//<Input Mode Selection> //Set GP74 to GP77 input mode
WriteByte(AddrPort, 0x80) //Select configuration register 80h
WriteByte(DataPort, 0x0X)
//Set (bit 4~7) = 0 to select GP 74~77 as Input mode.
//<input Value>
WriteByte(AddrPort, 0x82) // Select configuration register 82h
ReadByte(DataPort, Value) // Read bit 4~7(0xFx)= GP74 ~77 as High.
//<Leave the Extended Function Mode>
WriteByte(AddrPort, 0xAA)
据我了解,上面的代码应该读取四个输入 PIN 的值(因此每个 PIN 应该读取 1),但我真的很难理解它的实际工作原理。我已经理解逻辑(选择地址并读取/写入十六进制值),但我无法弄清楚WriteByte() 和ReadByte() 是哪种C 指令。另外,我不明白ReadByte(DataPort, Value) 行中的Value 来自哪里。它应该一起读取 4 个 PIN,所以它应该是某种“字节”类型,并且应该在其 4-7 位中包含 1,但我还是无法真正理解该行的含义。
我找到了answer for a similar chip,但对我的理解没有帮助。
请给我建议或指出一些相关文档。
【问题讨论】: