Pitx-sp software guide – Kontron pITX-SP User Manual
Page 32
KTD-S0003-C
Page 28
CPLD Interface
p
ITX-SP Software Guide
int flag = 0, reg_val;
void interrupt (*oldISR)(__CPPARGS);
void interrupt gpioISR(__CPPARGS)
{
outp (CPLD_BASE_ADDR, GPIO_OUTPUT);
reg_val |= (IRQ_BIT5 + IRQ_BIT6);
outp (CPLD_BASE_ADDR+1, reg_val);
flag++;
outp (CTRL_8259, EOI);
}
void main (void)
{
int i, count5 = 0, count6 = 0, old_mask, ctrl_val;
clrscr
();
_disable
();
oldISR = _dos_getvect (VECTOR_IRQ7);
_dos_setvect (VECTOR_IRQ7, gpioISR );
old_mask = inp (IMR_8259);
outp (IMR_8259, (old_mask & ~IRQ_MASK));
_enable
();
outp (CPLD_BASE_ADDR, GPIO_IRQ_POLARITY);
outp (CPLD_BASE_ADDR+1, IRQ_FALLING_EDGE);
outp (CPLD_BASE_ADDR, GPIO_OUTPUT);
reg_val = inp (CPLD_BASE_ADDR+1);
reg_val |= (IRQ_BIT5 + IRQ_BIT6);
outp (CPLD_BASE_ADDR+1, reg_val);
outp (CPLD_BASE_ADDR, GPIO_CONTROL);
ctrl_val = inp (CPLD_BASE_ADDR+1);
ctrl_val |= IRQ_ENABLE;
outp (CPLD_BASE_ADDR+1, ctrl_val);
while (! kbhit ())
{
flag = 0;
outp (CPLD_BASE_ADDR, GPIO_OUTPUT);
reg_val &= ~IRQ_BIT5;
outp (CPLD_BASE_ADDR+1, reg_val);
for (i = 0; i < IRQ_TIMEOUT; i++)
if (flag) break;
if (i != IRQ_TIMEOUT)
{
gotoxy (1, 2);
printf ("Interrupt Count GPIO 5 = %d", ++count5);
}
delay
(500);