/* X608Demo.c: Demo program for X608 Compiler: BC++ 3.1 Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X608.c ..\..\lib\7188xbl.lib ..\..\lib\XBoard\X608.lib Hardware: 7188XB + X608 [June/20/2002] by David [07/July/2005] by Liam /********************* M5M51008 ********************************** * Funtion: 512K Byte SRAM (1k Block,one Block is 128 Byte) * * * * Date: 2002/6/20 * * ControlPin: /OE ---> /RD * * /S1 ---> /CS * * S2 ---> DIO14 * * /W ---> /WR * * * * offset 0~127 bytes * * 0 1 2 125 126 127 byte * * ----+---+---+---------------+---+---+---+ * * Block 0 | | | | | | | | * * |---+---+---+-------------- +---+---+---+ * * Block 1 | | | | | | | | * * |---+---+---+-------------- +---+---+---+ * * : : * * : : * * : : * * : : * * : : * * ----+---+---+---------------+---+---+---+ * * Block 4092 | | | | | | | | * * |---+---+---+---------------+---+---+---+ * * Block 4093 | | | | | | | | * * |---+---+---+---------------+---+---+---+ * * Block 4094 | | | | | | | | * * |---+---+---+---------------+---+---+---+ * * Block 4095 | | | | | | | | * * |---+---+---+---------------+---+---+---+ * * * * **************************************************************/ #include #include #include #include #include "..\..\lib\7188xb.h" #include "..\..\lib\Xboard\X608.h" void main(void) { uchar Wdata[100]; uchar Rdata[100]; int WData, RData, iRet, iAction, block, offset; int len, i, quit; unsigned addr=0; InitLib(); X608_Init(); //Initialize the X608 Puts("\r\n"); Puts("*******************************************\r\n"); Puts("| Demo program for 7188XB + X608 |\r\n"); Puts("| |\r\n"); Puts("| [28,Juiy,2002] by DAVID |\r\n"); Puts("*******************************************\r\n"); while(iAction!=5) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Use [Absolute address] method to test 1 byte of 512K SRAM\r\n"); Puts("2) Use [Block ,Offset] method to test 1 byte of 512K SRAM\r\n"); Puts("3) Use [Absolute address] method to test N byte of 512K SRAM\r\n"); Puts("4) Use [Block ,Offset] method to test N byte of 512K SRAM\r\n"); Puts("\r\n"); Puts("5) Quits demo program\r\n\r\n"); Puts("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Puts("\r\n"); switch(iAction) { /************************************************************/ /* Use [Absolute address] method to test 1 byte of 512K SRAM*/ /************************************************************/ case 1: X608_Init(); Print("Please input a absolute addrss ( 0-65535 ) to write SRAM:"); Scanf("%u", &addr); Print("Please input data( 0-255) to write SRAM:"); Scanf("%d", &Wdata[0]); X608_WriteFn(addr, 1, Wdata); X608_ReadFn(addr, 1, Rdata); Print("\n\rAddr[%5u]: Write data = %3d ,Read data = %3d.", addr, Wdata[0], Rdata[0]); break; /**********************************************************/ /* Use [Block ,Offset] method to test 1 byte of 512K SRAM */ /**********************************************************/ case 2: X608_Init(); Print("Please select block ( 0-1023 ) to write SRAM:"); Scanf("%d", &block); Print("Please select offset( 0-127 ) to write SRAM:"); Scanf("%d", &offset); Print("Please input data( 0-255 ) to write SRAM:"); Scanf("%d", &WData); X608_Write(block, offset, WData); RData=X608_Read(block, offset); Print("\r\n[%4d,%3d]: Write data = %3d ,Read data = %3d.", block, offset, WData, RData); break; /************************************************************/ /* Use [Absolute address] method to test N byte of 512K SRAM*/ /************************************************************/ case 3: X608_Init(); Print("Please input a absolute addrss ( 0-65535 ) to write SRAM:"); Scanf("%u", &addr); Print("Please input data( 0-255 ) to write SRAM:"); Scanf("%d", Wdata); Print("Please input N(0-65535) byte to write SRAM:"); Scanf("%d", &len); for(i=0; i