?? target.c
字號(hào):
/************************************************
* NAME : TARGET.C *
* BY : HappyHd
* Version : 1.Sep.2006 *
***********************************************/
#include "..\inc\target.h"
#include "..\ucos_ii\ucos_ii.h"
#include "..\inc\includes.h"
extern OS_EVENT *KeySem;
void SystemInit(void) //系統(tǒng)初始化
{
rSYSCFG=SYSCFG_8KB; //使用8K指令緩存
rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);
Port_Init(); //端口初始化
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S); //更改時(shí)鐘頻率48MHZ
#endif
Uart_Init(SERIAL_CHNNAL,SERIAL_BAUD);//串口初始化
Uart_Select(SERIAL_CHNNAL); //選擇串口
InitInterrupts(); //中斷初始化
InitTimers(); // 初始化系統(tǒng)節(jié)拍發(fā)生器TIMER0
Delay(100); //延時(shí)調(diào)整
}
void InitTimers(void) //初始化系統(tǒng)節(jié)拍發(fā)生器TIMER0
{
rTCFG0= 0x00000095; //死區(qū)dead zone=0, 預(yù)標(biāo)值pre0= 150
rTCFG1= 0x00000003; //全部中斷, 分頻器mux0= 1/16
rTCNTB0= OS_CLOCK; //設(shè)置中斷頻率
rTCON = 0x00000002; //手動(dòng)更新 T0
}
void TimersStart(void) //啟動(dòng)節(jié)拍發(fā)生器TIMER0
{
rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL ); //開啟中斷 TIMER0
rTCON = 0x00000009; //自動(dòng)裝載并開始
}
void InitInterrupts(void) //初始化中斷
{
rINTCON=0x1; //向量中斷,IRQ 允許,FIQ 禁止
rINTMOD=0x0; //全部采用IRQ mode
rINTMSK=BIT_GLOBAL; // 屏蔽所有中斷.
//定義非正常中斷入口函數(shù)
pISR_UNDEF = (unsigned) DebugUNDEF;
pISR_SWI = (unsigned) DebugSWI;
pISR_PABORT = (unsigned) DebugPABORT;
pISR_DABORT = (unsigned) DebugDABORT;
pISR_FIQ = (unsigned) DebugFIQ;
//定義正常中斷入口函數(shù)
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) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
void DebugUNDEF(void)
{
Uart_Printf("Enter DebugUNDEF");
while(1) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
void DebugSWI(void)
{
Uart_Printf("Enter DebugSWI");
while(1) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
void DebugPABORT(void)
{
Uart_Printf("Enter DebugPABORT");
while(1) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
void DebugDABORT(void)
{
Uart_Printf("Enter DebugDABORT");
while(1) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
void DebugFIQ(void)
{
Uart_Printf("Enter DebugFIQ");
while(1) {
Led_Display(7);
Delay(500);
Led_Display(0);
}
}
/************************************************************************************************
* 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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -