📄 stop.c
字号:
rGPJDAT |= ((0x0<<12)|(0x1<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)\
|(0x0<<7)|(0x1<<6)|(0x1<<5)|(0x1<<4)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
///////////////////////////////////////////////////////////////////////////////////////////
// VDD_RMOP
rMSLCON = 0x0;
///////////////////////////////////////////////////////////////////////////////////////////
// VDD_SMOP : sleep wakeup iteration fail or not?
rMSLCON = 0x0;
rGPKUDP &=~((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3)|(0x1<<4)|(0x1<<5)); // reset value = 0x3f; --> 0x30 = 2uA
rGPKUDP |= (0x3<<4);
}
volatile unsigned int mslcon_bakup,mslcon_bakup2;
void ConfigMiscIO_stop(void)
{
//unsigned int mslcon_bakup;
// memory data/control signal pin status definition when sleep.
//mslcon_bakup = rGPADAT;
mslcon_bakup = rMISCCR;
//rMISCCR;
// In the evaluation board, Even though in sleep mode, the devices are all sDNplied the power.
//rMSLCON = (0<<11)|(0<<10)|(0<<9)|(0<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);
rMISCCR |= (1<<13)|(1<<12);
//rGPADAT |= (1<<13)|(1<<12);
// ows
//rMSLCON = (1<<11)|(0<<10)|(0<<9)|(0<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);
//rMSLCON = (0<<11)|(0<<10)|(0<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0);
// Memory interface signal definition when sleep mode.
//PSC_DATA [11] DATA status, 0:output "0" ( All 32-bit data Low drive ), 1:Hi-Z
//PSC_WAIT [10] nWAIT status, 0:output "0", 1: input
//PSC_RnB [9] RnB status, 0:output "0", 1: input
//PSC_NF [8] NAND Flash I/O status, 0:inactive nFCE,nFRE,nFWE,ALE,CLE = 11100, 1: Hi-Z
//PSC_SDR [7] nSRAS, nSCAS status, 0:inactive( "11"), 1: Hi-Z
//PSC_DQM [6] DQM[3:0]/nWE[3:0] status, 0:inactive( "0000"), 1:Hi-Z
//PSC_OE [5] nOE status, 0:inactive( "1"), 1:Hi-Z
//PSC_WE [4] nWE status, 0:inactive( "1"), 1:Hi-Z
//PSC_GCS0 [3] nGCS[0] status, 0:inactive( "1"), 1:Hi-Z
//PSC_GCS[5:1][2] nGCS[5:1] status, 0:inactive( "1"), 1:Hi-Z
//PSC_GCS6 [1] nGCS[6] status, 0:inactive( "1"), 1:Hi-Z
//PSC_GCS7 [0] nGCS[7] status, 0:inactive( "1"), 1:Hi-Z
#if 1 // 0:*1, 1:*2.
//printf("Drive strength control(*2).\n");
// dsc0_bak = rDSC0;
// dsc1_bak = rDSC1;
// rDSC0 = 0x7fffffff;
// rDSC0 &= ~(1<<31); //enable
// nEN_DSC [31] Enable Drive strength control, 0:enable
// DSC_ADR [9:8] Address bus drive strength. 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_DATA [7:0] Data bus drive strength, 0:12mA, 1:10mA, 2:8mA, 3:6mA
//rDSC1 = (3<<28)|(3<<26)|(3<24)|(3<<22)|(3<<20)|(3<<18);
// rDSC1 = 0x7fffffff;
// 0:16mA, 1:12mA, 2:8mA, 3:6mA
//DSC_SCK1 [29:28] SCLK1
//DSC_SCK0 [27:26] SCLK0
//DSC_SCKE [25:24] SCKE
//DSC_SDR [23:22] nSRAS/nSCAS
//DSC_NFC [21:20] Nand Flash(nFCWE, nFRE, nFWE,CLE,ALE) Control
//DSC_BE [19:18] nBE[3:0]
//DSC_WOE [17:16] nWE/nOE
//DSC_CS7 [15:14] nGCS7
//DSC_CS6 [13:12] nGCS6
//DSC_CS5 [11:10] nGCS5
//DSC_CS4 [9:8] nGCS4
//DSC_CS3 [7:6] nGCS3
//DSC_CS2 [5:4] nGCS2
//DSC_CS1 [3:2] nGCS1
//DSC_CS0 [1:0] nGCS0
#else
//printf("Drive strength control(*1).\n");
//rDSC0 |= (1<<31); //disable
//rDSC0 = (1<<31)|(3<<8)|(3<<0);
// nEN_DSC [31] Enable Drive strength control, 1:enable
// DSC_ADR [9:8] Address bus drive strength. 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_DATA [7:0] Data bus drive strength, 0:12mA, 1:10mA, 2:8mA, 3:6mA
//rDSC1 = (3<<28)|(3<<26)|(3<24)|(3<<22)|(3<<20)|(3<<18);
#endif
}
volatile unsigned int cnt_Stop=0;
//volatile unsigned int error=0;
void Test_StopMode(void)
{
int i,a,b;
U32 portStatus1[32]; // A ~ H, 8*4=32
U32 portStatus2[16]; // J ~ M, 4*4=16
int error=0;
int mode;
int count=0;
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("S3C2443 will wake up by EINT0 & EINT11 (Falling Edge Triggered).\n");
rGPFUDP &= ~(1<<1); // Pull up down disable
rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //GPF0=EINT0
rEXTINT0=rEXTINT0&~(0x7<<0)|(0x2<<0); //EINT0=falling edge triggered
rGPGUDP &=~ (1<<7);
rGPGCON=rGPGCON & ~(3<<6)|(2<<6); //GPG3=EINT11
rEXTINT1=rEXTINT1&~(7<<12)|(2<<12); //EINT11=falling edge triggered
printf("\nNow, I am entering Stop mode.\n");
Uart_TxEmpty(); //Wait until UART0 Tx buffer empty.
pISR_EINT0 = (U32)Eint0Int;
pISR_EINT8_23 = (U32)Eint8_23Int;
pISR_RTC = (U32)AlarmInt;
pISR_TICK = (U32)Tick_WakeDN;
rEINTPEND |= (1<<11); // clear EINT11 pending bit in rEINTPEND
rSRCPND = BIT_EINT0 | BIT_RTC | BIT_EINT8_23|BIT_TICK;
rINTPND = BIT_EINT0 | BIT_RTC | BIT_EINT8_23|BIT_TICK;
rEINTMASK &= ~(1<<11);
rINTMSK &=~(BIT_EINT0|BIT_RTC|BIT_EINT8_23|BIT_TICK);
rADCCON|=(1<<2); // ADC stanby.
LcdEnvidOnOff(0);// jcs 060610 //Before entering Sleep mode, LCD must be off
Delay(1);
// ConfigStopGPIO();
// ConfigMiscIO_stop();
/*
printf("Alarm wake-up (y/n)? ");
if(getchar()=='y')
{
printf("\nS3C2443 will wake up by RTC alarm(10 sec) \n");
SetAlarmWakeUp2();
}
printf("RTC tick interrupt (y/n)? ");
if(getchar()=='y')
{
printf("\nS3C2443 will wake up by RTC tick(4 sec) \n");
RTC_TimeTickSet(); // wake up will be occurred after 4sec!!!
}
*/
// SetAlarmWakeUp2();
printf("rPWRCFG: 0x%x", rPWRCFG);
Uart_TxEmpty();
// Entering the STOP mode
//*************************//
rOSCSET=0xffff;
printf("rOSCSET: %x\n", rOSCSET);
rPWRCFG=(1<<15)|(0<<9)|(0<<8)|(0<<7)|(0<<4)|(0<<3)|(0<<2)|(1<<0);
rPWRMODE=(1<<16);
/////////////////////////////// wakeup ///////////////////////////////
rPWRMODE &= ~(1<<16);
rPWRCFG=(1<<4); // USB Phy power on
//rTICNT0 &= ~(0<<7); // Tick Time Interrupt Enable
//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];
}
rINTMSK &=~(BIT_EINT0|BIT_RTC|BIT_EINT8_23|BIT_TICK);
rINTMSK =BIT_ALLMSK;
Led_Display(0xa);
// Lcd_EnvidOnOff(1); // jcs 060610
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_SoftMode(void)
{
printf("Software reset Test \n",rRSTSTAT);
//Check wake-DN reset
if( rRSTSTAT & (1<<0) ) // nRESET?
{
printf("\n__ Wake-UP by nRESET\n");
rRSTSTAT |= (1<<0);
}
else if( rRSTSTAT & (1<<2) ) // WDTRST?
{
printf("\n__ Wake-UP by WDTRST\n");
rRSTSTAT |= (1<<2);
}
else if( rRSTSTAT & (1<<3) ) // SLEEP?
{
printf("\n__ Wake-UP by SLEEP\n");
rRSTSTAT |= (1<<3);
}
else if( rRSTSTAT & (1<<4) ) // ESLEEP?
{
printf("\n__ Wake-UP by ESLEEP\n");
rRSTSTAT |= (1<<4);
}
else if( rRSTSTAT & (1<<5) ) // SWRST?
{
printf("\n__ Wake-UP by SWRST\n");
rRSTSTAT |= (1<<5);
}
// rPWRCFG|=(1<<9); // nand reset disable
rSWRST = 0x533c2443;
}
void RTC_TimeTickSet(void)
{
int i;
printf("RTC Tick set\n");
rRTCCON = (rRTCCON & ~(0x7<<5)) | (1<<5);
rTICNT0=0x7f; // upper count
rTICNT1=0xff; // Lower count
rTICNT0 |= (1<<7); // Tick Time Interrupt Enable
rRTCCON|=0x1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -