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

📄 stop.c

📁 samsung 最新芯片2450 的测试程序.
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************

  NAME: stop.c
  DESC: Stop mode test(I/O current measure + ...)
  HISTORY:
  08.24.2002:purnnamu
	LCDVFn is connected the analog circuit in LCD. 
	So, this signal should be output L.
  05.xx.2003:DonGo modifid for 2442X, Power-off -> Sleep. naming change.
  12.04.2006:grmoon
  	- S3C2443 GPIO configuration setup
  10.31.2007: SKY
  	- Modified for 2450			
 ****************************************************************/
 

#include "System.h"
#include "stop.h"

static void __irq Eint0Int(void)
 {
 	printf("INTPND:%x, SRCPND:%x \n", rINTPND, rSRCPND);
	rEINTMASK |= (1<<0);	
	rEINTPEND |= (1<<0);
	ClearPending(BIT_EINT0);
	printf("EINT0 interrupt is occurred for STOP wake-up.\n");
}

#if 0
static void __irq Eint11Int(void)
 {
 	printf("INTPND:%x, SRCPND:%x \n", rINTPND, rSRCPND);
	rEINTMASK |= (1<<11);
	rEINTPEND |= (1<<11);
	ClearPending(BIT_EINT8_23);
	printf("EINT11 interrupt is occurred for Sleep wake-up.\n");
}
#endif

static void __irq AlarmInt(void)
{
	printf("INTPND:%x, SRCPND:%x \n", rINTPND, rSRCPND);
	rINTMSK |= BIT_RTC;	
	ClearPending(BIT_RTC);	
	printf("ALARM interrupt is occurred for STOP wake-up.\n");
	//rRTCCON = 0x0;	// R/W disable, but interrupt will be generated.
}

static void __irq TickInt(void)
{
	printf("INTPND:%x, SRCPND:%x \n", rINTPND, rSRCPND);
	rINTMSK |= BIT_TICK;	
	ClearPending(BIT_TICK);
	printf("Tick interrupt is occurred for STOP wake-up.\n");
	rTICNT0 &=~(0x1<<7);	// Tick Time Interrupt disable	
}

static void __irq BattFaultInt(void)
{
	printf("INTPND:%x, SRCPND:%x \n", rINTPND, rSRCPND);
	rINTMSK|= (BIT_BAT_FLT);	// mask.
	ClearPending(BIT_BAT_FLT)
	printf("BATT_FLT interrupt is occurred for STOP wake-up.\n");

}


