⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 power_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif	

	INTC_SetVectAddr(NUM_PENDN, Isr_ADCTS_Wu);
	INTC_Enable(NUM_PENDN);

}



//////////
// Function Name : SetKeypadWakeup
// Function Description : 
// Input : 	None
// Output :	None 
// Version : v0.1
void SetKeypadWakeup (void)
{	
	u32 uGPACONSLP, uGPAPUDSLP;

	//EVT0
	uGPACONSLP = Inp32(0x7F00800C);
	uGPAPUDSLP = Inp32(0x7F008010);

	
	Outp32(0x7E00A004, 0xFF);	
	KEYPAD_Init();

	KEYPAD_SelectINT(1);		//Falling Edge
	//KEYPAD_EnableWakeup(3);	// 0x7E00_A000
	KEYPAD_COL(0,0);

	INTC_SetVectAddr(NUM_KEYPAD,Isr_KEYPAD);

	printf("	Keypad  is set for wake-up source\n");
	INTC_Enable(NUM_KEYPAD);

	// EVT0 
	Outp32(0x7F00800C, uGPACONSLP);
	Outp32(0x7F008010, uGPAPUDSLP);

}



#if 0
//////////
// Function Name : SetHSIWakeup
// Function Description : 
// Input : 	None
// Output :	None 
// Version : v0.1
void SetHSIWakeup (void)
{	
	HSI_SetPort();

	//prepare data
	PrepareTxData();
	PrepareRxData();

	//ISR mapping and interrupt enabling	
	INTC_SetVectAddr(NUM_HSIrx, HSI_Rx_ISR);
	INTC_Enable(NUM_HSIrx);

	HSI_SetForRx(HSI_INT_MODE, HSI_FRAME_MODE, HSI_SINGLE_CHID_MODE, HSI_CHID_3BIT);
	HSI_UnmaskRxInt(0xfb);	// unmask all interrupts except rx-done
	printf("	HSI  is set for wake-up source\n");
}
#endif

//////////
// Function Name : BatteryFaultEvent
// Function Description : Isr 
// Input : 	None
// Output :	None 
// Version : v0.1
void __irq Isr_WUBATF(void)
{
	SYSC_ClrBATFINT();
	printf("[WU]Battery Fault is occurred!\n");
	INTC_ClearVectAddr();
}

//////////
// Function Name : BatteryFaultEvent
// Function Description : Isr 
// Input : 	None
// Output :	None 
// Version : v0.1
void __irq Isr_WUBATF1(void)
{
	SYSC_ClrBATFINT();

	Outp32Inform(7, Inp32SYSC(0x90c));
	SYSC_SetCFGWFI(eSLEEP, 0);
	Stop_WFI_Test();
	
	INTC_ClearVectAddr();
}


//////////
// Function Name : Isr_Eintx
// Function Description : EINT ISR Routine
// Input : 	None
// Output :	None 
// Version : v0.1
void __irq Isr_WUEint9(void)
{
          
	GPIO_EINT0ClrPend(9);
	
	//printf("[WU] EINT9 interrupt is occurred .\n");
      // printf("0x7f008924= 0x%x\n", Inp32(0x7F008924));
	INTC_ClearVectAddr();  
    
}

void __irq Isr_WUEint10(void)
{
          
	GPIO_EINT0ClrPend(10);
	printf("[WU]EINT10 interrupt is occurred .\n");

	INTC_ClearVectAddr();
    
}

void __irq Isr_WUEint11(void)
{
          
	GPIO_EINT0ClrPend(11);
	printf("[WU]EINT11 interrupt is occurred .\n");

	INTC_ClearVectAddr();
    
}


//////////
// Function Name : SetBatteryFaultEvent
// Function Description : Setting Battery Falult Event
// Input : 	None
// Output :	None 
// Version : v0.1
void SetBatteryFaultEvent(BATFLT_eMODE eBATFLT)
{



	if(eBATFLT==eFLT_INT)
	{
		//Outp32SYSC(0x804,0x80); // BATFn_MASK_??
		
		INTC_SetVectAddr(NUM_BATF, Isr_WUBATF);
		SYSC_SetBATF(eFLT_INT, 0);
		INTC_Enable(NUM_BATF);
	}
	if(eBATFLT==eFLT_SLEEP)
	{
		printf("Inform register is set!\n");
		Outp32Inform(0,0xABCD6400);	
		SYSC_SetBATF(eFLT_SLEEP, 1);	
	}
}

//////////
// Function Name : CheckHCLK_ForPM
// Function Description : Checking & Enable HCLK_GATE[22,21,0]
// Input : 	None
// Output :	None 
// Version : v0.1
void CheckHCLK_ForPM(void)
{
	u32 uRegValue;

	uRegValue = Inp32SYSC(0x30);
	uRegValue = (uRegValue & ~((0x3<<21)|(0x1<<0))) | ((0x3<<21)|(0x1<<0));
	Outp32SYSC(0x30, uRegValue);

	

}

