arm9.rar

源代码在线查看: target.c

软件大小: 5914 K
上传用户: tiantianyuehui
关键词: arm
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include "target.h"
				#include "ucos_ii.h"               /* uC/OS interface */
				
				extern OS_EVENT *Key_Mbox;
				extern OS_EVENT *OK_Mbox;
				
				//extern void LedSet(U32 led);
				/********************************************************************************************************
				 * ARMTargetInit																						*
				 *																										*
				 * Description: This function initialize an ARM Target board											*
				 *																										*
				 * Argument   : none    																				*
				 ********************************************************************************************************/
				void ARMTargetInit(void) 
				{
					
					
				//	Port_Init();					//初始化端口
					
					Delay( 200 ) ;		//delay some time
					LedSet( 0x0f );		//LED全亮
					Delay( 500 ) ;		//delay some time
					LedSet( 0x00 );		//LED全亮
				
					ARMInitInterrupts();			//初始化中断,设置中断服务程序
					
					Delay(0);						//调整延时
				}
				
				
				/********************************************************************************************************
				 * ARMTargetStart																						*
				 *																										*
				 * Description: This function start the ARM target running												*
				 *																										*
				 * Argument   : none																					*
				 ********************************************************************************************************/
				void ARMTargetStart(void) {
					
					ARMInitTimers();				//配置时钟0相关寄存器
					//ARMInstallSystemTimer();		//时钟0中断使能
				}
				
				/********************************************************************************************************
				 * 中断初始化                   																		*
				 ********************************************************************************************************/
				void ARMInitInterrupts(void)
				{
					// Non-vectored,IRQ disable,FIQ disable    
				//	rINTCON = 0x0 ;	  
				
					// All=IRQ mode
					rINTMOD = 0x0 ;	  
				
					// All interrupt is masked.
				//	rINTMSK = BIT_GLOBAL;	  
				
					//set interrupt vector routine
				//	pISR_RESET					//reserved
					pISR_UNDEF = (unsigned) DebugUNDEF;
					pISR_SWI = (unsigned) DebugSWI;
					pISR_PABORT = (unsigned) DebugPABORT;
					pISR_DABORT = (unsigned) DebugDABORT;
				//	pISR_RESERVED = (unsigned) BreakPoint;		//not used
				//	pISR_IRQ = (unsigned) 0;			//reserved
					pISR_FIQ = (unsigned) DebugFIQ;
					
					pISR_ADC= (unsigned) BreakPoint;
					pISR_RTC= (unsigned) BreakPoint;
				//	pISR_UTXD1= (unsigned) BreakPoint;
				//	pISR_UTXD0= (unsigned) BreakPoint;
				/*	pISR_SIO= (unsigned) BreakPoint;
					pISR_IIC= (unsigned) BreakPoint;
					pISR_URXD1= (unsigned) BreakPoint;
					pISR_URXD0= (unsigned) BreakPoint;
					pISR_TIMER5= (unsigned) BreakPoint;
					pISR_TIMER4= (unsigned) BreakPoint;
					pISR_TIMER3= (unsigned) BreakPoint;
					pISR_TIMER2= (unsigned) BreakPoint;
					pISR_TIMER1= (unsigned) BreakPoint;
					pISR_TIMER0= (unsigned) BreakPoint;
					pISR_UERR01= (unsigned) BreakPoint;
					pISR_WDT= (unsigned) BreakPoint;
					pISR_BDMA1= (unsigned) BreakPoint;
					pISR_BDMA0= (unsigned) BreakPoint;
					pISR_ZDMA1= (unsigned) BreakPoint;
					pISR_ZDMA0= (unsigned) BreakPoint;
					pISR_TICK= (unsigned) BreakPoint;
					//pISR_EINT4567= (unsigned) OSEINT4567ISR;
					pISR_EINT4567=(unsigned)BreakPoint;
					pISR_EINT3= (unsigned) BreakPoint;
					pISR_EINT2= (unsigned) BreakPoint;
					pISR_EINT1= (unsigned) BreakPoint;
					pISR_EINT0= (unsigned) BreakPoint;
				
					pISR_TIMER0= (unsigned) OSTickISR;
				*/	
					pISR_TIMER0= (unsigned) OSTickISR;
				}
				
				//*******************************************************************************************************
				int ARMRequestSystemTimer(void *tick, const unsigned char *str) 
				{
					return 1;
				}
				
				/********************************************************************************************************
				 * Initialize timer that is used OS																		*
				 ********************************************************************************************************/
				void ARMInitTimers(void)
				{
					//dead zone=0, pre0= 150
					rTCFG0= 0x00000095;
					//all interrupt, mux0= 1/16
					rTCFG1= 0x00000003;
				
					//set T0 count
					rTCNTB0= _CLOCK;
				
					//update T0
					rTCON= 0x00000002;
				}
				
				/********************************************************************************************************
				 * start system timer0																					*
				 ********************************************************************************************************/
				void ARMStartTimer(void)
				{
					rTCON = 0x9;		//autoreload and start
				}
				
				/********************************************************************************************************
				 * enable the interrupt																					*
				 ********************************************************************************************************/
				void ARMInstallSystemTimer(void)
				{
					
					EnableIrq(BIT_TIMER0);	//Default value=0x7ffffff
				}
				
				//*******************************************************************************************************
				void BreakPoint(void)
				{
					printf("Enter BreakPoint");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				
				//*******************************************************************************************************
				void DebugUNDEF(void)
				{
					printf("Enter DebugUNDEF");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				
				//*******************************************************************************************************
				void DebugSWI(void)
				{
					printf("Enter DebugSWI");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				
				//*******************************************************************************************************
				void DebugPABORT(void)
				{
					printf("Enter DebugPABORT");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				
				//*******************************************************************************************************
				void DebugDABORT(void)
				{
					printf("Enter DebugDABORT");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				
				//*******************************************************************************************************
				void DebugFIQ(void)
				{
					printf("Enter DebugFIQ");
				
					while(1)
					{
						LedSet( 0xf ) ;		Delay( 1000 ) ;
						LedSet( 0x0 ) ;		Delay( 1000 ) ;
					}
				}
				//*******************************************************************************************************
							

相关资源