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

📄 power.c

📁 SMDK2416_BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
	pIOPort->GPJDAT |= ((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;
	#ifdef		__CHK2443
	pIOPort->GPMCON &=~((0x3<<2) | (0x3<<0));
	pIOPort->GPMUDP &=~((0x3<<4) |(0x3<<2) | (0x3<<0));
	pIOPort->GPMUDP |= ((0x3<<4) | (0x3<<2) | (0x3<<0));
	#endif

///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_SMOP : sleep wakeup iteration fail or not?
	//rMSLCON = 0x0;
	#ifdef		__CHK2443	
	//rDATAPDEN &=~((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3)|(0x1<<4)|(0x1<<5)); // reset value = 0x3f; --> 0x30 = 2uA
	//rDATAPDEN = (0x3<<4);
	#else
	pIOPort->GPKUDP &=~((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3)|(0x1<<4)|(0x1<<5)); // reset value = 0x3f; --> 0x30 = 2uA
	pIOPort->GPKUDP |= (0x3<<4);
	#endif

}
#if 0
void ConfigStopGPIO(void)
{

    volatile S3C2450_IOPORT_REG *pIOPort = (S3C2450_IOPORT_REG*)OALPAtoVA(S3C2450_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));


	//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)

	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 &=~((0x0<<14)|(0x0<<12)|(0x3<<10)|(0x3<<8)|(0x3<<6)|(0x3<<4)|(0x3<<2)|(0x3<<0));
	pIOPort->GPGCON |= ((0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x2<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
	           


//	pIOPort->EXTINT1 = (READEXTINT1(pIOPort->EXTINT1) | (0<<31) | (0<<27) | (0<<23) | (0<<19) | (1<<15) | (0<<11) | (0<<7)| (0<<3) );	
	
	pIOPort->GPGDAT &=~ ((0x0<<7)|(0x0<<6)|(0x1<<5)|(0x1<<4)|(0x1<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
	pIOPort->GPGDAT |= ((0x1<<7)|(0x1<<6)|(0x1<<5)|(0x1<<4)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
	
	//pIOPort->GPACDH = (READGPACDH(pIOPort->GPACDL,pIOPort->GPACDH) | (1<<16) | (1<<5));	//GPACDH[16] is exclusive use of nRSTOUT and '1' is PRESET

	
	// 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 &= ~((0x3<<20)|(0x3<<18)|(0x3<<16)|(0x3<<14)|(0x3<<12)|(0x3<<10)|(0x3<<8)|(0x3<<6)|(0x0<<4)|(0x3<<2)|(0x3<<0));

	pIOPort->GPBCON |= ((0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x1<<4)|(0x0<<2)|(0x3<<0));

	
	pIOPort->GPBUDP &= ~((0x3<<20)|(0x3<<18)|(0x3<<16)|(0x3<<14)|(0x3<<12)|(0x3<<10)|(0x3<<8)|(0x3<<6)|(0x0<<4)|(0x3<<2)|(0x3<<0));

	pIOPort->GPBUDP |= ((0x3<<20)|(0x2<<18)|(0x2<<16)|(0x2<<14)|(0x2<<12)|(0x2<<10)|(0x3<<8)|(0x3<<6)|(0x3<<4)|(0x0<<2)|(0x3<<0));

	
	
	//GPE
	pIOPort->GPECON &=~((0xf<<28)|(0x3ff<<0));	

	pIOPort->GPECON |= ((0x0<<30)|(0x0<<28)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));

	pIOPort->GPEUDP &=~((0xf<<28)|(0x3ff<<0));

	pIOPort->GPEUDP |= ((0x0<<30)|(0x0<<28)|(0x0<<8)|(0x3<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));                

	
	pIOPort->GPEDAT &=~ (0xffff<<0);
	pIOPort->GPEDAT |= ((0x1<<15)|(0x1<<14)|(0x1<<4)|(0x1<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));

	
	
	//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);

	pIOPort->GPGUDP |= ((0x2<<30)|(0x0<<28)|(0x3<<26)|(0x3<<24)|(0x0<<22)|(0x3<<20)|(0x3<<18)|(0x3<<16));

	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);

	pIOPort->GPHCON |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));

	pIOPort->GPHUDP &=~(0x3fffffff<<0);

	pIOPort->GPHUDP |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x3<<20)|(0x0<<18)|(0x3<<16)|(0x3<<6)|(0x0<<4)|(0x3<<2)|(0x0<<0));

	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);

	pIOPort->GPEUDP |= ((0x0<<26)|(0x0<<24)|(0x0<<22)|(0x3<<20)|(0x3<<18)|(0x3<<16)|(0x3<<14)|(0x3<<12)|(0x0<<10));

	
	pIOPort->GPEDAT &=~ (0x1ff<<5);
	pIOPort->GPEDAT |= ((0x0<<13)|(0x0<<12)|(0x0<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x0<<7)|(0x1<<6)|(0x1<<5));

	
	//GPL
	pIOPort->GPLCON &=~(0x3fffffff<<0);
	pIOPort->GPLCON |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)|(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
	pIOPort->GPLUDP &=~(0x3fffffff<<0);

	pIOPort->GPLUDP |= ((0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x3<<16)|(0x3<<14)|(0x3<<12)|(0x3<<10)|(0x3<<8)|(0x3<<6)|(0x3<<4)|(0x3<<2)|(0x3<<0));

	pIOPort->GPLDAT &=~ (0x1fff<<0);
	pIOPort->GPLDAT |= ((0x0<<14)|(0x0<<13)|(0x0<<12)|(0x0<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x1<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));
	
	//GPJ
	pIOPort->GPJCON &=~(0x3f<<26);
	pIOPort->GPJCON |= ((0x0<<30)|(0x0<<28)|(0x0<<26));
		
	pIOPort->GPJUDP &=~(0x3f<<26);

	pIOPort->GPJUDP |= ((0x0<<30)|(0x0<<28)|(0x0<<26));

	
	pIOPort->GPJDAT &=~ (0x7<<13);
	pIOPort->GPJDAT |= ((0x1<<15)|(0x1<<14)|(0x1<<13));
	




///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_LCD IO
	// GPC[15:0], GPD[15:0]
	
	//GPC
	pIOPort->GPCCON &=~(0xffffffff<<0);
	pIOPort->GPCCON |= ((0x0<<30)|(0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)\
	           |(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
	
	pIOPort->GPCUDP &=~(0xffffffff<<0);

	pIOPort->GPCUDP |= ((0x2<<30)|(0x2<<28)|(0x2<<26)|(0x2<<24)|(0x2<<22)|(0x2<<20)|(0x2<<18)|(0x2<<16)
	           |(0x2<<14)|(0x2<<12)|(0x2<<10)|(0x2<<8)|(0x2<<6)|(0x2<<4)|(0x2<<2)|(0x2<<0));

	
	pIOPort->GPCDAT &=~ (0x1fff<<0);
	pIOPort->GPCDAT |= ((0x0<<14)|(0x1<<13)|(0x0<<12)|(0x1<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));

	//GPD
	pIOPort->GPDCON &=~(0xffffffff<<0);
	pIOPort->GPDCON |= ((0x0<<30)|(0x0<<28)|(0x0<<26)|(0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)\
	           |(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));	           
	
	           
	pIOPort->GPDUDP &=~(0xffffffff<<0);

	pIOPort->GPDUDP |= ((0x2<<30)|(0x2<<28)|(0x2<<26)|(0x2<<24)|(0x2<<22)|(0x2<<20)|(0x2<<18)|(0x2<<16)\
	           |(0x2<<14)|(0x2<<12)|(0x2<<10)|(0x2<<8)|(0x2<<6)|(0x2<<4)|(0x2<<2)|(0x2<<0));

	
	pIOPort->GPDDAT &=~ (0xffff<<0);
	pIOPort->GPDDAT |= ((0x0<<14)|(0x1<<13)|(0x0<<12)|(0x1<<11)|(0x0<<10)|(0x1<<9)|(0x1<<8)|(0x0<<3)|(0x1<<2)|(0x1<<1)|(0x1<<0));


///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_CAM IO
	// GPJ[15:0],
	
	//GPJ
	pIOPort->GPJCON &=~(0x3ffffff<<0);
	pIOPort->GPJCON |= ((0x0<<24)|(0x0<<22)|(0x0<<20)|(0x0<<18)|(0x0<<16)\
	           |(0x0<<14)|(0x0<<12)|(0x0<<10)|(0x0<<8)|(0x0<<6)|(0x0<<4)|(0x0<<2)|(0x0<<0));
	           
	pIOPort->GPJUDP &=~(0x3ffffff<<0);

	pIOPort->GPJUDP |= ((0x2<<24)|(0x2<<22)|(0x2<<20)|(0x2<<18)|(0x2<<16)\
	           |(0x2<<14)|(0x2<<12)|(0x2<<10)|(0x2<<8)|(0x2<<6)|(0x2<<4)|(0x2<<2)|(0x2<<0));

	
	pIOPort->GPJDAT &=~ (0x1fff<<0);
	pIOPort->GPJDAT |= ((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
	pIOPort->MSLCON = 0x0;

///////////////////////////////////////////////////////////////////////////////////////////	
	// VDD_SMOP : sleep wakeup iteration fail or not?
	pIOPort->MSLCON = 0x0;

	pIOPort->DATAPDEN &=~((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3)|(0x1<<4)|(0x1<<5)); // reset value = 0x3f; --> 0x30 = 2uA
	pIOPort->DATAPDEN = (0x3<<4);

}
#endif

void BSPPowerOn()
{
    volatile S3C2450_IOPORT_REG *pIOPort = (S3C2450_IOPORT_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
    volatile S3C2450_LCD_REG *pLCD = (S3C2450_LCD_REG*)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE);
    volatile S3C2450_CLKPWR_REG *pCLKPWR = (S3C2450_CLKPWR_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE);
	volatile BSP_ARGS *pBspArgs = (BSP_ARGS*)OALPAtoVA(IMAGE_SHARE_ARGS_PA_START, FALSE);
	OEMInitDebugSerial();

	InitTimer();			// consume 2us
	//OALTimerInit(RESCHED_PERIOD, (OEM_COUNT_1MS), 0);
	//
#if (BSP_TYPE == BSP_SMDK2443)
	InitLDI_LTV350();
#elif (BSP_TYPE == BSP_SMDK2450)
	InitLDI_LTE480();
#endif
 
	// USB2.0 and PHY power
	pIOPort->MISCCR&=~(0x1<<12); //USB port = suspend
	//pCLKPWR->USB_PHYPWR |= (0xf<<0);
	pCLKPWR->PWRCFG |= (0x1<<4);
	//pIOPort->GSTATUS2 = pIOPort->GSTATUS2;

    //pIOPort->MISCCR &= ~(1<<12); //USB port0 = normal mode
    //pIOPort->MISCCR &= ~(1<<13); //USB port1 = normal mode

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

}

#ifdef VARTICK
void	InitTimer()
{
	S3C2450_PWM_REG *pPWMRegs = (S3C2450_PWM_REG*)OALPAtoUA(S3C2450_BASE_REG_PA_PWM);
    UINT32 countsPerSysTick;
    UINT32 tcon;
    
    // Validate Input parameters
    countsPerSysTick = RESCHED_PERIOD * OEM_COUNT_1MS;    
    // Set prescaler 1 to 1 
    //OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) & ~0x0000FF00);
    //OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) | (250-1) <<8);		// charlie, Timer4 scale value
    
     // Set prescaler 1 to 1 
    OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) & ~0x0000FF00);
    OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) | PRESCALER <<8);
    
    // Select MUX input 1/2
    //OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) & ~(0xF << 16));
    //OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (2 << 16));	// charlie, Timer4 Division    
    
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) & ~(0xF << 16));
#if( SYS_TIMER_DIVIDER == D2 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_2 << 16));
#elif ( SYS_TIMER_DIVIDER == D4 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_4 << 16));
#elif ( SYS_TIMER_DIVIDER == D8 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_8 << 16));
#elif ( SYS_TIMER_DIVIDER == D16 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_16 << 16));
#endif

    // Set timer register
    OUTREG32(&pPWMRegs->TCNTB4, countsPerSysTick);

    // Start timer in auto reload mode
    tcon = INREG32(&pPWMRegs->TCON) & ~(0x0F << 20);
    OUTREG32(&pPWMRegs->TCON, tcon | (0x2 << 20) );
    OUTREG32(&pPWMRegs->TCON, tcon | (0x1 << 20) );	
}
#else 
void	InitTimer()
{
	S3C2450_PWM_REG *pPWMRegs = (S3C2450_PWM_REG*)OALPAtoUA(S3C2450_BASE_REG_PA_PWM);
    UINT32 countsPerSysTick;
    UINT32 tcon;
    
    // Validate Input parameters
    countsPerSysTick = RESCHED_PERIOD * OEM_COUNT_1MS;    
    // Set prescaler 1 to 1 
    //OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) & ~0x0000FF00);
    //OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) | (250-1) <<8);		// charlie, Timer4 scale value
    
     // Set prescaler 1 to 1 
    OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) & ~0x0000FF00);
    OUTREG32(&pPWMRegs->TCFG0, INREG32(&pPWMRegs->TCFG0) | PRESCALER <<8);
    
    // Select MUX input 1/2
    //OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) & ~(0xF << 16));
    //OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (2 << 16));	// charlie, Timer4 Division    
    
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) & ~(0xF << 16));
#if( SYS_TIMER_DIVIDER == D2 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_2 << 16));
#elif ( SYS_TIMER_DIVIDER == D4 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_4 << 16));
#elif ( SYS_TIMER_DIVIDER == D8 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_8 << 16));
#elif ( SYS_TIMER_DIVIDER == D16 )
    OUTREG32(&pPWMRegs->TCFG1, INREG32(&pPWMRegs->TCFG1) | (D1_16 << 16));
#endif

    // Set timer register
    OUTREG32(&pPWMRegs->TCNTB4, countsPerSysTick);

    // Start timer in auto reload mode
    tcon = INREG32(&pPWMRegs->TCON) & ~(0x0F << 20);
    OUTREG32(&pPWMRegs->TCON, tcon | (0x2 << 20) );
    OUTREG32(&pPWMRegs->TCON, tcon | (0x5 << 20) );	
}

#endif

⌨️ 快捷键说明

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