#include<stdio.h>
#include<conio.h>
#include"a826.h"

int Base=0x220;
int Irq=15;
int Buf[1000];

void main(void)
{ int err;
  int quit=0;
  int i;
  float rate=10.0/32768.0;
  unsigned long ping;
  int c1,c2;
  int NowCount;

  err=A826_Initialize(0,Base,-1,Irq);
  if(err){
     if(err==CheckBoardError){
        printf("Address 0 Error!\n");
     }
     else if(err==CardNumError){
        printf("Card Number Error!(range:0-7)\n");
     }
     return;
  }
  printf("\nCard 0 [interrupt test]\n");
  A826_AD_SetChGainMode(0,A826_BI_1,INTERRUPT_MODE);
  c1=10;
  c2=10;
  ping=0;
  while(!quit){
  printf("\nCard 0 [interrupt test]_%lu\n",ping);
        A826_AD_INT_Start(Buf,1000,c1,c2);
        ping++;
        do {
           NowCount=A826_AD_INT_Count();
           printf("[%d] ",NowCount);
           if(kbhit() && getch()==27) {
              quit=1;
              break;
           }
        } while( NowCount<1000 );
        A826_AD_INT_Stop( );
        if(kbhit() && getch()==27) break;
        printf("\n");
        for(i=0;i<1000;i+=100){
            printf("[%3d]%6.4f\n",i,rate*Buf[i]);
        }
  }
}
