?? target.c
字號(hào):
VICIntSelect = 0x00000000; /* 設(shè)置所有中斷分配為IRQ中斷 */
VICVectCntl2 = 0x20 | 0x0e; /* 分配外部中斷0到向量中斷0 */
VICVectAddr2 = (uint32)Eint0_Handler;/* 設(shè)置中斷服務(wù)程序地址 */
EXTINT = 0x01; /* 清除EINT0中斷標(biāo)志 */
VICIntEnable = 1 << 0x0e; /* 使能EINT0中斷 */
/* Slot 1分配給Uart0 */
VICVectAddr5= (uint32)Uart0_Handler;
VICVectCntl5= (0x20 | 0x06);
VICIntEnable = 1 << 6;
/* Slot 12分配給Uart1 */
VICVectAddr12 = (uint32)Uart1_Handler;
VICVectCntl12 = (0x20 | 0x07);
VICIntEnable = 1 << 7;
}
/*********************************************************************************************************
** Function name: TargetInit
**
** Descriptions: Initialize the target board; it is called in a necessary place, change it as
** needed
**
** 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:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetInit(void)
{
UARTMODE uart0_set,uart1_set;
uart0_set.baudrate = 57600;//Dtu_config.baudrate;//57600;//conf_get_bps(); // 串口0的波特率
uart0_set.datab = 8;//conf_get_data(); // 8位數(shù)據(jù)位
uart0_set.stopb = 1;//conf_get_stop(); // 1位停止位
uart0_set.parity = 0;//conf_get_crc(); // 無奇偶校驗(yàn)
uart1_set.baudrate = 38400; // 串口1的波特率
uart1_set.datab = 8; // 8位數(shù)據(jù)位
uart1_set.stopb = 1; // 1位停止位
uart1_set.parity = 0; // 無奇偶校驗(yàn)
OS_ENTER_CRITICAL();
VICInit();
EInt0Init();
Timer0Init();
/* 設(shè)置串行口 */
/* initialize UART*/
UART1_Ini((UARTMODE *)&uart1_set); // 初始化串口模式
UART0_Ini((UARTMODE *)&uart0_set); // 初始化串口模式
OS_EXIT_CRITICAL();
PINSEL2 = 0;
IO1DIR |= 0x01000000; //P1.24 MODEM RESET
IO1CLR |= 0x01000000;
//IO1DIR |= 0x00040000 ; //wdi
}
/*********************************************************************************************************
** Function name: TargetResetInit
**
** Descriptions: Initialize the target
**
** 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:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetResetInit(void)
{
#ifdef __DEBUG_RAM
MEMMAP = 0x2; //remap
#endif
#ifdef __DEBUG_FLASH
MEMMAP = 0x1; //remap
#endif
#ifdef __IN_CHIP
MEMMAP = 0x1; //remap
#endif
PINSEL0 = (PINSEL0 & 0xFFFF0000) | 0x05 | 0x50;
/* 設(shè)置系統(tǒng)各部分時(shí)鐘 */
/* Set system timers for each component */
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 = 0x55;
while((PLLSTAT & (1 << 10)) == 0);
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
/* 設(shè)置存儲(chǔ)器加速模塊 */
/* Set memory accelerater module*/
MAMCR = 0;
#if Fcclk < 20000000
MAMTIM = 1;
#else
#if Fcclk < 40000000
MAMTIM = 2;
#else
MAMTIM = 3;
#endif
#endif
MAMCR = 2;
/* 設(shè)置實(shí)時(shí)時(shí)鐘 */
/* initialize RTC*/
/*CCR = 1;
PREINT = Fpclk / 32768 - 1;
PREFRAC = Fpclk - (Fpclk / 32768) * 32768;
YEAR = 2003;
MONTH = 6;
DOM = 2;
/* initialize VIC*/
/*VICIntEnClr = 0xffffffff;
VICVectAddr = 0;
VICIntSelect = 0;
T0IR = 0xffffffff;
T0TCR = 0X02;
*/
}
/*********************************************************************************************************
** 以下為一些與系統(tǒng)相關(guān)的庫(kù)函數(shù)的實(shí)現(xiàn)
** 具體作用請(qǐng)ads的參考編譯器與庫(kù)函數(shù)手冊(cè)
** 用戶可以根據(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)
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
********************************************************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -