Appendix
EPE1814V2NAR
45
(2)
I/O Programming
a. Output Programming
Functions input: int pin – Value 1~4 are corresponding with output pin 1~4
int lev_val – 1: output pin is active high; 0: output pin is active low
Functions Output: None
void Out_Lev(int pin ,int lev_val)
{
unsigned int reg_val ;
outportb(BAR,0xbf);
outportb(BAR+0x04,0x40);
outportb(BAR+0x03,0x01);
reg_val = inportb(BAR+0x05);
reg_val = lev_val ?
reg_val|(0x01<<pin+3) :reg_val&(~(0x01<<pin+3)) ;
outportb(BAR+0x05, reg_val);
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;
}
}
}