System Installation
PEB-2772AVGATM User’s Manual
3-7
3.6
GPIO
#define EFER 0x2e
//Address for Extended Function Enable Register
#define DEVICE_NUM_REG
0x07
//Address for Logic Device Number Register
#define GPIO_LOGIC_NUM
0x08
//Logic device number for GPIO
#define GPIO_BASE_REG
0x30
//Set GPIO
#define GPIO_IO_REG
0xe0
//Address for GPIO I/O Register
#define GPIO_MODE_OUT
0
#define GPIO_DATA_REG
0xe1
//Address for GPIO Data Register
int GPIO_Pin_Set(int pin_num, int mode, int value){
int tmp = 1 << pin_num;
if(pin_num < 0 || pin_num > MAX_GPIO_NUM || mode < 0 || mode > 1 || value
< 0 || value > 1){
printf("GPIO_Pin_Set:Invalid
parameter\n");
return
-1;
}
//Enter the Extended Function Mode
outp(EFER,
0x87);
outp(EFER,
0x87);
//Now set the configuration register
outp(EFER, DEVICE_NUM_REG); //Select Logic Device Number Register
outp(EFER + 1, GPIO_LOGIC_NUM); //device number for GPIO2,3,4,5 is 9
outp(EFER,
GPIO_BASE_REG);
outp(EFER + 1, 0x07);
outp(EFER, GPIO_IO_REG); //Select GPIO3 I/O Register
outp(EFER + 1,(inp(EFER + 1) & ~tmp) | (tmp * mode));//Set I/O mode, 0:output
1:input
//If mode is GPO, set value
if(mode == GPIO_MODE_OUT){
outp(EFER, GPIO_DATA_REG); //Select GPIO3 Data Register
outp(EFER + 1,(inp(EFER + 1) & ~tmp) | (tmp * value));//Set GPO value, 0:low
1:high
printf("GPIO_Pin_Set: Set GPIO(%d) to GPO, Value = %d\n", pin_num, value);
}
else{
printf("GPIO_Pin_Set: Set GPIO(%d) to GPI\n", pin_num);
}
//Exit the Extended Function Mode
Содержание PEB-2772VGATM
Страница 7: ...System Overview PEB 2772AVGATM User s Manual 1 4 Mechanical Drawing ...
Страница 10: ...System Installation PEB 2772AVGATM User s Manual 2 2 Solder side ...
Страница 19: ...System Installation PEB 2772AVGATM User s Manual 2 11 ...
Страница 27: ...System Installation PEB 2772AVGATM User s Manual 3 8 o4utp EFER 0xAA return 0 ...
Страница 37: ...BIOS Setup Information PEB 2772AVGATM User s Manual 4 10 Chipset Configuration Memory Configuration ...
Страница 42: ...BIOS Setup Information PEB 2772AVGATM User s Manual 4 15 SIO Configuration ...
Страница 44: ...BIOS Setup Information PEB 2772AVGATM User s Manual 4 17 Hardware Monitor Smart Fan Control ...