?? power.c
字號:
/*****************************************
NAME: power.c
DESC: SLOW,HOLD mode test
HISTORY:
03.23.2002:purnnamu: first release for 2410
06.02.2002:DonGo: Modified for 2442
*****************************************/
#include "def.h"
#include "option.h"
#include "2413addr.h"
#include "Console.h"
#include "System.h"
#include "lcdlib.h"
#include "sleep.h"
#include "power.h"
#include "idle.h"
void __irq SlowEint0Int(void);
volatile int slowExit;
void * func_power_test[][2]=
{
// "0123456789012345678"
//Power mode test
//(void *)Check_SleepWakeUp, "WakeUp status ",
//(void *)Test_SlowMode, "Slow mode test ",
//(void *)Test_HoldMode, "Hold mode test ",
//Clock test
//(void *)Test_Locktime, "Lock time test ",
//(void *)Test_PLL, "PLL change test ",
//(void *)Manual_Change_Pll, "PLL change(manual)",
//(void *)Manual_Change_Pll_Iostrength, "IO strneght test ",
//(void *)Test_PllOnOff, "PLL On/Off test ",
//(void *)MeasurePowerConsumption, "Power consumption ",
// Sleep mode test
(void *)Eint_test, "EINT test ",
(void *)Test_IdleMode, "Idle mode test ",
(void *)Test_IdleModeHard, "Idle mode hard ",
(void *)Test_MMUIdleMode, "Idle mode(MMU) ",
(void *)Test_SleepMode, "Sleep mode test ",
(void *)Test_StopMode, "Stop mode test ",
(void *)Test_SoftMode, "Soft Reset Test ",
//(void *)Test_SleepMode_100Hz, "Sleep mode 100Hz ",
//(void *)Test_BattFaultInterrupt, "nBATT_FLT intr ",
//(void *)Test_InitSDRAM, "SDRAM init ",
// I/O strength test.
//(void *)Test_IO_Strength, "IO Strength ",
//(void *)Dvs_Test, "DVS test ",
0,0
};
void Power_Test(void)
{
int i;
printf("\nPower mode test.\n");
// Battery fault setting.
rMISCCR = (rMISCCR & ~(0x7<<20)) | (1<<22) | (1<<21) | (0<<20);
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_power_test[i][1]);
i++;
if((int)(func_power_test[i][0])==0)
{
printf("\n");
break;
}
if((i%3)==0)
printf("\n");
}
printf("\nSelect (\"-1\" to exit) : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_power_test)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_power_test[i][0]) )();
}
printf("\nPower_Test program end.\n");
}
//////////////////////////////////////////////////////////////////////////
void Test_SlowMode(void)
{
#if 0
int i;
unsigned int saveREFRESH;
slowExit=0;
// GPIO and Interrupt setting
rGPFCON=(rGPFCON & ~(0x3<<0)) | (0x2<<0); //PF0=EINT0
rEXTINT0=(rEXTINT0&~(0x7<<0)) | (0x2<<0); //EINT0=falling edge triggered
pISR_EINT0=(U32)SlowEint0Int;
rINTMSK=~BIT_EINT0; // Unmask eint0
printf("[SLOW MODE TEST]\n");
printf(" Press EINT0 key to exit SLOW mode\n");
printf(" Check the CLKOUT0 pad clock is the same as X-tal input in Slow mode.\n");
printf(" Compare the LED Blink speed at each mode.\n");
printf("\n Press any key to enter slow mode.\n");
//Uart_TxEmpty(1); //To avoid being crushed the character
//Clk0_Enable(2); // 0:MPLLin, 1:UPLL, 2:FCLK, 3:HCLK, 4:PCLK, 5:DCLK0
while(!slowExit) {
Led_Display(0xa);
//DoQsort();
for(i=0; i<100; i++);
Led_Display(0x5);
//DoQsort();
for(i=0; i<100; i++);
if(Uart_GetKey()!=0) break;
}
//rCLKSLOW=(1<<7)|(1<<5)|(1<<4)|(0<<0); //FCLK=FIN/1,SLOW mode,MPLL=off,UPLL=off
// Re-setting the refresh count for 12MHz HCLK.
saveREFRESH=rREFRESH;
rREFRESH=(1<<23)|(U32)(2048+1-12*7.8); //Trp=2clk,Trc=4clk
while(!slowExit) {
Led_Display(0xa);
//DoQsort();
//for(i=0; i<100; i++);
Led_Display(0x5);
//DoQsort();
//for(i=0; i<100; i++);
}
rINTMSK=BIT_ALLMSK;
//rCLKSLOW=0|(1<<4)|(0<<5);//PLL on,MPLL=on
for(i=0;i<2048;i++); //S/W MPLL lock-time
//rCLKSLOW=0|(0<<4)|(0<<5);//NORMAL mode,PLL on,MPLL=on
#endif
}
void __irq SlowEint0Int(void)
{
ClearPending(BIT_EINT0);
slowExit=1;
}
void Test_HoldMode(void)
{
#if 0
printf("[Power Saving Mode by Stopping Each Block]\n");
printf("LCD ENVID is turned off.\n");
Lcd_EnvidOnOff(0);
printf("Check the current cunsumption. Type any key to proceed.\n");
//Except GPIO,UART0
rCLKCON=0xffff0; // All enable. sleep disable, Idle trable.
getchar();
printf("Nand off.\n");
rCLKCON&=~(1<<4);
getchar();
printf("LCD off.\n");
rCLKCON&=~(1<<5);
Lcd_EnvidOnOff(0);
getchar();
printf("USB host off(DP0/DN0 is suspended).\n");
rCLKCON&=~(1<<6);
rMISCCR|=(1<<12); //USB port0 = suspend
getchar();
printf("USB device off(DP1/DN1 is also suspended).\n");
rCLKCON&=~(1<<7);
rMISCCR|=(1<<13); //USB port1 = suspend
getchar();
printf("PWM Timer off.\n");
rCLKCON&=~(1<<8);
getchar();
printf("SDI off.\n");
rCLKCON&=~(1<<9);
getchar();
printf("UART0 off.\n");
rCLKCON&=~(1<<10);
getchar();
printf("UART2 off.\n");
rCLKCON&=~(1<<12);
getchar();
printf("RTC_control off.\n");
rCLKCON&=~(1<<14);
getchar();
printf("ADC off.\n");
rADCCON|=(1<<2); // ADC stand-by mode select
rCLKCON&=~(1<<15);
getchar();
printf("IIC off.\n");
rCLKCON&=~(1<<16);
getchar();
printf("IIS off.\n");
rCLKCON&=~(1<<17);
getchar();
printf("SPI off.\n");
rCLKCON&=~(1<<18);
getchar();
printf("Camera off.\n");
rCLKCON&=~(1<<19);
getchar();
printf("Return to Normal Mode.\n");
rCLKCON=0xffff0;
rADCCON&=(1<<2);
rMISCCR&=~((1<<12)|(1<<13)); //USB port0,1 = normal
Lcd_EnvidOnOff(1);
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -