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

📄 power.c

📁 2443 wince5.0 bsp, source code
💻 C
📖 第 1 页 / 共 2 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// -----------------------------------------------------------------------------
//
//      THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//      ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//      THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//      PARTICULAR PURPOSE.
//
// -----------------------------------------------------------------------------
#include <windows.h>
#include <bsp.h>
#include <s3c2443ref_gpio.h>

#define Clear_FrameBuffer 0xA0100000

void InitTimer(void);
void ConfigStopGPIO(void);
void Write_LDI_LTV350(int address, int data);

VOID BSPPowerOff()
{
	//RETAILMSG(1,(TEXT("BSPPowerOff\n")));
	volatile S3C2443_IOPORT_REG *pIOPort = (S3C2443_IOPORT_REG*)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
	volatile S3C2443_ADC_REG *pADCPort = (S3C2443_ADC_REG*)OALPAtoVA(S3C2443_BASE_REG_PA_ADC, FALSE);
 	volatile S3C2443_RTC_REG *pRTCPort = (S3C2443_RTC_REG*)OALPAtoVA(S3C2443_BASE_REG_PA_RTC, FALSE);
 	volatile S3C2443_LCD_REG *pLCDPort = (S3C2443_LCD_REG*)OALPAtoVA(S3C2443_BASE_REG_PA_LCD, FALSE);
	volatile S3C2443_CLKPWR_REG *pCLKPWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);


	ULONG *FrameBufferPtr = (ULONG *)Clear_FrameBuffer;
	ULONG FrameBufferCount;
	pRTCPort->RTCCON=0x0;   // R/W disable, 1/32768, Normal(merge), No reset
	pADCPort->ADCCON|=(1<<2);		// ADC StanbyMode

	// USB2.0 and PHY power
	pIOPort->MISCCR|=(1<<12); //USB port = suspend
	
	pCLKPWR->USB_PHYPWR |= (0xf<<0);
	pCLKPWR->PWRCFG &= ~(1<<4);
#ifdef	EVT1
	pCLKPWR->USB_CLKCON &= ~(1<<31);		
#else
#endif
	pCLKPWR->INFORM0 = 0x2BED;	
	

	//pIOPort->MISCCR|=(1<<2); //Previous state at STOP(?) mode (???)

	//D[31:0] pull-up off. The data bus will not be float by the external bus holder.
	//If the pull-up resitsers are turned on,
	//there will be the leakage current through the pull-up resister
	//pIOPort->MISCCR=pIOPort->MISCCR|(3<<0);

	// In the evaluation board, Even though in sleep mode, the devices are all supplied the power.
//	pIOPort->MSLCON = (0<<11)|(0<<10)|(0<<9)|(0<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0);
//	pIOPort->DSC0 = (1<<31)|(3<<8)|(3<<0);
//	pIOPort->DSC1 = (3<<28)|(3<<26)|(3<24)|(3<<22)|(3<<20)|(3<<18);

    /* LCD Controller Disable               */
	CLRPORT32(&pIOPort->GPGDAT, 1 << 4);

	

}