//////////
// Function Name : CheckBLKPWR_ForPM
// Function Description : Checking & Enable NORMAL_CFG
// Input : 	None
// Output :	None 
// Version : v0.1
void CheckBLKPWR_ForPM(void)
{
	u32 uRegValue;

	uRegValue = Inp32SYSC(0x90c) & 0x7F;
	if(uRegValue != 0x7F)
	{
		Outp32SYSC(0x810, 0xFFFFFF00);	// All Sub block Power Enable			
		while(!(Inp32SYSC(0x90C) == 0x7F));
	}
}

//////////
// Function Name : CheckWAKESTAT_ForPM
// Function Description : Checking & Clear Wakeup Status
// Input : 	None
// Output :	None 
// Version : v0.1
void CheckWAKESTAT_ForPM(u32 uPrint)
{
	u32 uRegValue;

	uRegValue =Inp32SYSC(0x908);
	if (uPrint==1)
	{
	printf("Wake-up Status Register:	0x%x\n",  uRegValue);
	}
	Outp32SYSC(0x908, uRegValue);
}



//////////
// Function Name : IDLET_Baisc
// Function Description : Idle Mode Test - Baisc Test ( 1 Int. Source Enable, Not adapted DVS Scheme)
// Input : 	None
// Output :	None 
// Version : v0.1

void IDLET_Basic (void)
{
	u32 uRegValue;
	
	printf("[IDLE Mode Baisc Test]\n");
	printf("After 10 seconds, S3C6400 will wake up by RTC alarm interrupt.\n");
	printf("S3C6400 will also wake up by EINT9, ADCTS, or BATT_FLT.\n");
	
	
	////////////////////////////////
	// Wake-up Source Setting
	////////////////////////////////
	printf("Wake-up sourceis set! \n");
	SetEintWakeup();
	SetADCTSWakeup();
	SetAlarmWakeup();
	SetBatteryFaultEvent(eFLT_INT);

	////////////////////////////////
	// Enter Idle Mode
	// 		1. Setting "CFG_STANDBYWFI" to "2'b01"  ( PWR_CFG(0x7E00_F804)
	//          2.  Enter to the STANDBYWFI Command
	////////////////////////////////
	
	printf("CPU will goes to IDLE Mode \n");
	UART_TxEmpty();

	SYSC_SetCFGWFI(eIDLE,0);		// IDLE,  Clock Disable
	MMU_WaitForInterrupt();


	printf("Return to Normal Mode \n\n");
	printf("rWAKEUP_STAT=0x%x\n", Inp32SYSC(0x908));
	uRegValue=Inp32SYSC(0x908);
	Outp32SYSC(0x908,uRegValue);
	printf("rWAKEUP_STAT=0x%x\n Wake-up Status Clear\n", Inp32SYSC(0x908));

	// Int. Disable
	INTC_Disable(NUM_EINT1);
	INTC_Disable(NUM_RTC_ALARM);
	INTC_Disable(NUM_BATF);
	INTC_Disable(NUM_PENDN);

}


//////////
// Function Name : STOPT_Basic 
// Function Description : Stop Mode Test - Baisc Test 
// Input : 	None
// Output :	None 
// Version : v0.1

