69,369
社区成员
发帖
与我相关
我的任务
分享
volatile int argument = 0, retValue = 0; // the key word "volatile" here is necessary
// The following pragma is pseudo, that only describes the effect of the interrupt vector function
#pragma interrupt_vector(TIMER)
// @0x00001000 the address of the vector for timer event
void timer_vector_handler(void)
{
save_context(); // Save the context(almost all the general registers)
retValue = toggle_led(LED1, &argument); // According to argument, If argument is 0, turn it off; Otherwise, turn it on.
// Then, the value of argument is toggled.
// retValue is a return vbalue that indicates whether the operation is successful or not.
reset_timer(); // clear the timer interrupt status and reset the timer.
restore_context(); // resotre the context saved before
// iret(); // Because the function is predeclared as #pragma interrupt_vector,
// the compiler may automatically generate "iret" instruction at the end of the fucntion
}
UINT SetTimer(
UINT nIDEvent,
UINT nElapse,
void ( CALLBACK* lpfnTimer )(HWND, UINT, UINT, DWORD) = NULL
) throw();