void ConfigStopGPIO(void)
{

    volatile S3C2443_IOPORT_REG *pIOPort = (S3C2443_IOPORT_REG*)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
	
	
///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_OP1 IO
	// GPF[7:0], GPG[7:0], GPE[15:14], GPE[4:0]

	
//GPF
	pIOPort->GPFCON &=~(0xffff<<0);
	pIOPort->GPFCON |= ((0x1<<14)|(0x1<<12)|(0x1<<10)|(0x1<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x2<<0));
#ifdef		EVT1	
	pIOPort->EXTINT0 = (READEXTINT0(pIOPort->EXTINT0) & ~((1<<31) | (1<<27) | (1<<23) | (1<<19) | (1<<15) | (1<<11) | (1<<7) | (1<<3) ));
	pIOPort->EXTINT0 = (READEXTINT0(pIOPort->EXTINT0)  | ((1<<31) | (1<<27) | (1<<23) | (1<<19) | (0<<15) | (1<<11) | (1<<7) | (1<<3) )); //rEXTINT0[11] = PD_dis(Because of VBUS_DET)
#else	           
	pIOPort->GPFUDP &=~(0xffff<<0);
	pIOPort->GPFUDP |= ((0x2<<14)|(0x2<<12)|(0x2<<10)|(0x2<<8)|(0x1<<6)|(0x1<<4)|(0x2<<2)|(0x1<<0));
#endif
	pIOPort->GPFDAT &=~ (0xff<<0);
	pIOPort->GPFDAT |= ((0x0<<7)|(0x0<<6)|(0x0<<5)|(0x0<<4)|(0x0<<3)|(0x0<<2)|(0x0<<1)|(0x0<<0));
	
	//GPG
	pIOPort->GPGCON &=~(0xffff<<0);
	pIOPort->GPGCON |= ((0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x2<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
	           
	pIOPort->GPGUDP &=~(0xffff<<0);
#ifdef		__EVT1	
	pIOPort->EXTINT1 = (READEXTINT1(pIOPort->EXTINT1) | (0<<31) | (0<<27) | (0<<23) | (0<<19) | (1<<15) | (0<<11) | (0<<7)| (0<<0) );	
#else
	pIOPort->GPGUDP |= ((0x2<<14)|(0x2<<12)|(0x1<<10)|(0x1<<8)|(0x1<<6)|(0x1<<4)|(0x1<<2)|(0x1<<0));
#endif
	
	pIOPort->GPGDAT &=~ (0xff<<0);
	pIOPort->GPGDAT |= ((0x1<<7)|(0x0<<6)|(0x1<<5)|(0x1<<4)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
	
	//GPA
#ifdef		EVT1
	pIOPort->GPACDH = (READGPACDH(pIOPort->GPACDL,pIOPort->GPACDH) | (1<<16) | (1<<5));	//GPACDH[16] is exclusive use of nRSTOUT and '1' is PRESET
#else
	pIOPort->GPACON &=~(0x1<<21);
	pIOPort->GPACON |= ((0x0<<21));//Set GPA21 as Output(default : nRSTOUT)
	
	pIOPort->GPADAT &=~ (0x7<<21);//Clear GPA21~23 
	pIOPort->GPADAT |= ((0x1<<21));//Set GPA21(DAT) as '1'
#endif

	
	// DP0 / DN0
	pIOPort->MISCCR |= (1<<12); //Set USB port as suspend mode	

	
///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_OP2 IO
	// GPB[10:0], GPH[12:0], GPE[15:14], GPE[4:0]

	
	//GPB
	pIOPort->GPBCON &=~(0x3fffff<<0);
#ifdef	EVT1
	pIOPort->GPBCON |= ((0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x3<<0));
#else
	pIOPort->GPBCON |= ((0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x1<<6)|(0x1<<4)|(0x0<<2)|(0x1<<0));
#endif
	
	pIOPort->GPBUDP = (pIOPort->GPBUDP &=~(0x3fffff<<0));
#ifdef		EVT1											
	pIOPort->GPBUDP |= ((0x3<<20)|(0x2<<18)|(0x2<<16)|(0x2<<14)|(0x2<<12)|(0x2<<10)|(0x3<<8)|(0x3<<6)|(0x3<<4)|(0x0<<2)|(0x3<<0));
#else
	pIOPort->GPBUDP |= ((0x1<<20)|(0x1<<18)|(0x1<<16)|(0x1<<14)|(0x1<<12)|(0x1<<10)|(0x0<<8)|(0x2<<6)|(0x2<<4)|(0x1<<2)|(0x2<<0));          
#endif
	
	
	//GPE
	pIOPort->GPECON &=~((0xf<<28)|(0x3ff<<0));	
#ifdef		EVT1
	pIOPort->GPECON |= ((0x0<<30)|(0x0<<28)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
#else	
	pIOPort->GPECON |= ((0x0<<30)|(0x0<<28)|(0x1<<8)|(0x0<<6)|(0x1<<4)|(0x0<<2)|(0x0<<0));
#endif
	
	pIOPort->GPEUDP &=~((0xf<<28)|(0x3ff<<0));
#ifdef		EVT1
	pIOPort->GPEUDP |= ((0x0<<30)|(0x0<<28)|(0x0<<8)|(0x3<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));                
#else
	pIOPort->GPEUDP |= ((0x2<<30)|(0x2<<28)|(0x2<<8)|(0x1<<6)|(0x2<<4)|(0x1<<2)|(0x1<<0));          
#endif
	
	pIOPort->GPEDAT &=~ (0xffff<<0);
	pIOPort->GPEDAT |= ((0x1<<15)|(0x1<<14)|(0x1<<4)|(0x1<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
#ifdef		EVT1
#else
	pIOPort->GPEDAT = 0;
	//printf("rgPEcon=%08x, rgPEUDP=%08x, rGPeDAT=%08x\n", rGPECON,rGPEUDP,rGPEDAT);
#endif
	
	
	//GPG
	pIOPort->GPGCON &=~(0xffff<<16);
	pIOPort->GPGCON |= ((0x0<<30)|(0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16));
	
	pIOPort->GPGUDP &=~(0xffff<<16);
#ifdef		EVT1	
	pIOPort->GPGUDP |= ((0x2<<30)|(0x0<<28)|(0x3<<26)|(0x3<<24)|(0x0<<22)|(0x3<<20)|(0x3<<18)|(0x3<<16));
#else
	pIOPort->GPGUDP |= ((0x0<<30)|(0x1<<28)|(0x1<<26)|(0x1<<24)|(0x1<<22)|(0x2<<20)|(0x2<<18)|(0x1<<16));
#endif
	
	pIOPort->GPGDAT &=~ (0xff<<8);
	pIOPort->GPGDAT |= ((0x0<<15)|(0x0<<14)|(0x0<<13)|(0x0<<12)|(0x0<<11)|(0x0<<10)|(0x0<<9)|(0x0<<8));

	
	
	//GPH
	pIOPort->GPHCON &=~(0x3fffffff<<0);
#ifdef		EVT1
	pIOPort->GPHCON |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
#else
	pIOPort->GPHCON |= ((0x1<<28)|(0x0<<26)|(0x0<<24)|(0x1<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
#endif
	
	pIOPort->GPHUDP &=~(0x3fffffff<<0);
#ifdef		EVT1	
	pIOPort->GPHUDP |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x3<<20)|(0x0<<18)|(0x3<<16)|(0x3<<6)|(0x0<<4)|(0x3<<2)|(0x0<<0));
#else
	pIOPort->GPHUDP |= ((0x2<<28)|(0x1<<26)|(0x1<<24)|(0x2<<22)|(0x1<<20)|(0x2<<18)|(0x1<<16)|(0x1<<6)|(0x2<<4)|(0x1<<2)|(0x2<<0));
#endif	
	pIOPort->GPHDAT &=~ (0x7fff<<0);
	pIOPort->GPHDAT |= ((0x0<<14)|(0x1<<13)|(0x0<<12)|(0x1<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));

	

///////////////////////////////////////////////////////////////////////////////////////////
	// VDD_SD IO
	// GPE[13:5], GPL[14:0], GPJ[15:13]
	
	//GPE
	pIOPort->GPECON &=~(0x3ffff<<10);
	pIOPort->GPECON |= ((0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<14)|(0x0<<12)|(0x0<<10));//Set Input All
	
	pIOPort->GPEUDP &=~(0x3ffff<<10);
#ifdef		EVT1	
	pIOPort->GPEUDP |= ((0x0<<26)|(0x0<<24)|(0x0<<22)|(0x3<<20)|(0x3<<18)|(0x3<<16)|(0x3<<14)|(0x3<<12)|(0x0<<10));
#else
	pIOPort->GPEUDP |= ((0x1<<26)|(0x1<<24)|(0x1<<22)|(0x2<<20)|(0x2<<18)|(0x2<<16)\
	           |(0x2<<14)|(0x2<<12)|(0x1<<10));
#endif
	
	pIOPort->GPEDAT &=~ (0x1ff<<5);
	pIOPort->GPEDAT |= ((0x0<<13)|(0x0<<12)|(0x0<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x0<<7)|(0x1<<6)|(0x1<<5));

⌨️ 快捷键说明

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