void STOPT_Basic (void)
{
	u32 uRegValue;
	
	printf("\n[STOP Mode Basic Test]\n");
	printf("After 10 seconds, S3C6400 will wake up by RTC alarm interrupt.\n");
	printf("S3C6400 will also wake up by EINT9, ADCTS, or BATT_FLT.\n");


	////////////////////////////////
	//  Save I/O Ports 
	////////////////////////////////
	// Save the port configurations
	//printf("I/O Port is stored!\n");
	//for(i=0;i<36;i++) {
	//	portStatus[i]=*( (volatile U32 *)0x56000000 + i);	// 0x5600_0000:GPACON addr.
	//	}
	//printf("I/O Port is set for Stop Mode!\n");
	//ConfigStopGPIO();
	//ConfigMiscIO_stop();
	Outp32Inform(5, 0x0);

	printf("Wake-up source is set!\n");
	////////////////////////////////
	// Wake-up Source Setting
	//      Wake-up Source Interrupts are must enabled at Stop Mode
	////////////////////////////////
   	SetAlarmWakeup();
	SetEintWakeup();
	Outp32SYSC(0x804, 0x1<<7);			// nBATF Wake-up Mask disable
	SetBatteryFaultEvent(eFLT_INT);
	SetADCTSWakeup();

       /////////////////////////////////
       // 1) Check&Enable HCLK_GATE[22,21,0]
       // 2) Check BLK_PWR_STAT 
       // 3) Check&Clear WAKEUP_STAT
       //////////////////////////////
	CheckHCLK_ForPM();
       CheckBLKPWR_ForPM();
	CheckWAKESTAT_ForPM(1);
	
	printf("\nCPU will goes to Stop Mode!\n\n");
	UART_TxEmpty();				// 

	////////////////////////////////
	// Enter the Stop Mode
	// 		1. Setting "CFG_STANDBYWFI" to "2'b10"  ( PWR_CFG(0x7E00_F804)
	//          2. Setting "STOP_CFG"(0x7E00_F814) -> ARM_LOGIC/MEM, TOP_LOGIC/MEM ON, OSC_EN ="0"
	//          2.  Enter to the STANDBYWFI Command
	////////////////////////////////
	SYSC_OSCSTAB(1);			
	SYSC_SetSTOPCFG(1, 1, 1, 1);		// Set ARM_LOGIC/MEM, TOP_LOGIC/MEM to "1"
	SYSC_SetCFGWFI(eSTOP, 0);		// 
	MMU_WaitForInterrupt();


	
	////////////////////////////////
	//  Restore  I/O Ports 
	////////////////////////////////
	
/*
	//Restore the port configurations
	printf("\nI/O Port is restored!\n");
	for(i=0;i<36;i++){
		*( (volatile U32 *)0x56000000 + i)=portStatus[i];
	}
*/
	DisplayLED(0x3);
	printf("Return to Normal Mode.\n");
	printf("rWAKEUP_STAT=0x%x\n", Inp32SYSC(0x908));
	uRegValue=Inp32SYSC(0x908);
	Outp32SYSC(0x908,uRegValue);
	printf("rWAKEUP_STAT=0x%x\n Wake-up Status Clear\n", Inp32SYSC(0x908));
	
	SYSC_RdBLKPWR();

	// Int. Disable
	INTC_Disable(NUM_EINT1);
	INTC_Disable(NUM_RTC_ALARM);
	INTC_Disable(NUM_BATF);
	INTC_Disable(NUM_PENDN);

}

//////////
// Function Name : DeepStopStatus
// Function Description : This function  define Deepstop wake-up
// Input :   NONE			
// Output : true , false
// Version : 
bool DeepStopStatus(void)
{
	u32 uRead0, uRead1;
	
	uRead0=Inp32SYSC(0x804);			// Read PWR_CFG
	uRead1=Inp32SYSC(0x814);			// Read STOP_CFG

       uRead0 = (uRead0 >>5)& 0x3;			// Read CFG_STANDBYWFI
       uRead1 = (uRead1 >>17)&0x1;			// Read ARM_LOGIC

       if ((uRead0==0x2)&&(uRead1 == 0x0))
      	{
      	#if DBG_PRINT
      		printf("Wake-up from Deep Stop Mode \n");
      	#endif
		return true;
      	}
      	else
		return false;
}


//////////
// Function Name : DSTOPT_Basic 
// Function Description : Stop Mode Test - Baisc Test 
// Input : 	None
// Output :	None 
// Version : v0.1

void DSTOPT_Basic (void)
{
	//u32 uRegValue;
	u32	uDSTOP;

	uDSTOP= DeepStopStatus();
	SYSC_RdRSTSTAT(1);

	if( uDSTOP && !(g_OnTest_DSTOP) )									// must be changed
	{
		
		CheckData_SDRAM(_DRAM_BaseAddress+0x1000000, 0x10000);

		//Check & Clear Wake-up Source 
		SYSC_ClrWKUPSTAT();

		//Read RawInterrupt Status
		printf("VIC0RawStatus: 0x%x \n", Inp32(0x71200008));
		printf("VIC1RawStatus: 0x%x \n", Inp32(0x71300008));

		printf("Deep Stop mode test is done\n");
		g_OnTest_DSTOP = 1;
	}

else			// Entering into Deep Stop Mode
	{
		g_OnTest_DSTOP=0;
	
	printf("\n[Deep STOP Mode Basic Test]\n");
	printf("After 10 seconds, S3C6400 will wake up by RTC alarm interrupt.\n");
	printf("S3C6400 will also wake up by EINT9, ADCTS, or BATT_FLT.\n");


	printf("Test pattern for SDRAM Self-Refresh is filled!\n");
	InitData_SDRAM(_DRAM_BaseAddress+0x1000000, 0x10000);
	Outp32Inform(5, 0x0);
	////////////////////////////////
	//  Save I/O Ports 
	////////////////////////////////
	// Save the port configurations
	//printf("I/O Port is stored!\n");
	//for(i=0;i<36;i++) {
	//	portStatus[i]=*( (volatile U32 *)0x56000000 + i);	// 0x5600_0000:GPACON addr.
	//	}
	//printf("I/O Port is set for Stop Mode!\n");
	//ConfigStopGPIO();
	//ConfigMiscIO_stop();


	printf("Wake-up source is set!\n");
	////////////////////////////////
	// Wake-up Source Setting
	//      Wake-up Source Interrupts are must enabled at Stop Mode

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -