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

📄 target.c

📁 基于3SC44B0的移植代码,包括UCOSII、UCGUI、触模屏、摄像头的程序
💻 C
字号:
#include "target.h"
#include "ucos_ii.h"               /* uC/OS interface */

extern OS_EVENT *KeySem;



volatile char which_int=0;






void EInt4567Isr(void)
{
    which_int = rEXTINTPND;
    rEXTINTPND = 0xf;		//clear EXTINTPND reg.		
    rI_ISPC |= BIT_EINT4567;	//clear pending_bit

	Delay(500);		//延时若干个100us,消除抖动
	rPCONG &= 0x00ff;
	if( (rPDATG&0xf0) != 0xf0)
	{
	    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;
	    }
	}

	while((rPDATG&0xf0) != 0xf0);		//按键没有松开就一直等待
    rPCONG |= 0xff00;		//GPG4、5、6、7设为中断引脚
}

/********************************************************************************************************
 * ARMTargetInit																						*
 *																										*
 * Description: This function initialize an ARM Target board											*
 *																										*
 * Argument   : none    																				*
 ********************************************************************************************************/

void ARMTargetInit(void) {
	
	//配置Cache
   	rSYSCFG=SYSCFG_8KB;				//使用8K字节的指令缓存
	//rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);
	
	Port_Init();					//初始化端口
	ChangePllValue(48,2,1);			//设置CPU频率为48M

//Uart_Init(0,115200);			//设置串口0的速率为115200bps
	
	//Uart_Select(0);					//选择串口0

//

	ARMInitInterrupts();			//初始化中断,设置中断服务程序
	
	Delay(10);						//调整延时

}


/********************************************************************************************************
 * 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=0x01;	  

	// All=IRQ mode
	rINTMOD=0x0;	  

	// All interrupt is masked.
	rINTMSK=BIT_GLOBAL;	  

//      rPCONG = rPCONG | 0xff00;		//GPG4、5、6、7设为中断引脚
   //   rPUPG = rPUPG & 0x0f;		//GPG4、5、6、7上拉电阻有效
//	rEXTINT=0x0;	//低电平触发

//	rPCONG = rPCONG | 0x00c0;
//	rPUPG = rPUPG & 0xf7;
	//
//	rEXTINT |= 0x4000;

	
	//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_EINT3= (unsigned) BreakPoint;
	pISR_EINT2= (unsigned) BreakPoint;
	pISR_EINT1= (unsigned) BreakPoint;
	pISR_EINT0= (unsigned) BreakPoint;

	pISR_TIMER0= (unsigned) OSTickISR;
	//pISR_TIMER3 = (unsigned)EInttimer3Isr;  
}


int ARMRequestSystemTimer(void *tick, const unsigned char *str) 
{

	return 1;

}


//Initialize timer that is used OS.
void ARMInitTimers(void)
{
  #if 0
//dead zone=0, pre0= 150
	rTCFG0= 0x00000f95;   //system  time  use time0  ,touch panel use time3
	//all interrupt, mux0= 1/16
	rTCFG1= 0x000001003;

	//set T0 count
	rTCNTB0= _CLOCK;
	
rTCNTB3=0xc350;		//(1/(60MHz/4/15))*0xc350=50ms
    					//(1/(60MHz/4/15))*0x4320=20ms
    rTCMPB3=0x0;

	//update T0/T3
	rTCON= 0x00020002;
#else
	//dead zone=0, pre0= 150
	rTCFG0= 0x00000095;   //system  time  use time0  ,touch panel use time3
	//all interrupt, mux0= 1/16
	rTCFG1= 0x00000003;

	//set T0 count
	rTCNTB0= _CLOCK;

	//update T0/T3
	rTCON= 0x00000002;
#endif 
	
}


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


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


void BreakPoint(void) {

	Uart_Printf("Enter BreakPoint");
	
	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}


void DebugUNDEF(void) {

	Uart_Printf("Enter DebugUNDEF");

	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}

void DebugSWI(void) {

	Uart_Printf("Enter DebugSWI");

	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}


void DebugPABORT(void) {

	Uart_Printf("Enter DebugPABORT");

	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}


void DebugDABORT(void) {

	Uart_Printf("Enter DebugDABORT");

	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}


void DebugFIQ(void) {

	Uart_Printf("Enter DebugFIQ");

	while(1) {
		Led_Set(0xf);
		Delay(1000);
		Led_Set(0x0);
		Delay(1000);
	}
}

⌨️ 快捷键说明

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