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

📄 target.c

📁 LPC2300 ucos工程模板,直接导入ADS
💻 C
📖 第 1 页 / 共 2 页
字号:
** input parameters:		None
** Returned value:			None
**         
** Used global variables:	None
** Calling modules:			None
**
** Created by:				Chenmingji
** Created Date:			2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:				李仲生
** Modified date:			2007/01/16
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetResetInit(void)
{
#ifdef __DEBUG_RAM    
    MEMMAP = 0x2;                  	 	// remap
#endif

#ifdef __DEBUG_FLASH    
    MEMMAP = 0x1;                   	// remap
#endif

#ifdef __IN_CHIP    
    MEMMAP = 0x1;                   	// remap
#endif
    
	SCS = (SCS & 0x04)|0x20;                // Enable the main OSC,,1MHz~20MHz       							      
    while((SCS & 0x40) == 0 );			    // Wait until main OSC is usable 
 
	if ( PLLSTAT & (1 << 25) )				// if the PLL was connected
    {
		PLLCON  = 0x01;										
		PLLFEED = 0xAA;						// disconnect the PLL
		PLLFEED = 0x55;	
		PLLCON  = 0x00;										
		PLLFEED = 0xAA;						// disable the PLL
		PLLFEED = 0x55;			
    }  
	else if ( PLLSTAT & (1 << 24) )			// if the PLL was enabled 		                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 如果PLL已被使能,则先禁止PLL
    {
		PLLCON  = 0x00;										
		PLLFEED = 0xAA;						// disable the PLL
		PLLFEED = 0x55;
    }
        
    CLKSRCSEL = 0x01;						// select main OSC as the PLL clock source 
	PLLCON = 1;								// Enable but disconnect the PLL
    PLLCFG  = (((PLL_NValue-1) << 16)|(PLL_MValue-1) );  	// set the PLLCFG		
    PLLFEED = 0xAA;							// Enable PLL
    PLLFEED = 0x55;	
    while (((PLLSTAT & (1 << 24)) == 0));	// Wait until the PLL is usable
    
    CCLKCFG = (Fcco/Fcclk - 1);				// set the CCLKCFG
 	PLLCON = 3;								// connect the PLL 
    PLLFEED = 0xAA;
    PLLFEED = 0x55;							
	while (((PLLSTAT & (3 << 25))!= (3 << 25)));	// Wait until the PLL is connected and locked


#if USE_USB
    PCONP |= 0x80000000;				// Turn On the USB PCLK 
    USBCLKCFG = (Fcco/Fusbclk - 1);	     	
#endif

// Set system timers for each component 
#if (Fpclk / (Fcclk / 4)) == 1

    PCLKSEL0 = 0x00000000;				// PCLK is 1/4 CCLK 
    PCLKSEL1 = 0x00000000;

#else

    #if (Fpclk / (Fcclk / 4)) == 2

    PCLKSEL0 = 0xAAAAAAAA;				// PCLK is 1/2 CCLK 
    PCLKSEL1 = 0xAAAAAAAA;	 

    #else

    PCLKSEL0 = 0x55555555;				// PCLK is the same as CCLK 
    PCLKSEL1 = 0x55555555;	
    
    #endif 
#endif

/* Set memory accelerater module*/     
   MAMCR = 0;
#if Fcclk < 20000000
    MAMTIM = 1;
#else
    #if Fcclk < 40000000
    MAMTIM = 2;
    #else
    MAMTIM = 3;
    #endif
#endif

    MAMCR = 2;       
	/* Initialize VIC*/		
	VICIntEnClr = 0xffffffff;
    VICVectAddr = 0;
    VICIntSelect = 0;       
    /* Add your codes here */
    InitialiseUART0(115200);               //Initialize the uart0 
    return;
}

/*********************************************************************************************************
**                  以下为一些与系统相关的库函数的实现
**                  具体作用请ads的参考编译器与库函数手册
**                  用户可以根据自己的要求修改        
********************************************************************************************************/
/*********************************************************************************************************
**                  The implementations for some library functions
**                  For more details, please refer to the ADS compiler handbook and The library 
**					function manual
**                  User could change it as needed       
********************************************************************************************************/

#include "rt_sys.h"
#include "stdio.h"

#pragma import(__use_no_semihosting_swi)

int __rt_div0(int a)
{
    a = a;
    return 0;
}

int fputc(int ch,FILE *f)
{
    ch = ch;
    f = f;
    return 0;
}

int fgetc(FILE *f)
{
    f = f;
    return 0;
}

int _sys_close(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

int _sys_write(FILEHANDLE fh, const unsigned char * buf,
                      unsigned len, int mode)
{
    fh = fh;
    buf = buf;
    len =len;
    mode = mode;
    return 0;
}

int _sys_read(FILEHANDLE fh, unsigned char * buf,
                     unsigned len, int mode)
{
    fh = fh;
    buf = buf;
    len =len;
    mode = mode;
    
    return 0;
}

void _ttywrch(int ch)
{
    ch = ch;
}

int _sys_istty(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

int _sys_seek(FILEHANDLE fh, long pos)
{
    fh = fh;
    return 0;
}

int _sys_ensure(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

long _sys_flen(FILEHANDLE fh)
{
    fh = fh;
    return 0;
}

int _sys_tmpnam(char * name, int sig, unsigned maxlen)
{
    name = name;
    sig = sig;
    maxlen = maxlen;
    return 0;
}

void _sys_exit(int returncode)
{
    returncode = returncode;
}

char *_sys_command_string(char * cmd, int len)
{
    cmd = cmd;
    len = len;
    return 0;
}

/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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