/*
	SPDEMOR.C

   Little Giant, Tiny Giant, Protocol Switch

   Demonstration of the high speed parallel protocol.
   Protocol runs in background, with the PC program SPDEMO.C
   transmitting and receiving a buffer of 1000 characters.

   Run with SPDEMO.C on PC side.
   
   See Applications Note #100 for information on the high speed protocol.
      
   NOTE: documentation may indicate the CLINK_NBUFS and clink_bufptrs,
         these are actually NBUFS and bufptrs.
*/

#use prport.lib

//#define NO_TIMEOUT 1 

// default configuration uses first PIO on protocol switch card 

// #define USELG 1  // activate for little giant card 
// #define USETG 1  // activate for tiny giant card 

#define NBUFS 3   // number of buffers visible to PC 

int buf0 [NBUFS] = {6, 2, 1002};
int buf1 [2];         // holds pctimeout and timeout 
char buf2 [1002];

char *bufptrs[NBUFS] = {buf0,buf1,buf2};

shared long counters;

#define ZEROWAIT 1

main()
{
   setwaits(1, 0);      // set wait states for mem and I/O 

   outport(OMCR, 0x40);

   piolatch();

   doreti();

   clink_init();

   counters = 0L;
   EI();         

   while(1)
   {
   	hitwd();
      runwatch();       // it's all in the background 
   }
}