/*                                                                
8K_DI.c :This demo program is uesed in DI 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_DI.c                                                               
         ..\Lib\(8000.Lib, 8000E.lib)   
                                                                               
Hardware: 8000

[24 May,2005] by Bill
*/

#include "..\..\lib\vp2k.h" //I-8000 Series Function Call Declaration
#include <stdio.h>  

void main(void)
{
    unsigned long lData;
    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(8,16 or 32)");
    LineInput(cTemp,10);
    sscanf(cTemp,"%d",&iChannelNum);
    
    for(;;)
    {             
        if(iChannelNum<=8)
        {
            lData=DI_8(iSlot);
            Print("DI data = %02X\n\r",lData);   
        }
        
        else if(iChannelNum==16)
        {
            lData=DI_16(iSlot);
            Print("DI data = %04X\n\r",lData);   
        }
        
        else if(iChannelNum==32)   
        {
            lData=DI_32(iSlot);
            Print("DI data = %-08lX\n\r",lData);  
        }
    }
}