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

📄 target.c

📁 基于ARM7的ucos-ii移动收发通信编程ADS开发源码
💻 C
📖 第 1 页 / 共 2 页
字号:

	// 打开UART0中断(使用向量中断) 									
	VICVectAddr4 = (uint32)Uart0_Handler;		
    VICVectCntl4 = (0x20 | 0x06);
    VICIntEnable = 1 << 6;
	// 打开UART1中断(使用向量中断)
    VICVectAddr5 = (uint32)Uart1_Handler;		
    VICVectCntl5 = (0x20 | 0x07);
    VICIntEnable = 1 << 7;
    
    VICVectAddr6 = (uint32)I2c_Handler;			
    VICVectCntl6 = (0x20 | 0x09);  
    VICIntEnable = 1 << 9;
}
/*********************************************************************************************************
** 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:				cuijingjun
** Created Date:			2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetInit(void)
{
    OS_ENTER_CRITICAL();
    srand((uint32) TargetInit);
    VICInit();
    Timer0Init();
    OS_EXIT_CRITICAL();
} 
/*********************************************************************************************************
** Function name:			TargetResetInit
**
** Descriptions:			Initialize the target 
**
** input parameters:		None
** Returned value:			None
**         
** Used global variables:	None
** Calling modules:			None
**
** Created by:				cuijingjun
** Created Date:			2007/08/15
**-------------------------------------------------------------------------------------------------------
** 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

/* 设置系统各部分时钟 */
/* 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;

/* 设置存储器加速模块 */
/* Set memory accelerater module*/
    MAMCR = 0;
#if Fcclk < 20000000
    MAMTIM = 1;
#else
#if Fcclk < 40000000
    MAMTIM = 2;
#else
    MAMTIM = 3;
#endif
#endif
    MAMCR = 2; 
    // 初始化端口  
     
    PINSEL0 = 0x00050055;
    PINSEL1 = 0x15400000;
    PINSEL2 = PINSEL2 & (~0x0B);
    // initialize VIC
    VICIntEnClr = 0xffffffff;
    VICVectAddr = 0;
    VICIntSelect = 0;
    T0IR = 0xffffffff;
    T0TCR = 0X02;
}
void rdAddr(uint8 *addr)
{
	uint8 swA=0, swB=0, cnt=0;
	//读取SWa
	if(0x00==(IO2PIN&(1<<19)))
	{
		swA |= 0x01;
	}
	if(0x00==(IO2PIN&(1<<18)))
	{
		swA |= 0x02;
	}
	if(0x00==(IO2PIN&(1<<17)))
	{
		swA |= 0x04;
	}
	if(0x00==(IO2PIN&(1<<16)))
	{
		swA |= 0x08;
	}
	//读取SWb
	if(0x00==(IO2PIN&(1<<25)))
	{
		swB |= 0x01;
	}
	if(0x00==(IO2PIN&(1<<24)))
	{
		swB |= 0x02;
	}
	if(0x00==(IO2PIN&(1<<23)))
	{
		swB |= 0x04;
	}
	if(0x00==(IO0PIN&(1<<24)))
	{
		swB |= 0x08;
	}
	if(0x00==(IO1PIN&(1<<19)))
	{
		swB |= 0x10;
	}
	if(0x00==(IO0PIN&(1<<23)))
	{
		swB |= 0x20;
	}
	if(0x00==(IO0PIN&(1<<22)))
	{
		swB |= 0x40;
	}
	if(0x00==(IO0PIN&(1<<21)))
	{
		swB |= 0x80;
	}
	
	if(0x01==swA || 0x02==swA || 0x04==swA || 0x08==swA)
	{
		for(cnt=0; cnt<8; cnt++)
		{
			if(swA&(1<<cnt))
			{
				*addr = cnt+1;
			}
		}
	}
	if(0x01==swB || 0x02==swB || 0x04==swB || 0x08==swB
	   || 0x10==swB || 0x20==swB || 0x40==swB || 0x80==swB)
	{
		for(cnt=0; cnt<8; cnt++)
		{
			if(swB&(1<<cnt))
			{
				*(addr+1) = cnt+1;
			}
		}
	}
}
/*********************************************************************************************************
**                  以下为一些与系统相关的库函数的实现
**                  具体作用请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 + -