但是Delay相当占系统时间,白白浪费资源你得被骂死,于是我们要采用定时器和中断: 
 
暂时就定个10ms中断好了: 
 
中断不能带参数,看来得用全局变量了。 
 
ontime ,offtime,alltime.来来来,我们给它初始化一下. 
[AppleScript] syntaxhighlighter_viewsource syntaxhighlighter_copycode void LEDInit(u32 ontime ,u32 offtime,u32 alltime)
{
	static u32 m_ontime,m_offtime,m_alltime;
	//统统滴 读进来
}
 
 
下面就是写中断处理了: 
[AppleScript] syntaxhighlighter_viewsource syntaxhighlighter_copycode void __Timer0Int(void)
{
	//10ms重载
	LEDProcess();
}
void LEDProcess(void)
{
	static u32 allcount,ncount;
	m_count+=10;
	if(allcount>alltime)
	{
		//任务结束
		//看起来这里还要设个标志
	}
	else
	{
		//燥起来
		ncount+=10;
		if(ncount>m_ontime)
		{
			LED_ON;
			ncount=0;
			//看起来还要设个交替的标志
		}
		else
		{
			LED_OFF;
			ncount=0;
		}
	}
}
void LEDInit(u32 ontime ,u32 offtime,u32 alltime)
{
	static u32 m_ontime,m_offtime,m_alltime;
	//统统滴 读进来
}
 
 |