Created
February 10, 2012 12:12
-
-
Save c2h2/1789181 to your computer and use it in GitHub Desktop.
gpio windows demo file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* W83627UHG GPIO DEMO PROGRAM File Name : 2780GPIO.C | |
*/ | |
#include <stdio.h> | |
#include <conio.h> | |
#include <dos.h> | |
#define Superio2_Addr 0x2E | |
/* #define DEBUG 1 */ | |
void enter_Superio2_CFG(void) { | |
outportb(Superio2_Addr, 0x87); | |
outportb(Superio2_Addr, 0x87); | |
} | |
void exit_Superio2_CFG(void) { | |
outportb(Superio2_Addr, 0xAA); | |
} | |
void Set_CFG2(unsigned char Addr2,unsigned char Value2) { | |
unsigned char d2; | |
outportb(Superio2_Addr, Addr2); | |
delay(2); | |
outportb(Superio2_Addr +1, Value2); | |
#ifdef DEBUG | |
d2 = inportb(Superio2_Addr+1); | |
printf("\nWrite %x to CR%x, read back is:%x",Value2,Addr2,d2); | |
#endif /*DEBUG*/ | |
delay(2); | |
} | |
unsigned char Get_CFG2(unsigned char Addr2) { | |
unsigned char d2; outportb(Superio2_Addr, Addr2); | |
delay(2); | |
d2 = inportb(Superio2_Addr+1); | |
#ifdef DEBUG | |
printf("\nGet data %x from CR%x",d2,Addr2); | |
#endif /*DEBUG*/ delay(2); | |
return(d2); | |
} | |
int main(void) { | |
unsigned char d2; printf("\n------------------------------------------------------------------------"); | |
printf("\n- PEB-2771/2781 GPIO TEST Program R1.0 -"); printf("\n------------------------------------------------------------------------"); | |
printf("\n Please short the following pins with 2.00mm-pitched jumper on J13"); printf("\n P.S: SIO: W83627UHG, Winbond"); | |
printf("\n GP50(J13 PIN 1)----GP57(J13 PIN 2)"); | |
printf("\n GP51(J13 PIN 3)----GP56(J13 PIN 4)"); | |
printf("\n GP52(J13 PIN 5)----GP55(J13 PIN 6)"); | |
printf("\n GP53(J13 PIN 7)----GP54(J13 PIN 8)"); | |
printf("\n GND (J13 PIN10)****VCC (J13 PIN 9)"); | |
printf("\n\n Starting..."); | |
enter_Superio2_CFG(); | |
/* CR2A B7 = 1 selet GPIO Port 1*/ | |
d2 = Get_CFG2(0x2A); | |
d2 = (d2 & 0x7F) | 0x80; | |
Set_CFG2(0x2A, d2); | |
/* IO test loop 1 */ | |
/* Set GPIO Port 5 Enable */ | |
Set_CFG2(0x07, 0x08); /* Select logic device 08*/ Set_CFG2(0x30, 0x02); /* Enable GPIO Port 5 */ | |
// 87 87 | |
//-------------------------------------------------------------------------------------------------------- // GPIO50->57 | |
// GPIO51->56 | |
// GPIO52->55 | |
// GPIO53->54 //-------------------------------------------------------------------------------------------------------- | |
/* Set GPIO Port 5 of Superio2 Enable */ | |
Set_CFG2(0x07, 0x08); | |
Set_CFG2(0xE0, 0xF0); | |
Set_CFG2(0xE2, 0x00); | |
delay(2); | |
Set_CFG2(0x07, 0x08); | |
Set_CFG2(0xE1, 0x0F); | |
delay(100); | |
Set_CFG2(0x07, 0x08); | |
d2 = Get_CFG2(0xE1); | |
//printf("\n%x",d2); | |
if ((d2&0xFF) == 0x0F ){ | |
/* Select logic device 08*/ | |
/* GPIO Port 5 is [11110000], 0: output, 1:input */ /* GPIO Port 5 is non-inversed*/ | |
/* Select logic device 08*/ | |
/* GP50~53 of Superio2 -> GP57~54 of Superio2 */ | |
/* Select logic device 08*/ /* get GPIO Port 6 data */ | |
printf("\n GPIO[50,51,52,53]->[57,56,55,54] test ok!"); | |
}else{ | |
printf("\n GPIO[50,51,52,53]->[57,56,55,54] test fail!"); | |
} | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment