📄 timeisrinit.c
字号:
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\source\includes.h"
#define IRQ_VECTOR_OFFSET (0x18)
//初次下载程序的时候可能是由于以下的程序没有进行初始诲(有待验证)
/*void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void Isr_Init(void)
{
U32 i;
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
{
*((volatile unsigned *)i)=0xEA000000+0x1FFE;
}
//rINTCON=0x1; // Vectored Int. IRQ enable,FIQ disable
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT3; // All interrupt is masked.
}
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception!!!\n");
while(1);
}
void HaltSwi(void)
{
Uart_Printf("SWI exception!!!\n");
while(1);
}
void HaltPabort(void)
{
Uart_Printf("Pabort exception!!!\n");
while(1);
}
void HaltDabort(void)
{
Uart_Printf("Dabort exception!!!\n");
while(1);
}*/
//-------------------------------------------------------
// globle variables
//-------------------------------------------------------
volatile static int isrCount = 0; // tick counter
//volatile static unsigned int Dump_Pool[16];
//-------------------------------------------------------
// OS_Tick Hook Fubction
//-------------------------------------------------------
void tick_hook(void)
{
isrCount++;
rI_ISPC = (unsigned int)1 << 20;
}
//-------------------------------------------------------
// install a new ISR
// this function must be synchronized
//-------------------------------------------------------
void ISR_Install(void)
{
pISR_TICK=(unsigned)OSTickISR;
}
//-------------------------------------------------------
// must be synchronized
//-------------------------------------------------------
void tick_off(void)
{
rRTCCON = (unsigned char)1;
rTICINT = (unsigned char)0;
rRTCCON = (unsigned char)0;
}
//--------------------------------------------------------
// set or clear TICK interrupt mask
// this function must be synchronized
//--------------------------------------------------------
void tick_int_enable(unsigned char bEnabled)
{
// clear interrupt pending first
rI_ISPC = (unsigned int)0x01 << 20;
rINTMSK &= (unsigned int)~(0x01 << 20);
}
//--------------------------------------------------------
// start tick function of RTC
// interval = (1 + div) / 128 second
// this function must be synchronized
// div MUST >= 1 && <= 128
//--------------------------------------------------------
void tick_init(unsigned char div)
{
rRTCCON = (unsigned char)1;
// ASSERT(div >= 1 && div <= 127);
rTICINT = (unsigned char)(div | 0x80);
rRTCCON = (unsigned char)0;
tick_int_enable(1);
}
//--------------------------------------------------------
// interrupt controler initilization
//--------------------------------------------------------
void intcon_init(void)
{
rINTMOD = 0; // all interrupt sources configed as IRQ
rI_ISPC = 0x7ffffff; // clear all intrrupt request
rINTCON = 0x05; // irq interrupt available
}
//--------------------------------------------------------
// globel interrupt enable
//--------------------------------------------------------
void globle_int_enable(unsigned char bEnabled)
{
if(bEnabled)
rINTMSK &= ~BIT_GLOBAL;
else
rINTMSK |= 0x01 << 26;
}
void sys_init(void)
{
//Isr_Init();
tick_off();
tick_int_enable(0);
globle_int_enable(0);
intcon_init();
isrCount = 0;
// Set the function of the pins
Port_Init();
Uart_Select(0);
Uart_Init(0, 115200);
// hook the tick ISR
ISR_Install();
globle_int_enable(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -