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

📄 uartdown.c

📁 S3C2443的USB 的驱动程序
💻 C
字号:
/**
* Project Name : S3C2443 verification project
*
* Copyright 2006 by Samsung Electronics, Inc.
* All rights reserved.
*
* Project Description :
* This software is only for verifying functions of the S3C2443. 
* Anybody can use this code without our permission.
*/

/**
* File Name    : 2443mon_s.cpp
* Description  : S3C2443 UART monitor main code
* Author       : GOM
* Dept         : Mobile solution, AP
* Created Date : 2005.05.29
* Version      : 0.0
* History
*   R0.0 (2005.05.29): GOM draft
*/


#include "System.h"
#include "uartdown.h"


#define	UART_OS_START_ADDR_OFFSET 	(0x00000000)
#define UART_DOWNLOAD_ADDRESS 			(_RAM_STARTADDRESS+UART_OS_START_ADDR_OFFSET)


void (*uart_restart)(void)=(void (*)(void))0x0;
void (*uart_run)(void)=(void (*)(void))UART_DOWNLOAD_ADDRESS;

volatile unsigned char *uart_downPt;
volatile unsigned int uart_err=0;


void __irq Uart0_RxInt(void)
{
	rSUBSRCPND = BIT_SUB_RXD0;
    	rSUBSRCPND;
    
    	ClearPending(BIT_UART0);
	*uart_downPt++=RdURXH0();//RdURXH0
}

void __irq Uart1_RxInt(void)
{

 	rSUBSRCPND = BIT_SUB_RXD1;
    	rSUBSRCPND;
    
    	ClearPending(BIT_UART1);//
	*uart_downPt++=RdURXH1();
}

void __irq Uerror(void)
{
	rSUBSRCPND = BIT_SUB_ERR0;
    	rSUBSRCPND;

    	ClearPending(BIT_UART0);
    	uart_err++;
}


void Uart_Isr_Init(void)
{
	
    	rINTMOD=0x0;    //All=IRQ mode
    	
	// Uart 0
	rINTSUBMSK=~(BIT_SUB_RXD0);
	rINTMSK=~(BIT_UART0);
    	pISR_UART0=(unsigned)Uart0_RxInt;
	
	// Uart 1
    	rINTSUBMSK=~(BIT_SUB_RXD1);
    	rINTMSK=~(BIT_UART1);	
    	pISR_UART1=(unsigned)Uart1_RxInt;
}												  


void UartMON( void)
{
	int i,j;
	int memError=0;
	unsigned int fileSize;
	unsigned short int checkSum=0,dnCS;

	Init_LED();
	Led_Display(0xf);

	MMU_EnableICache();
	Led_Display(0x1);

	//pISR_SWI=(_ISR_STARTADDRESS+0xf0);	  //for pSOS

	Uart_Isr_Init();

	// FCLK,HCLK output
	//rMISCCR = (rMISCCR & ~(7<<8) & ~(7<<4)) | (3<<8) | (2<<4);	// CLKSEL0=FCLK, CLKSEL1=HCLK
	//rGPHCON = (rGPHCON & ~(0xf<<26)) | (2<<28) | (2<<26);		// CLKOUT1, CLKOUT0

	/*******************************/
	/*          		Banner      	            */
	/*******************************/

	printf("\n\n+-----------------------------------------------------+\n");
	printf("| S3C2443X Serial Downloader ver R0.0 2006 MAY. |\n");
	printf("+-----------------------------------------------------+\n");
	//   	printf("FCLK=%dMHz,COM:115.2kbps,8Bit,NP,UART1 <n+6>(4)+(n)+CS(2)\n",ARMCLK/1000000);
	printf("DOWNADDR:%xh ISR_ADDR:%xh \n",UART_DOWNLOAD_ADDRESS,_ISR_STARTADDRESS);

	//	mpll_val = rMPLLCON;
	//	printf("MPLLVal [M:%xh,P:%xh,S:%xh]\n", (mpll_val&(0xff<<12))>>12,(mpll_val&(0x3f<<4))>>4,(mpll_val&0x3));
	//	printf("CLKDIVN:%xh\n", rCLKDIV0);
	SystemCLK(1);
	Console();

	/*******************************/
	/*      	    Memory test                  */
	/*******************************/
	printf("\nMemory Test(%xh-%xh):WR",	_RAM_STARTADDRESS,(_ISR_STARTADDRESS&0xfff0000));

	for(i=_RAM_STARTADDRESS;i<(_ISR_STARTADDRESS&0xfff0000);i+=4)
	{
		*((volatile unsigned *)i)=i;
	}

	printf("\b\bRD");

	for(i=_RAM_STARTADDRESS;i<(_ISR_STARTADDRESS&0xfff0000);i+=4)
	{
		j=*((volatile unsigned *)i);

		if(j!=i)
		{
			memError=1;
			//printf("0x%x=0x%x,",i,j);
		}
	}

	if(memError==0)
	printf("\b\bO.K.\n");
	else
	printf("\b\bFAIL\n");


	/*******************************/
	/*   	    Test program download   	     */
	/*******************************/

	printf("Waiting for Download [Addr : 0x30000000]\n");
	uart_downPt=(unsigned char *)UART_DOWNLOAD_ADDRESS;

	while(( (unsigned int)uart_downPt-UART_DOWNLOAD_ADDRESS )<4)
	{
		Led_Display(0x6);
		for(i=0;i<0x800000;i++);
		Led_Display(0x9);
		for(i=0;i<0x800000;i++);
	}

	printf("Downloadig size check!\n");

	fileSize=*((unsigned int *)(UART_DOWNLOAD_ADDRESS));
	//		fileSize=*((unsigned char *)(UART_DOWNLOAD_ADDRESS+0))+
	//		(*((unsigned char *)(UART_DOWNLOAD_ADDRESS+1))<<8)+
	//		(*((unsigned char *)(UART_DOWNLOAD_ADDRESS+2))<<16);//+
	//		(*((unsigned char *)(UART_DOWNLOAD_ADDRESS+3))<<24);

	printf("\nNow, Downloading[FILESIZE:%7d bytes]\n",fileSize);

	j=1000;

	while(((int)uart_downPt-UART_DOWNLOAD_ADDRESS)<fileSize)
	{
		 if( ((int)uart_downPt-UART_DOWNLOAD_ADDRESS)>=j)
		{
	    	j+=1000;
			printf(".");
		}
	}

	/*******************************/
	/*    	 Verify check sum      */
	/*******************************/

	for(i=4;i<(fileSize-2);i++)
	{
		checkSum+=*((unsigned char *)(i+UART_DOWNLOAD_ADDRESS));
	}

	dnCS=*((unsigned char *)(UART_DOWNLOAD_ADDRESS+fileSize-2))+
	(*( (unsigned char *)(UART_DOWNLOAD_ADDRESS+fileSize-1) )<<8);

	if(checkSum!=dnCS)
	{
	printf("Checksum Error!!! MEM:%x DN:%x\n",checkSum,dnCS);
	uart_restart();
	}

	printf("\nDownload O.K.\n");

	//Move the program from 0x30000004~ to 0x30000000~(to remove header and checksum)
	for(i=4;i<(fileSize-2);i++) 
	{
	*((unsigned char *)(i+UART_DOWNLOAD_ADDRESS-4))=*((unsigned char *)(i+UART_DOWNLOAD_ADDRESS));
	}

	uart_run();
}

⌨️ 快捷键说明

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