📄 timer.c
字号:
/*
*********************************************************************************************************
* 文件: Timer5.C
* 描述: Timer5 分配为系统节拍发生器.
* 编写: 深思 (001-12345@sohu.com).
*********************************************************************************************************
*/
#include <windows.h>
#include "ucos_ii.h"
/*
*********************************************************************************************************
* 描述: 初始化系统节拍定时器, Timer5 产生 200 Hz 的时钟节拍.
*********************************************************************************************************
*/
extern CONTEXT context;
extern HANDLE mainHandle;
extern BOOLEAN flagEn; //增加一个全局变量,做为是否时钟调度的标志
void CALLBACK ISR_Timer5(unsigned int a,unsigned int b,unsigned long c,unsigned long d,unsigned long e);
void timer5_Init()
{
HANDLE cp,ct;
context.ContextFlags = CONTEXT_CONTROL;
cp = GetCurrentProcess(); //得到当前进程句柄
ct = GetCurrentThread(); //得到当前线程伪句柄
DuplicateHandle(cp, ct, cp, &mainHandle, 0, TRUE, 2); //伪句柄转换,得到线程真句柄
timeSetEvent(1000/OS_TICKS_PER_SEC, 0, ISR_Timer5, 0, TIME_PERIODIC);
}
/*
*********************************************************************************************************
* 描述: 系统节拍中断服务程序.
*********************************************************************************************************
*/
void OSTickISR();
void Qf_Tick();
void CALLBACK ISR_Timer5(unsigned int a,unsigned int b,unsigned long c,unsigned long d,unsigned long e)
{
OSTickISR();
OSIntNesting++;
Qf_Tick();
OSIntNesting--;
}
/*
********************************************************************************************************
* End.
********************************************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -