Appendix e – DFI CD952 series User Manual

Page 64

Advertising
background image

www.dfi .com

64

Appendix E Digital I/O User Guide

Appendix E

4.2 Control of GP80 to GP87

#define AddrPort 0x2E
#define DataPort 0x2F

<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

<Output/Input Mode Selection>//SetGP80 to GP87 I/O Mode
WriteByte(AddrPort, 0x88)// Select configuration register 88h
WriteByte(DataPort, (ReadByte(DataPort) & 0xXX))
//Set (bit n) = (1/0) to select GP 8n as Output/Input mode.
<Get Input Value>
WriteByte(AddrPort, 0x8A)// Select configuration register 8Ah
Data = ReadByte(DataPort)// The “Data” represent the input value of GP80~87

<Output Value>
WriteByte(AddrPort, 0x89)// Select configuration register 89h
WriteByte(DataPort, Value)// Set bit n=(0/1) to output GP 8n
as Low or High

<Leave the Extended Function Mode>
WriteByte(AddrPort, 0xAA)

4. Sample Code in C Language

4.1 Control of GP03, GP02 and GP07

#define AddrPort 0x2E
#define DataPort 0x2F

<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(AddrPort, 0x06)
//Select logic device 06h

<Output Mode Selection>//SetGPIO71/72 to output Mode
WriteByte(AddrPort, 0x80)// Select configuration register 80h
WriteByte(DataPort, (ReadByte(DataPort)

ǀ 0x06))

//Set (bit 0/1) = (1) to select GPIO 71/72 as Output mode.

<Output Value>
WriteByte(AddrPort, 0x81)// Select configuration register 81h
WriteByte(DataPort, Value)// Set bit n=(1/2) to output GPI07n
as Low or High

<Leave the Extended Function Mode>
WriteByte(AddrPort, 0xAA)

Advertising