/* 
8K_DIO.c :This demo program is uesed in DIO module.     

Compiler: BC++ 3.1,                                                            
          Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum)
          MSC 6.0,                                                             
          MSVC 1.52.                                                           
                                                                               
Compile mode: large                                                            
                                                                               
Project: 8K_DIO.c                                                               
         ..\Lib\(8000.Lib, 8000E.lib)   
                                                                               
Hardware: 8000

[24 May,2005] by Bill
*/
 
#include <stdio.h>  
#include "..\..\lib\vp2k.h" //I-8000 Series Function Call Declaration

void main()
{
    unsigned int DIdata,DOdata;
    int iSlot,iChannelNum;
    unsigned char cTemp[10];
    
    InitLib();
    
    Print("Please Input Slot Number(0~3 or 0~7)=");
    LineInput(cTemp,10);
    sscanf(cTemp,"%d",&iSlot);
    
    Print("Please Input Channel Number:");
    LineInput(cTemp,10);
    sscanf(cTemp,"%d",&iChannelNum);
    
    for(;;)
    {      
        Print("Please Input DO Data(Hex) = ");
        LineInput(cTemp,10);
        sscanf(cTemp,"%X",&DOdata);
        
        if(iChannelNum<=16)
        {
            //for DO channels
            DIO_DO_8(iSlot,DOdata);
            Print("DO ok.\n\r");
            
            //for DI channels
            DIdata = DI_8(iSlot);
            Print("DI data = %02X\n\r",DIdata);
        }       
        else if(iChannelNum==32)
        {
            //for DO channels
            DIO_DO_16(iSlot,DOdata);
          	Print("DO ok.\n\r");
          	
          	//for DI channels
          	DIdata = DI_16(iSlot);
            Print("DI data = %04X\n\r",DIdata);
        }
    }
}