Appendix
46
EPE1814V2NAR
b. Input Programming
Functions Input: int pin – Value 1~4 are corresponding with the input pin 1~4
Functions Output: int lev_val – 1: input pin is active high; 0: input pin is active low
int In_Lev(int pin)
{
unsigned int reg_val ;
int lev_val ;
outportb(BAR,0xbf);
outportb(BAR+0x04,0x41);
outportb(BAR+0x03,0x00);
reg_val =(inportb(BAR+0x02)|0x08)&0xeb;
reg_val |= 0x40;
outportb(BAR+0x02, reg_val);
delay(30);
reg_val =inportb(BAR);
while((reg_val &0x02)!=0x02)
{
reg_val =inportb(BAR);
if((reg_val &0x04)!=0)
{
printf("ERROR\n");
return 0;
}
}
lev_val = inportb(BAR+0x05)&( 0x01<<pin1);
lev_val = lev_val ? 1:0; /*Get the variable lev_val, 1 represents
that the input pin is active high, while 0 represents the input pin is
active low*/
return lev_val ;
}