/* 87k_demo.c :This demo program is for 87K General Function in Com0. It can communicate with CM0 via DMA. If without DMA, it may caused communication lost data in send/receive long data. User needs to know: 1. The communication protocol for COM0 is always 115200,N,8,1 and Checksum disable. User can't modify it. 2. User need to know the module's location on Slot (Slot 0 ~ 7). Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) MSC 6.0, MSVC 1.52. Compile mode: large Project: 87K_demo.c ..\Lib\(8000.Lib, 8000E.lib) Hardware: 8000 [21 Jan,2014] by Hans */ #include"..\..\lib\8000a.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 硂ㄇи竒非称 计瞷Θ絛ㄒ祘Α盢硂ㄇ祘Α絏钡狡籹祘Αいㄓㄏノ */ char *_Demo_Date=__DATE__; void main() { unsigned char InBufCom0[60]; Print("/*******************/\n\r"); Print("/* 87K_ demo */\n\r"); Print("/* */\n\r"); Print("/* [%s] */\n\r",_Demo_Date); Print("/*******************/\n\r"); Print("\n"); InitLib(); //Step 1: Open COM 0 with DMA function InstallCom_DMA_0(115200L,8,0,1); //(Baudrate,Data bit,Parity bit,Stop bit) //Step 2: Change to 87k Slot 0 ChangeToSlot(0); //Step 3: Send command to 87k module 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: Receive data from 87k module 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 module name string Print("InBufCom0 = %s",InBufCom0); //Step 6: Close COM Port RestoreCom0(); }