// Enter Extended Function Mode
outp(0x002E, 0x87);
outp(0x002E, 0x87);
// Assign Pin121-128 to be GPIO port 1
outp(0x002E, 0x29);
outp(0x002F, inp(0x002F) | 0x01);
// Select Logic Device 7
outp(0x002E, 0x07);
outp(0x002F, 0x07);
// Active Logic Device 7
outp(0x002E, 0x30);
outp(0x002F, 0x01);
// Select Inversion Mode
outp(0x002E, 0xF2);
outp(0x002F, 0x83);
// Select I/O Mode
// Bit0~bit3 output and bit4~bit7 input
outp(0x002E, 0xF1);
outp(0x002F, 0x00);
// Access GPIO ports
outp(0x002E, 0xF0);
outp(0x002F, 0x7C);
// Exit Extended Function Mode
outp(0x002E, 0xAA);
Definitions of Variables:
Each bit in the lower nibble of each Register represents the setting of a GPIO port.
Bit0 vs. GPIO DIO-Out 0
Bit1 vs. GPIO DIO-Out 1
Bit7 vs. GPIO DIO-Out 3
Bit4 vs. GPIO DIO-In 0
Bit3 vs. GPIO DIO-In 3