/* 定时器 ISR */
void vTimerISR( voidvoid * pvParameters )
{
static unsigned char ucLocalTickCount = 0;
static signed BaseType_txHigherPriorityTaskWoken;
/*定时器中断发生 */
...执行其它代码
/*需要vATask() 运行吗? */
xHigherPriorityTaskWoken = pdFALSE;
ucLocalTickCount++;
if( ucLocalTickCount >= TICKS_TO_WAIT )
{
/* 释放信号量,解除vATask任务阻塞状态 */
xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
/* 复位计数器 */
ucLocalTickCount = 0;
}
/* 如果 xHigherPriorityTaskWoken 表达式为真,需要执行一次上下文切换*/
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}