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

📄 target.c

📁 ucos移植到44b0
💻 C
字号:
#include "..\inc\target.h"
#include "..\SOURCE\includes.h"               /* uC/OS interface */
#include "..\lwip\arch\ne2kif.h"

extern OS_EVENT *KeySem;
extern void RtcTickInit(void);
volatile char which_int=0;
void EInt4567Isr(void)
{
    which_int = rEXTINPND;
    rEXTINPND = 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
    Port_Init();					//初始化端口

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

    Led_Display(7);
    RtcTickInit();
    OSTimeSet(0);
	
	Delay(0);						//调整延时

}


/********************************************************************************************************
 * ARMTargetStart																						*
 *																										*
 * Description: This function start the ARM target running												*
 *																										*
 * Argument   : none																					*
 ********************************************************************************************************/


void ARMTargetStart(void) {
	
	ARMInitTimers();				//配置时钟0相关寄存器
	ARMInstallSystemTimer();		//时钟0中断使能

//	ARMStartTimer();				//时钟0开始,最好在系统的第一个任务调用,不推荐在这里调用
}

void ARMInitInterrupts(void)
{
//begin:add by wangbin for plant 2005-11-25
    rINTCON=0x5;
    rINTMOD=0x0;	  // All=IRQ mode
    rINTMSK=0x7ffffff;	  // All interrupt is masked.
	rWTCON=0;
//End:add by wangbin for plant 2005-11-25

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

	//rPCONG = rPCONG | 0x000c;//中断1
	//rPUPG = rPUPG & 0xfd;
	//rEXTINT |= 0x40;//网卡中断,上升沿触发
	//rEXTINT |= 0x10;//网卡中断,高电平触发

	
	//set interrupt vector routine
//	pISR_RESET					//reserved
	pISR_TICK= (unsigned)OSTickISR;
	//pISR_EINT1= (unsigned) OSNE2KISR;
	
}


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;
	
}//ARMnitTimers


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


// enable the interrupt.
void ARMInstallSystemTimer(void)
{
	//Non-vectored,IRQ enable,FIQ disable 
	rINTCON=0x1;

	//Non maksed TIMER0
	rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL | BIT_EINT4567 | BIT_EINT3);	//Default value=0x7ffffff
}//ARMInstallSystemTimer


void BreakPoint(void) {

	Uart_Printf("Enter BreakPoint");
	
	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while
}//BreakPoint


void DebugUNDEF(void) {

	Uart_Printf("Enter DebutUNDEF");

	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while

}

void DebugSWI(void) {

	Uart_Printf("Enter DebutSWI");

	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while

}


void DebugPABORT(void) {

	Uart_Printf("Enter DebutPABORT");

	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while

}


void DebugDABORT(void) {

	Uart_Printf("Enter DebutDABORT");

	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while

}


void DebugFIQ(void) {

	Uart_Printf("Enter DebutFIQ");

	while(1) {
		Led_Display(0x7);
		Delay(1000);
		Led_Display(0x0);
		Delay(1000);
	}//while

}

⌨️ 快捷键说明

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