Appendix
- 46 -
EC0-1814(B)
#define DATA_PORT 0x2F
VOID PreInitGPIO()
{
outportb(INDEX_PORT,0x87);
outportb(INDEX_PORT,0x87);
outportb(INDEX_PORT,0x07);
outportb(DATA_PORT,0x09);
outportb(INDEX_PORT,0x30);
outportb(DATA_PORT,0x03); //Enable GPIO2 and GPIO3 series.
}
outportb(INDEX_PORT,0xF8);
outportb(DATA_PORT,0x0);
outportb(INDEX_PORT,0x29);
Temp_val=(inportb(DATA_PORT)|0x02)&0xfb;
outportb(DATA_PORT, Temp_val);
//GP21,GP20 select as gpio
Note: the multifunctional GPIO shall be initialized to GPIO function.
(2)
Input/output program:
outportb
(
INDEX_PORT, 0xE3
)
;
Temp_val=(inportb(DATA_PORT))&0xfc;
outportb (DATA_PORT, Temp_val)
;
// GPIO20 and 21, i.e. GPIO7 and 8,
are set to output.
outportb
(
INDEX_PORT, 0xE4
)
;
Temp_val=(inportb(DATA_PORT))&0xfc;
outportb (DATA_PORT, Temp_val)
;
// GPIO7 and 8 are set to low level.
outportb
(
INDEX_PORT, 0xF0
)
;
Temp_val=(inportb(DATA_PORT)|0x33)&0x3f;
outportb (DATA_PORT, 0x3F)
;
// GPIO30, 31, 34 and 35, i.e. GPIO1, 2,
3 and 4, are set to input; //GPIO36 and 37, i.e. GPIO5 and 6 are set to output.
outportb
(
INDEX_PORT, 0xF1
)
;
Temp_val=(inportb(DATA_PORT))&0x3f;
outportb (DATA_PORT, Temp_val)
;
// GPIO5 and 6 are set to low level.
(3)
Disable Programming
outportb(0x2e,0xaa);