void Test_StopMode(void)
{
     
	printf("[STOP Mode Test]\n");
	/*
	// Save the port configurations
	for(i=0;i<32;i++) {
		portStatus1[i]=*( (volatile U32 *)0x56000000 + i);	// 0x5600_0000:GPACON addr.
	}
	
	for(i=0;i<16;i++) {
		portStatus2[i]=*( (volatile U32 *)0x560000d0 + i);	// 0x5600_00d0:GPJCON addr.
	}  	
	*/

	printf("S3C2450 will wake up by EINT0 (Falling Edge Triggered).\n");
	rGPFCON = (rGPFCON & ~0x3)|(2<<0);			//GPF0 = EINT0
	rGPGCON = (rGPGCON & ~0xc0)|(2<<6);		//GPG3 = EINT11	
	rGPFUDP= (rGPFUDP & ~0x3);			//GPF0 up down disable
	rGPGUDP= (rGPGUDP & ~0xc0);		//GPG3 = EINT11	up down disable
	rEXTINT0 = (rEXTINT0 | (1<<3)); //EINT0 filter enable
	rEXTINT1 = (rEXTINT1 | (1<<15));//EINT11 filter enable
	rEXTINT0 = (rEXTINT0 & ~(7<<0))  | (0x2<<0) ; //EINT0=falling edge triggered
	rEXTINT1 = (rEXTINT1 & ~(7<<12)) | (0x2<<12); //EINT11=falling edge triggered

	pISR_EINT0=(U32)Eint0Int;
	//pISR_EINT8_23=(U32)Eint11Int;
	pISR_BAT_FLT = (U32)BattFaultInt;
	pISR_RTC=(U32)AlarmInt;	
	pISR_TICK	  = (U32)TickInt;	
	
	rEINTPEND = 0xffffff;
	rSRCPND = BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK; //to clear the previous pending states
	rINTPND = BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK;

	#if 1
 	printf("Alarm wake-up (y/n)? ");
	if(getchar()=='y')
	{
		printf("\nS3C2450 will wake up by RTC alarm(10 sec) \n");
		SetAlarmWakeUp();
	}

	printf("RTC tick interrupt (y/n)? ");
	if(getchar()=='y')
	{
		printf("\nS3C2450 will wake up by RTC tick(4 sec) \n");
		RTC_TimeTickSet();  // wake up will be occurred after 4sec!!!
	}
	
	#endif
	
	//SetAlarmWakeUp();	
	//RTC_TimeTickSet();
	//rADCCON|=(1<<2);	// ADC stanby	
 	//LcdEnvidOnOff(0);// jcs 060610 //Before entering stop mode, LCD must be off	
	//Delay(1);
	//	ConfigStopGPIO();
	//	ConfigMiscIO_stop();

	// Entering the STOP mode
	//*************************//
	Led_Display(0x5);	

	#if 1	
 	printf("WFI mode(y/n)? ");
	if(getchar()=='y')
	{
	rEINTMASK &= ~((1<<11)|(1<<0));
	rINTMSK &= ~(BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK);		
	Uart_TxEmpty();	//Wait until UART0 Tx buffer empty.		
	rOSCSET=0xffff;	
	rPWRCFG=(0<<16)|(1<<15)|(0<<9)|(0<<8)|(0<<7)|(0<<4)|(0<<3)|(0<<2)|(1<<0);

	rPWRCFG|=(1<<17);	
	rPWRCFG&=~(0x3<<5)|(0x01<<5);	
	MMU_WaitForInterrupt();	
	}
	else
	#endif		
	{
	rEINTMASK &= ~((1<<11)|(1<<0));
	rINTMSK &= ~(BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK);		
	Uart_TxEmpty();	//Wait until UART0 Tx buffer empty.		
	rOSCSET=0xffff;	
	rPWRCFG=(0<<17)|(1<<15)|(0<<9)|(1<<8)|(1<<7)|(0<<4)|(0<<3)|(0<<2)|(1<<0);	
	rPWRMODE=(1<<16);	
	}	

      /////////////////////////////// wakeup ///////////////////////////////

	rPWRMODE &= ~(1<<16); 
	rPWRCFG=(1<<4); // USB Phy power on

	//Lcd_EnvidOnOff(1);  // jcs 060610	
	rINTMSK =BIT_ALLMSK;		
	/*
	//Restore the port configurations
	for(i=0;i<32;i++){
		*( (volatile U32 *)0x56000000 + i)=portStatus1[i];
	}

       for(i=0;i<16;i++){
		*( (volatile U32 *)0x560000d0 + i)=portStatus2[i];
	}
	*/

	printf("Return to Normal Mode.\n");
	printf("wake-up= %08x\n", rWKUPSTAT);
	//Check wake-up source
	if( rWKUPSTAT & (1<<0) )		// EINT?
	{
		printf("\n__ Wake-up by EINT\n");
		rWKUPSTAT |= (1<<0);
	}
	else if( rWKUPSTAT & (1<<1) )	// RTC?
	{
		printf("\n__ Wake-up by RTC Alarm\n");
		rWKUPSTAT |= (1<<1);
	}
	else if( rWKUPSTAT & (1<<4) )	// RTC?
	{
		printf("\n__ Wake-up by RTC tick\n");
		rWKUPSTAT |= (1<<4);
	}
	else if( rWKUPSTAT & (1<<5) )	// BATFLT?
	{
		printf("\n__ Wake-up by nBATFLT\n");
		rWKUPSTAT |= (1<<5);
	}
	
}
void Test_DeepStopMode(void)
{
     
	printf("[Deep STOP Mode Test]\n");
	/*
	// Save the port configurations
	for(i=0;i<32;i++) {
		portStatus1[i]=*( (volatile U32 *)0x56000000 + i);	// 0x5600_0000:GPACON addr.
	}
	
	for(i=0;i<16;i++) {
		portStatus2[i]=*( (volatile U32 *)0x560000d0 + i);	// 0x5600_00d0:GPJCON addr.
	}  	
	*/

	printf("S3C2450 will wake up by RTC Alarm, RTC Tick, BATFLT, EINT0, EINT11.\n");
	rGPFCON = (rGPFCON & ~0x3)|(2<<0);			//GPF0 = EINT0
	rGPGCON = (rGPGCON & ~0xc0)|(2<<6);		//GPG3 = EINT11	
	rGPFUDP= (rGPFUDP & ~0x3);			//GPF0 up down disable
	rGPGUDP= (rGPGUDP & ~0xc0);		//GPG3 = EINT11	up down disable
	rEXTINT0 = (rEXTINT0 | (1<<3)); //EINT0 filter enable
	rEXTINT1 = (rEXTINT1 | (1<<15));//EINT11 filter enable
	rEXTINT0 = (rEXTINT0 & ~(7<<0))  | (0x2<<0) ; //EINT0=falling edge triggered
	rEXTINT1 = (rEXTINT1 & ~(7<<12)) | (0x2<<12); //EINT11=falling edge triggered

	pISR_EINT0=(U32)Eint0Int;
	//pISR_EINT8_23=(U32)Eint11Int;
	pISR_BAT_FLT = (U32)BattFaultInt;
	pISR_RTC=(U32)AlarmInt;	
	pISR_TICK	  = (U32)TickInt;	
	
	rEINTPEND = 0xffffff;
	rSRCPND = BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK; //to clear the previous pending states
	rINTPND = BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK;	

	#if 1
 	printf("Alarm wake-up (y/n)? ");
	if(getchar()=='y')
	{
		printf("\nS3C2450 will wake up by RTC alarm(10 sec) \n");
		SetAlarmWakeUp();
	}

	printf("RTC tick interrupt (y/n)? ");
	if(getchar()=='y')
	{
		printf("\nS3C2450 will wake up by RTC tick(4 sec) \n");
		RTC_TimeTickSet();  // wake up will be occurred after 4sec!!!
	}
	
	#endif
	
	//rADCCON|=(1<<2);	// ADC stanby	
 	//LcdEnvidOnOff(0);// jcs 060610 //Before entering stop mode, LCD must be off	
	//Delay(1);
	//	ConfigStopGPIO();
	//	ConfigMiscIO_stop();

	// Entering the STOP mode
	//*************************//
	Led_Display(0x5);	
	#if 1
 	printf("WFI mode(y/n)? ");
	if(getchar()=='y')
	{
	Uart_TxEmpty();	//Wait until UART0 Tx buffer empty.		
	rEINTMASK &= ~((1<<11)|(1<<0));
	rINTMSK &= ~(BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK);		
	rOSCSET=0xffff;	
	rPWRCFG=(1<<15)|(0<<9)|(0<<8)|(0<<7)|(0<<4)|(0<<3)|(0<<2)|(1<<0);

	rPWRCFG|=(1<<17)|(1<<16);	
	rPWRCFG&=~(0x3<<5)|(0x02<<5);	
	MMU_WaitForInterrupt();
	}
	else
	#endif
	{	
	Uart_TxEmpty();	//Wait until UART0 Tx buffer empty.		
	rEINTMASK &= ~((1<<11)|(1<<0));
	rINTMSK &= ~(BIT_EINT0|BIT_EINT8_23|BIT_BAT_FLT|BIT_RTC|BIT_TICK);	
	rOSCSET=0xffff;		
	rPWRCFG=(0<<17)|(1<<16)|(1<<15)|(0<<9)|(1<<8)|(1<<7)|(0<<4)|(0<<3)|(0<<2)|(1<<0);
	rPWRMODE=(1<<16);	
	}	

     
}

static void LcdEnvidOnOff(unsigned int onoff)
{
	if(onoff==1)
		rLCDCON1 = rLCDCON1|(3); // ENVID On using Per Frame method
	else 
		rLCDCON1 &= (~3); // ENVID Off using Per Frame method
}    

void ConfigStopGPIO(void)
{
   

⌨️ 快捷键说明

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