/* Pwrsave.c: How to use CPU(AM188ES)'s power save mode. 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: Pwrsave.c ..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XL.Lib or 7188EL.Lib) Hardware: 7188/8000 Detail description: When com1's CTS is InActive,--> go to power save mode. When com1's CTS is Active, --> back to normal mode. So the remote node must use RTS to control the power save mode. Before send command to 7188XC, must set back to normal mode, Then wait a moment for 7188XC to go back to normal mode (7188XC will set RTS active for it is on normal mode), then it can receive the RS-232 data correctly. When in power save mode ,Please Enable WDT, and user's program must refresh WDT. Execution: 1. Run 7188xw.exe in PC. 2. Run "pwrsave /d(x)" (mode ==> x: range from 0 to 7) range 0-7, --> the system clock is divide by: 0 --> 1 1 --> 2 2 --> 4 3 --> 8 4 --> 16 5 --> 32 6 --> 64 7 --> 128 3. User can pull out the com1's plug to save mode, and plug in the com1's plug to normal mode. [24 May,2005] by Bill */ #include #include"..\lib\7188Xb.h" void SetToPowerSaveMode(int mode); void SetToPowerNormalMode(void); void ShowSave(void); void ShowNormal(void); void main(int argc,char *argv[]) { int i,key; int divide=1; int quit=0; int mode=0; /* 0 : normal mode, 1: save mode */ InitLib(); for(i=1;i='0' && argv[i][2]<='7') { divide=argv[i][2]-'0'; } break; } } } ShowNormal(); while(!quit) { if(mode) { /* in power save mode */ EnableWDT(); while(!GetCtsStatus1()) { mode=0; /* back to normal mode */ SetToPowerSaveMode(divide); RefreshWDT(); } DisableWDT(); mode=0; /* back to normal mode */ SetToPowerNormalMode(); ShowNormal(); } if(Kbhit()) { key=Getch(); switch(key) { case 'q': quit=1; break; default: Putch(key); break; } } if(!GetCtsStatus1()) { mode=1; ShowSave(); } } SetToPowerNormalMode(); } void SetToPowerSaveMode(int mode) { unsigned syscon; mode&=7; /* */ syscon=inpw(0xfff0); syscon &= (~7); syscon |= mode+0x8000; outpw(0xfff0,syscon); SetRtsInactive1(); } void SetToPowerNormalMode(void) { unsigned syscon; syscon=inpw(0xfff0); syscon &= (~0x8000); outpw(0xfff0,syscon); SetRtsActive1(); } //Show "Save" in the 7-segment display for save mode. void ShowSave(void) { Set5DigitLedIntensity(1); Show5DigitLed(1,5); Show5DigitLed(2,10); Show5DigitLedSeg(3,0x3E); Show5DigitLed(4,14); } //Show "7188" in the 7-segment display for normal mode. void ShowNormal(void) { Set5DigitLedIntensity(7); Show5DigitLed(1,7); Show5DigitLed(2,1); Show5DigitLed(3,8); Show5DigitLed(4,8); Show5DigitLed(5,16); }