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

📄 main.c

📁 smdk2416 wince source code/BSP
💻 C
📖 第 1 页 / 共 5 页
字号:
//
// 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.
//
//
//
// 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.
//

#include <windows.h>
#include <bsp.h>
#include <ethdbg.h>
#include <fmd.h>
#include "loader.h"
#include <display.h>
#include "DisplaySample_320_240.h"

// header files for whimory - hmseo-061028
#include <WMRTypes.h>
#include <VFLBuffer.h>
//#include <WMR.h>
#include <FTL.h>
#include <VFL.h>
#include <FIL.h>
#include <config.h>
#include <WMR_Utils.h>
//#include <WMR_Eboot.h>

// For USB Download function.
extern BOOL UbootReadData (DWORD cbData, LPBYTE pbData);
extern BOOL InitUSB ();

#ifdef _EBOOT_SLEEP_
BOOL InitPowerButton();
#endif

extern void Isr_Init();
// For USB Download function.
char *inet_ntoa(DWORD dwIP);
DWORD inet_addr( char *pszDottedD );
BOOL EbootInitEtherTransport (EDBG_ADDR *pEdbgAddr, LPDWORD pdwSubnetMask,
                              BOOL *pfJumpImg,
                              DWORD *pdwDHCPLeaseTime,
                              UCHAR VersionMajor, UCHAR VersionMinor,
                              char *szPlatformString, char *szDeviceName,
                              UCHAR CPUId, DWORD dwBootFlags);
BOOL EbootEtherReadData (DWORD cbData, LPBYTE pbData);
EDBG_OS_CONFIG_DATA *EbootWaitForHostConnect (EDBG_ADDR *pDevAddr, EDBG_ADDR *pHostAddr);

void	SaveEthernetAddress();

extern BOOL IsValidMBRSector();
extern BOOL CreateMBR();
// End   ***************************************


// Globals
//
DWORD			g_ImageType;
DWORD			g_dwMinImageStart;
MultiBINInfo		g_BINRegionInfo;
PBOOT_CFG		g_pBootCfg;
UCHAR			g_TOC[SECTOR_SIZE];
const PTOC 		g_pTOC = (PTOC)&g_TOC;
DWORD			g_dwImageStartBlock;
DWORD			g_dwTocEntry;
BOOL			g_bBootMediaExist = FALSE;
BOOL			g_bDownloadImage  = TRUE;
BOOL 			g_bWaitForConnect = TRUE;
BOOLEAN			g_bUSBDownload = FALSE;


EDBG_ADDR 		g_DeviceAddr; // NOTE: global used so it remains in scope throughout download process
                        // since eboot library code keeps a global pointer to the variable provided.


DWORD			wNUM_BLOCKS;

// External definitions.
//
extern const BYTE ScreenBitmap[];



/*
    @func   void | SpinForever | Halts execution (used in error conditions).
    @rdesc
    @comm
    @xref
*/
static void SpinForever(void)
{
    EdbgOutputDebugString("SpinForever...\r\n");

    while(1)
    {
        ;
    }
}


/*
    @func   void | main | Samsung bootloader C routine entry point.
    @rdesc  N/A.
    @comm
    @xref
*/

void MemoryTest_Function(void)
{
//	UINT32 startaddress;
	UINT32 addr;


	// 1. 0x30100000 ~ 0x33ffffff : 0x0 => clear with 0x00 write -> read verify
	for (addr = 0x30200000; addr <= 0x31200000 ; addr += 4)
	{
		*(UINT32 *)addr = 0x00;
	}
	for (addr = 0x30200000; addr <= 0x31200000 ; addr += 4)
	{
		if(*(UINT32 *)addr != 0x00)
		{
			//WriteDebugLED(0, 0x1);
			while(1);
		}
	}

    	//while(1);

}

#ifdef _EBOOT_SLEEP_
/*
    @func   void | Post_Wakeup | for control GPIO pads.
    @rdesc  N/A.
    @comm
    @xref
*/

void Post_Wakeup(void)
{
    volatile S3C2450_CLKPWR_REG *pCLKPWR = (S3C2450_CLKPWR_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE);    	
    pCLKPWR->RSTCON |= pCLKPWR->RSTCON;
}
#endif

void main(void)
{
    //MemoryTest_Function();

#ifdef _EBOOT_SLEEP_
    Post_Wakeup();
#endif

    BootloaderMain();

    // Should never get here.
    //
    SpinForever();
}


/*
    @func   void | InitDisplay | Initializes the LCD controller and displays a splashscreen image.
    @rdesc  N/A.
    @comm
    @xref
*/

void delayLoop(int count)
{
	volatile int j;
	for(j = 0; j < count; j++)  ;
}

