NO:
W90P710 Programming Guide
VERSION:
2.0
PAGE:
179
The above information is the exclusive intellectual property of Winbond Electronics and shall not be disclosed, distributed or reproduced without permission
from Winbond.
Table No.: 2005-W90P710-11-A
14.3.3 GPIO
Input
Mode
Before the system use the GPIO pin as input pin, program need to configure the GPIO direction
register(GPIO_DIRn). The configuration sequence is described as follows.
1. Set
GPIO_CFGn
PTxCFGy
as GPIO purpose according to the adove method of Multiple
function setting
2. Set
the
GPIO_DIRn
OMDENx[y]
value as 0 (input mode).
After the above steps, user can get the GPIO pin input value(high or low) by read the GPIO data
input register(GPIO_DATAINn).
A sample code set GPIO PORT0 pin1 as GPIO input, then get the input value is given below:
int GPIO_CFG=0;
int value=0;
// Set GPIO1 as I/O pin
GPIO_CFG=inpw(0xFFF83000);// Get GPIO_CFG0 value
GPIO_CFG=GPIO_CFG&0xFF3; // Set PT0CFG1, GPIO1 as I/O pin
outpw(xFFF83000,GPIO_CFG);// Write value to GPIO_CFG0
// Set GPIO1 as input mode
GPIO_CFG=inpw(0xFFF83004);// Get GPIO_DIR0 value
GPIO_CFG=GPIO_CFG&(0<<17);// GPIO1 input mode
outpw(xFFF83004,GPIO_CFG);// Write value to GPIO_DIR0
// get GPIO1 input value
value =inpw(0xFFF8300C)&0x02;
if(value)
printf(“GPIO pin1 input value is 1.”);
else
printf(“GPIO pin1 input value is 0.”);