//=========================================================================== // Rev Date Name Description //=========================================================================== // 1.1 06/30/10 Willy GPIO10~GPIO17 Test utility for W83627HF. //=========================================================================== //=========================================================================== // Turbo C++ Version 3.0 Copyright(c) 1990, 1992 by Borland International,Inc. //=========================================================================== //=========================================================================== // Language include files //=========================================================================== #include #include #include //=========================================================================== // Normal procedure //=========================================================================== void Show_Help(); void Show_Fail(); void Show_Pass(); //=========================================================================== // Main procedure //=========================================================================== int main(int argc) { char *Model_Name="FleetPC-6"; char *Version="v1.0"; unsigned char IO_PORT_BASE=0x2E; // DATA_PORT = IO_PORT_BASE + 1; unsigned char data; int result=0; if ( argc > 1 ) { Show_Help(); return 1; } clrscr(); textcolor(WHITE); gotoxy(1, 1); cprintf("<>==========================================================================<>"); gotoxy(1, 2); cprintf("|| W83627DHG GPIO Test Utility %s CarTFT. ||",Version); gotoxy(1, 3); cprintf("<>==========================================================================<>"); gotoxy(1, 4); cprintf("<>==========================================================================<>"); gotoxy(1, 5); cprintf("|| Model Name : ||"); gotoxy(1, 6); cprintf("|| SIO IO Base : ||"); gotoxy(1, 7); cprintf("<>==========================================================================<>"); // Show Got Parameter Informat textcolor(LIGHTGRAY); gotoxy(18,5); cprintf("%s",Model_Name); gotoxy(18,6); cprintf("%X",IO_PORT_BASE); // Enter W83627HF Config outportb(IO_PORT_BASE,0x87); outportb(IO_PORT_BASE,0x87); // Set Multi-function Pins to GPIO outportb(IO_PORT_BASE,0x2C); outportb(IO_PORT_BASE+1,(inportb(IO_PORT_BASE+1) & 0x1F)); // Select GPIO Port device outportb(IO_PORT_BASE,0x07); outportb(IO_PORT_BASE+1,0x09); // Set GPIO Port Active GPIO3 outportb(IO_PORT_BASE,0x30); outportb(IO_PORT_BASE+1,0x02); // Set W83627HF GPIO30~33 to Output, GPIO34~GPIO37 to Input outportb(IO_PORT_BASE,0xF0); outportb(IO_PORT_BASE+1,0xF0); // inversion data to correct, because the protect circuit outportb(IO_PORT_BASE,0xF2); outportb(IO_PORT_BASE+1,0xF0); // Set W83627HF GPIO30~33 to 0x05 outportb(IO_PORT_BASE,0xF1); outportb(IO_PORT_BASE+1,0x05); // Read W83627HF GPIO34~37 Status, if not 0x50 error. delay(100); data=inportb(IO_PORT_BASE+1)&0xF0; if(data!=0x50) result=1; // Set W83627HF GPIO30~33 to 0x0A outportb(IO_PORT_BASE,0xF1); outportb(IO_PORT_BASE+1,0x0A); // Read W83627HF GPIO34~37 Status, if not 0xA0 error. delay(100); data=inportb(IO_PORT_BASE+1)&0xF0; if(data!=0xA0) result=1; // Exit W83627HF Config outportb(IO_PORT_BASE,0xAA); if(result) Show_Fail(); else Show_Pass(); return result; } //=========================================================================== // Function : Show_Help() // Input : - // Change : - // Return : - // Description : Show Title string. //=========================================================================== void Show_Help() { clrscr(); printf("GPIO Test utility for W83627DHG\n\n"); printf("GP30 1  ЭЭ  11 GP34\n"); printf("GP31 2  ЭЭ  12 GP35\n"); printf("GP32 3  ЭЭ  13 GP36\n"); printf("GP33 4  ЭЭ  14 GP37\n"); } //=========================================================================== // Function : Show_Fail() // Input : - // Change : - // Return : - // Description : Show Fail Message. //=========================================================================== void Show_Fail() { textcolor(LIGHTRED); gotoxy(20,10); cprintf(" лллллллл лллллл лллл лл "); gotoxy(20,11); cprintf(" лл лл лл лл лл "); gotoxy(20,12); cprintf(" лллллл лллллллл лл лл "); gotoxy(20,13); cprintf(" лл лл лл лл лл "); gotoxy(20,14); cprintf(" лл лл лл лллл лллллллл"); } //=========================================================================== // Function : Show_Pass() // Input : - // Change : - // Return : - // Description : Show Pass Message. //=========================================================================== void Show_Pass() { textcolor(LIGHTGREEN); gotoxy(20,10); cprintf(" лллллллл лллллл лллллллл лллллллл"); gotoxy(20,11); cprintf(" лл лл лл лл лл лл "); gotoxy(20,12); cprintf(" лллллллл лллллллл лллллллл лллллллл"); gotoxy(20,13); cprintf(" лл лл лл лл лл"); gotoxy(20,14); cprintf(" лл лл лл лллллллл лллллллл"); }