beautypg.com

Chapter 6 - gpio programming guide, Sample code – DFI CR960-HM76 User Manual

Page 71

background image

www.dfi .com

Chapter 6 GPIO Programming Guide

71

Chapter 6

Chapter 6 - GPIO Programming Guide

Function Description

Get_EC_Data (unsigned char ucData): Read a Byte data from EC.

Write_EC_Data (unsigned char ucData, unsigned char Data): Write a Byte data to EC.

Sample Code

GPIO Input Process

EC_DIO_Read_Input()

{

BYTE Data;

//Pin0-3 Input Mode

Data = Get_EC_Data(0xBA);

Data |= 0x80;

Write_EC_Data(0xBA, Data);

while(((Get_EC_Data(0xBA) >> 7)&0x01))

{

Data = Get_EC_Data(0xBA);

}

Return Data ;

}

GPIO Output Process

EC_DIO_Write_Output(unsigned char udata)

{

//Pin4-7 Output Mode

udata <<= 4;

udata |= 0x01;

Write_EC_Data(0xBB, udata);

return 0;

EC_DIO_Read_Output()

{

BYTE Data;

//Pin4-7 Output Mode

Write_EC_Data(0xBB, 0x02);

Delay;

Data = Get_EC_Data(0xBB);

Data >>= 4;

Return Data ;

}

This manual is related to the following products: