#use "default.h"

#if ((BOARD_TYPE==L_STAR) || (BOARD_TYPE==CPLC_BOARD))
#use cplc.lib
#endif

/*
	UIRAW.C

   Sample program to read the XP8100's 16 digital inputs in one function call.

   Data are read raw with the even inputs (0,2,4,6,8,10,12,14) in the
   lower byte and the odd inputs (1,3,5,7,9,11,13,15) in the high byte.

   Set the J2, J3, J4 and J5 jumpers to pull up or pull down the inputs.
   Jumper H4 should be jumpered 2-3 for digital input (1-2 is "universal").

   Board to be read is specified with the low nibble of the actual board
   address.

   Works with any board that has the PLCBUS.
*/

main()  
{
int error;
unsigned int data;
char c;

#if ((BOARD_TYPE==CPLC_BOARD) + (BOARD_TYPE==L_STAR)) 
      uplc_init();
#endif
    reset_pbus();
    reset_pbus_wait();

#if BOARD_TYPE==L_STAR    
    reset_pbus_wait();  // do twice to accomodate the PK2200/Little Star
#endif    
    _uiLocateBrd();  // find the available universal input boards

    data = _uiRaw16(0,&error);  // read board 0x40
    if(error==-1) printf("Board 0x40 not found.\n");
    else printf("Board 0x40 Inputs >> %x\n",data);

    data = _uiRaw16(1,&error);   // read board 0x41
    if(error==-1) printf("Board 0x41 not found.\n");
    else printf("Board 0x41 Inputs >> %x\n",data);
}

