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

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

void main(void)
{ int err;
  int i;
  float rate=5.0/2048.0;

  err=A812_Initialize(0,Base,-1,-1);
  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 [polling test]\n");
  printf("Using [A812_AD_PollingArray]\n");
  A812_AD_SetChGainMode(0,A812_BI_1,POLLING_MODE);
  A812_Delay(4*2);     /* delay the 4 uS settling time */
  A812_AD_PollingArray(Buf,1000);
  for(i=0;i<1000;i+=100){
	 printf("[%3d]:[%x]=%6.3f\n",i,Buf[i],rate*(Buf[i]-2048));
  }
  printf("Using [A812_AD_PollingVar]\n");
  Buf[0]=A812_AD_PollingVar();
  printf("PollingVar=[%x]=%6.3f\n",Buf[0],rate*(Buf[0]-2048));
  Buf[0]=A812_AD_PollingVar();
  printf("PollingVar=[%x]=%6.3f\n",Buf[0],rate*(Buf[0]-2048));
  Buf[0]=A812_AD_PollingVar();
  printf("PollingVar=[%x]=%6.3f\n",Buf[0],rate*(Buf[0]-2048));
}
