/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Copyright (c) 1995-1999, ADLink Technology Inc.  All rights reserved.  ;;
;;                                                                         ;;
;;      File Name : 7233dbint.c                                            ;;
;;      Purpose   : This sample program demonstrates how handle interrupt  ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
#include <stdio.h>
#include <unistd.h>
#include "dask.h"
#include "conio.h"

int int_count=0, int2_count=0;
I16 card=-1, card_number = 0;

void sig1_handler( int signo )
{ 
  switch( signo ){
    case SIGEVENT1:
      int_count ++;
      break;
  }
  printf("INT1 count = %d    INT2 count = %d\n", int_count, int2_count);
  printf("press ENTER for exit\n" );

  return;
}

void sig2_handler( int signo )
{
  switch( signo ){
    case SIGEVENT2:
      int2_count ++;
      break;
  }
  printf("INT1 count = %d    INT2 count = %d\n", int_count, int2_count);
  printf("press ENTER for exit\n" );

  return;
}

int main(void)
{
    int  err;

    setbuf( stdout, NULL );
    printf("PCI-7233 Double Interrupt Sample \n\n");

    printf("This program shows the number of occurrence of interrupt for Dual interrupt lines.\n");
    printf("INT1 interrupt is generated by change of state of DI bit 0-15.\n");
    printf("INT2 interrupt is generated by change of state of DI bit 16-31.\n");

    printf("Press ENTER for exit\n\n" );

    if ( (card=Register_Card(PCI_7233, card_number)) < 0) {
      printf ("Can't open device file: PCI7233\n");
      exit(-1);
    }

    err = DIO_SetDualInterrupt(card, INT1_EXT_SIGNAL, INT2_EXT_SIGNAL, sig1_handler, sig2_handler);
    if( err != NoError ){
       printf(" error from DIO_SetDualInterrupt : %d \n" , err );
       goto exit_after_error;
    }

    getchar();

    DIO_SetDualInterrupt(card, INT1_DISABLE, INT2_DISABLE, NULL, NULL);
exit_after_error:
    if (card >= 0) Release_Card(card);
    exit(0);
}


















