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

📄 target.c

📁 不用我多说,自己看吧,大家共同进步
💻 C
字号:
#include "..\inc\target.h"
#include "..\ucos_ii\ucos_ii.h"  
#include "..\inc\Adc.h"
#include "..\inc\Rtc.h"
#include "..\inc\Iic.h"

extern OS_EVENT *KeySem;

/************************************************************************************************
 * ARMTargetInit									
 * Description: This function initialize an ARM Target board						 * Argument   : none    				
************************************************************************************************/
void ARMTargetInit(void)
{
 	rSYSCFG=SYSCFG_8KB;				
	rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);	
	Port_Init();						
	#if (PLLON==1)
    ChangePllValue(PLL_M,PLL_P,PLL_S);
    #endif			     
	Uart_Init(0,115200);			      	
	Uart_Select(0);					
	ARMInitInterrupts();			        	
	Delay(100);		
	Led_Display(0);
    Delay(500);  //calibrate Delay()
    Led_Display(7);
    Delay(500);  //calibrate Delay()
    Led_Display(0);
    Delay(500);
	Led_Display(7);			
}
/************************************************************************************************
 * ARMTargetStart											 * Description: This function start the ARM target running						 * Argument   : none											************************************************************************************************/
void ARMTargetStart(void) 
{	
	ARMInitTimers();				
	ARMInstallSystemTimer();		        
}

//Initialize timer that is used OS.
void ARMInitTimers(void)
{
	rTCFG0= 0x00000095;            //dead zone=0, pre0= 150
	rTCFG1= 0x00000003;            //all interrupt, mux0= 1/16
	rTCNTB0= _CLOCK;               //set T0 count
	rTCON= 0x00000002;             //update T0	
}

// enable the interrupt.
void ARMInstallSystemTimer(void)       
{	
	rINTCON=0x1;                            //Non-vectored,IRQ enable,FIQ disable 
	rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL );	//Non maksed TIMER0,Default value=0x7ffffff
}

//start system timer0
void ARMStartTimer(void)
{
	rTCON = 0x9;                    //autoreload and start
}

int ARMRequestSystemTimer(void *tick, const unsigned char *str) 
{
	return 1;
}

/************************************************************************************************
 * ARMTargetInit											 * Description: This function initialize an ARM Target board						 * Argument   : none    				
************************************************************************************************/
void ARMInitInterrupts(void)
{
	    
	 rINTCON=0x1;           // Non-vectored,IRQ ensable,FIQ disable	  
	 rINTMOD=0x0;	        // All=IRQ mode
	 rINTMSK=BIT_GLOBAL;    // All interrupt is masked.	  
       
//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) Adc_Int;
	pISR_RTC= (unsigned) Rtc_Alarm;
	pISR_UTXD1= (unsigned) BreakPoint;
	pISR_UTXD0= (unsigned) BreakPoint;
	pISR_SIO= (unsigned) BreakPoint;
	pISR_IIC= (unsigned) Iic_Int;
	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) OSTickISR;
	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) Rtc_Tick;
	pISR_EINT4567= (unsigned) OSEINT4567ISR;
	pISR_EINT3= (unsigned) BreakPoint;
	pISR_EINT2= (unsigned) BreakPoint;
	pISR_EINT1= (unsigned) BreakPoint;
	pISR_EINT0= (unsigned) BreakPoint;
        
}

void BreakPoint(void)
{

	Uart_Printf("Enter BreakPoint");
	
	while(1) {
		
	         }
}

void DebugUNDEF(void)
{

	Uart_Printf("Enter DebugUNDEF");

	while(1) {
		
	         }
}

void DebugSWI(void) 
{

	Uart_Printf("Enter DebugSWI");

	while(1) {
		
	          }
}

void DebugPABORT(void) 
{

	Uart_Printf("Enter DebugPABORT");

	while(1) {
		
	         }
}

void DebugDABORT(void)
 {

	Uart_Printf("Enter DebugDABORT");

	while(1) {
		
	         }
}

void DebugFIQ(void) 
{

	Uart_Printf("Enter DebugFIQ");

	while(1) {
	 	
	         }
} 
/************************************************************************************************
 * ARMTargetInit4567											 * Description: This function initialize an ARM Target board						 * Argument   : none    				
************************************************************************************************/
volatile char which_int=0;
void EInt4567Isr(void)
{
    which_int = rEXTINTPND;
    rEXTINTPND = 0xf;		//clear EXTINTPND reg.		
    rI_ISPC = BIT_EINT4567;	//clear pending_bit

	    switch(which_int)
	    {
			case 1:
			{
				OSMboxPost(KeySem, (void *)4);
			}
			    break;
			case 2:
			{
				OSMboxPost(KeySem, (void *)5);
			}
			    break;
			case 4:
			{
				OSMboxPost(KeySem, (void *)6);
			}
			    break;
			case 8:
			{
				OSMboxPost(KeySem, (void *)7);
			}
			    break;
			default :
			break;
	    }
	
}


⌨️ 快捷键说明

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