/*
87k_demo.c :This demo program is for 87K General Function in Com0.     
            User must to know: 
                1.The com0's baudrate is 115200. User don't modify it.
                2.User need to know the module's location in the MCU.     

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: 87K_demo.c                                                               
         ..\Lib\(8000.Lib, 8000E.lib)   
                                                                               
Hardware: 8000

[24 May,2005] by Bill
*/

#include "..\..\lib\vp2k.h"
/*
=== English comments ==========================================
This demo program is for all functions of 87K I/O modules .
Users can refer the demo to excute every commands list in 
87K I/O module's document. For example: $AAM, #AA, @AA, @AA6... etc.

If users wants to use AI,AO,DI,DO,DIO, we have prepared several
demos. Uers can copy the code from these demos then paste to 
their own program.

=== Chinese comments ==========================================
這個範例是針對 87K I/O 模組的全部功能。
使用者可以參考此範例來使用每一個 87K I/O 模組命令手冊中的功能。
例如 $AAM, #AA, @AA, @AA6... 等等。

假如使用者要使用 AI, AO, DI, DO, DIO 這些功能，我們已經準備了
數個現成的範例程式。你可以將這些程式碼直接複製到你的程式中來使用。
*/
void main()
{
	unsigned char InBufCom0[60];   
    
    InitLib();
    
    //Step 1:
    InstallCom_0(115200L,8,0,0); //(Baudrate,Data bit,Parity bit,Stop bit)
    
    //Step 2:
    ChangeToSlot(7);
    
    //Step 3:
    SendCmdTo7000(0,"$00M",0); 
        //Send command to COM0(Com port,command,Checksum=Disable)
        //For example: command="$00M" ===> Gets module name.
        //For detailed command sets,refer to 
        //CD:\DCON\IO_Module\hw_dcon_on_87kUnit 
    
    //Step 4:
    ReceiveResponseFrom7000_ms(0,InBufCom0,100,0);  
        //COM port=0,
        //InBufCom0: Pointer of input buffer to receive response
        //           from the 87K module,
        //Timeout=100ms,
        //Checksum=Disable
    
    //Step 5:
    Print("InBufCom0 = %s",InBufCom0);
    
    //Step 6:    
    RestoreCom0();
}