📄 os_timer.c
字号:
#define OS_TIMER_ENTITY
#include "includes.h"
extern void TIMER5er(void);
//在还没有开中短的时候,关闭定时器,以免在创建进程的时候进入中断,
//因为此时还没有安装中断向量,而且还没有开启向量中断机制
//会引起错误
void timer_stop(void)
{
rTCON&=~(1<<24);
rI_ISPC=0x3ffffff;
}
void timer_init(void)
{
unsigned int temp;
//中断的初始化
rINTCON&=~0x06;
rINTMOD=0x00; //timer5 irq
rINTMSK&=~(BIT_TIMER5+BIT_GLOBAL); //timer 5 irq on
rI_ISPC=BIT_TIMER5; //clear int
Install_Irq(pISR_TIMER5,TIMER5er);
/*
//led0
rPCONC&=~(0x03<<2);
rPCONC|=(0x01<<2);
rPUPC&=~(0x02);
rPDATC|=LED; //light
*/
//timer5 init
rTCFG0|=(0xff<<16); //0xff
rTCFG1&=~((0x0f<<20)|(0x0f<<24));
rTCFG1|=(0x03<<20); //1/16
rTCNTB5=81;
temp=rTCON;
temp&=~(0x07<<24);
temp|=(0x02<<24);
rTCON=temp; //timer5 one-shot,updatat
temp=rTCON;
temp&=~(0x07<<24);
temp|=(0x05<<24);
rTCON=temp; //timer5 start
return ;
}
void timer5_int(void)
{
rI_ISPC=BIT_TIMER5;
OSTimeTick();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -