?? target.c
字號:
/******************************************************************************************************
** File name: target.c
** Descriptions: header file of the specific codes for LPC2200 target boards
** Every project should include a copy of this file, user may modify it as needed
********************************************************************************************************/
#define IN_TARGET
#include "config.h"
/*********************************************************************************************************
** Function name: IRQ_Exception
**
** Descriptions: interrupt exceptional handler , change it as needed
**
** input parameters: 無
** Returned value: 無
**
** Used global variables: 無
** Calling modules: 無
********************************************************************************************************/
void __irq IRQ_Exception(void)
{
while(1); // change it to your code 這一句替換為自己的代碼
}
/*********************************************************************************************************
** Function name: FIQ_Exception
**
** Descriptions: Fast interrupt exceptional handler , change it as needed
**
** input parameters: 無
** Returned value: 無
**
** Used global variables: 無
** Calling modules: 無
**
********************************************************************************************************/
void FIQ_Exception(void)
{
while(1); // change it to your code 這一句替換為自己的代碼
}
/*********************************************************************************************************
** Function name: TargetInit
**
** Descriptions: Initialize the target board; it is called in a necessary place, change it as
** needed
**
** input parameters: 無
** Returned value: 無
**
** Used global variables: 無
** Calling modules: 無
**
********************************************************************************************************/
void TargetInit(void)
{
/* 添加自己的代碼 */
/* Add your codes here */
}
/*********************************************************************************************************
** Function name: TargetResetInit
**
** Descriptions: Initialize the target board before running the main() function; User may
** change it as needed, but may not deleted it.
**
** input parameters: 無
** Returned value: 無
**
** Used global variables: 無
** Calling modules: 無
********************************************************************************************************/
void TargetResetInit(void)
{
#ifdef __DEBUG
MEMMAP = 0x3; //remap,對0X00000008讀數(shù)/取指就是從片外0x80000000單元進行操作
#endif
#ifdef __OUT_CHIP
MEMMAP = 0x3; //remap, 對0X00000008讀數(shù)/取指就是從片外0x80000000單元進行操作
#endif
#ifdef __IN_CHIP
MEMMAP = 0x1; //remap, 對0X00000008讀數(shù)/取指就是從片外0x00000000單元進行操作
#endif
/* 設置系統(tǒng)各部分時鐘 */
/* Set system timers for each component,其中cclk=M*Fosc,cclk=Fcco/(2*P),M、P分別是PLLCFG的低5位,高2位*/
PLLCON = 1;
#if (Fpclk / (Fcclk / 4)) == 1
VPBDIV = 0;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
VPBDIV = 2;
#endif
#if (Fpclk / (Fcclk / 4)) == 4
VPBDIV = 1;
#endif
#if (Fcco / Fcclk) == 2
PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
PLLFEED = 0xaa; /*必須將正確的饋送序列寫入PLLFEED,才能使PLLCON 和 PLLCFG更改生效*/
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0); /*判斷PLLSTAT的PLOCK位是否為0,是,則表明PLL為鎖定,否,則表明PLL鎖定到指定頻率*/
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
/* 設置存儲器加速模塊 */
/* Set memory accelerater module,由于LPC2210沒有片內(nèi)FLASH,MAM設置無效*/
MAMCR = 0;
#if Fcclk < 20000000
MAMTIM = 1; /*當改變MAM定時值時,必須先通過向MAMCR寫入0關閉MAM,然后將新值寫入MAMTIM。最后將需要的操作模式
的對應值(1或2)寫入MAMCR,再次打開MAM。*/
#else
#if Fcclk < 40000000
MAMTIM = 2;
#else
MAMTIM = 3;
#endif
#endif
MAMCR = 2;
/* 初始化VIC */
/* initialize VIC*/
VICIntEnClr = 0xffffffff; /*寫1清零VICIntEnable中斷使能寄存器中的對應位并禁止對應的中斷請求*/
VICVectAddr = 0; /*寫0將清零內(nèi)部中斷優(yōu)先級硬件當中對應的標志*/
VICIntSelect = 0; /*寫0,對應的中斷請求分配為IRQ*/
/* 添加自己的代碼 */
/* Add your codes here */
}
/*********************************************************************************************************
** 以下為一些與系統(tǒng)相關的庫函數(shù)的實現(xiàn)
** 具體作用請參考ads的編譯器與庫函數(shù)手冊
** 用戶可以根據(jù)自己的要求修改
********************************************************************************************************/
/*********************************************************************************************************
** 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)
#pragma import(__use_two_region_memory)
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 + -