void Write_LDI_LTV350(int address, int data)
{
	volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
	volatile S3C2450_LCD_REG    *s2450LCD = (S3C2450_LCD_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE);
 	UINT8	dev_id_code=0x1D;
        int     j;
	unsigned char DELAY=50;



	LCD_DEN_Hi; 		//	EN = High					CS high
	LCD_DCLK_Hi;							//	SCL High
	LCD_DSERI_Hi;							//	Data Low

	delayLoop(DELAY);

	LCD_DEN_Lo; 		//	EN = Low				CS Low
	delayLoop(DELAY);

	for (j = 5; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((dev_id_code >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}

	// RS = "0" : index data
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	// Write
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	for (j = 15; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((address >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}
	LCD_DSERI_Hi;
	delayLoop(DELAY);

	LCD_DEN_Hi; 				// EN = High
	delayLoop(DELAY*10);

	LCD_DEN_Lo; 		//	EN = Low				CS Low
	delayLoop(DELAY);

	for (j = 5; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((dev_id_code >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}

	// RS = "1" instruction data
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Hi;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	// Write
	LCD_DCLK_Lo;			// CLOCK = Low
	LCD_DSERI_Lo;
	delayLoop(DELAY);
	LCD_DCLK_Hi;			// CLOCK = High
	delayLoop(DELAY);

	for (j = 15; j >= 0; j--)
	{
		LCD_DCLK_Lo;							//	SCL Low

		if ((data >> j) & 0x0001)	// DATA HIGH or LOW
		{
			LCD_DSERI_Hi;
		}
		else
		{
			LCD_DSERI_Lo;
		}

		delayLoop(DELAY);

		LCD_DCLK_Hi;			// CLOCK = High
		delayLoop(DELAY);

	}

	LCD_DEN_Hi; 				// EN = High
	delayLoop(DELAY);

}

#if (BSP_TYPE == BSP_SMDK2450)
void InitLDI_LTE480(void)
{

    	volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);

	delayLoop(LCD_DELAY_1MS*10);
	
//	s2450IOP->GPFDAT |= (1<<2);	// PCI High	
	s2450IOP->GPBDAT |= (1<<1);	// PCI High	
		
}
#elif (BSP_TYPE == BSP_SMDK2443)
#endif
#define LTV350 (TRUE)

void InitLDI_LTV350(void)
{	
    	volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
    	volatile S3C2450_LCD_REG    *s2450LCD = (S3C2450_LCD_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE);	
		volatile S3C2450_CLKPWR_REG *s2450PWR = (S3C2450_CLKPWR_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE);    	
		
	// enable EPLL CLOCK for LCD
	s2450PWR->SCLKCON |= (1<<10);

	// LCD module reset
	s2450IOP->GPBDAT |= (1<<(LCD_nRESET));
	s2450IOP->GPBDAT &= ~(1<<(LCD_nRESET)); // goes to LOW

	// delay about 5ms
	delayLoop(LCD_DELAY_1MS*10);	
	s2450IOP->GPBDAT |= (1<<(LCD_nRESET));  // goes to HIGH

		
	//SET_CONFIG_PORT( spi1)
	s2450IOP->GPLCON &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));	
	s2450IOP->GPLCON |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));
	// pull-up pull-down disable
	s2450IOP->GPLUDP &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));	

	s2450IOP->GPLUDP |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));

	// delay about 5ms
	delayLoop(LCD_DELAY_1MS*10);	
		
	LCD_DEN_Hi;
	LCD_DCLK_Hi;
	LCD_DSERI_Hi;

	///////////////////////////////////////////////////////////////////
	// Init_Lcd_Function
	//////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x01,0x001d);
	Write_LDI_LTV350(0x02,0x0000);
    	Write_LDI_LTV350(0x03,0x0000);
    	Write_LDI_LTV350(0x04,0x0000);
    	Write_LDI_LTV350(0x05,0x50a3);
    	Write_LDI_LTV350(0x06,0x0000);
    	Write_LDI_LTV350(0x07,0x0000);
    	Write_LDI_LTV350(0x08,0x0000);
   	Write_LDI_LTV350(0x09,0x0000);
   	Write_LDI_LTV350(0x0a,0x0000);
   	Write_LDI_LTV350(0x10,0x0000);
   	Write_LDI_LTV350(0x11,0x0000);
   	Write_LDI_LTV350(0x12,0x0000);
   	Write_LDI_LTV350(0x13,0x0000);
   	Write_LDI_LTV350(0x14,0x0000);
   	Write_LDI_LTV350(0x15,0x0000);
   	Write_LDI_LTV350(0x16,0x0000);
   	Write_LDI_LTV350(0x17,0x0000);
   	Write_LDI_LTV350(0x18,0x0000);
   	Write_LDI_LTV350(0x19,0x0000);
#else
	Write_LDI_LTV350(0x09,0x0000);
#endif
	///////////////////////////////////////////////////////////////////
	// Power On Reset Display off State
	//////////////////////////////////////////////////////////////////
	//Write_LDI_LTV350(0x09,0x0000);

	// delay about 10ms
	delayLoop(LCD_DELAY_1MS*10);

	///////////////////////////////////////////////////////////////////
	// Power Setting Function 1
	//////////////////////////////////////////////////////////////////
#if LTV350
	Write_LDI_LTV350(0x09,0x4055);
	Write_LDI_LTV350(0x0a,0x0000);
#else
	Write_LDI_LTV350(0x09,0x4055);
	Write_LDI_LTV350(0x0a,0x2000);
#endif

	// delay about 10ms
	delayLoop(LCD_DELAY_1MS*10);

⌨️ 快捷键说明

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