/*  @(#) $Header: $
 *
 * Test Philosophy:
 *    Determine if we can reliably accumulate an 8 bit value from
 *    an Interrupt Service Routine into a long.
 * Author:
 *	Allen Brown  http://brown.armoredpenguin.com/~abrown/contact.html
 */

#include <stdio.h>
#include <math.h>
#define MAIN
#include "fastacc.h"

int main (void)
{
  int scanfreturn, lineno, returnval;
  char inpline[80];
  unsigned char charfromisr;
  long accumulator=0;
  signed char isrdiff;

  lineno = 0;
  while( NULL !=		// Check if this is the end of the file.
	 (fgets(inpline, sizeof(inpline), stdin))) // Read a line of text
  {
    lineno++;
    // Parse the input line.
    scanfreturn = sscanf(inpline, "%d", &charfromisr);
    if( scanfreturn != 1)
    { // Number of scanned vars must match what we expect.
      printf("fastacc_t: wrong # values line %d: '%s'\n", lineno, inpline);
    } else {
      isrdiff = fastacc( charfromisr, &accumulator );

      printf("line %3d: fastacc %d -> %d, %ld\n",
	     lineno, (unsigned int) charfromisr, (int) isrdiff, accumulator );
      fflush(stdout);
    } // else
  } // while

  return (0);
} // main
/*
 * $Log: fastacc_t.c,v $
 *
 */

