本帖最后由 1208 于 2018-10-18 17:50 编辑
[mw_shl_code=c,true]LED灯
void Led_ON(void)
{
GPIO_ResetBits(GPIOF, GPIO_Pin_9); // 1- ON
}
void Led_OFF(void)
{
GPIO_SetBits(GPIOF, GPIO_Pin_9); // 0- OFF
}
void handle_Led(u8 ucSwitch, u8 usCnt)
{
if (ucSwitch == ON)
{
int i;
for(i = 0; i < usCnt; i++)
{
Led_ON();
delay_ms(1000);
}
Led_OFF();
}
else
{
Led_OFF();
}
}
//定时器3中断服务函数
u16 ucTimer_led = 0;
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_Update)==SET)
{
ucTimer_led++;
}
TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
}
extern u16 ucTimer_led;
//外部中断0服务程序
void EXTI0_IRQHandler(void)
{
if(WK_UP==1)
{
TIM_Cmd(TIM3,ENABLE);
ucTimer_led++;
if(ucTimer_led > 500)
{
ucTimer_led= 500;
}
}
else
{
if(ucTimer_led > 200 && ucTimer_led < 400) //3s< ucTimer_led < 4s
{
handle_Led(ON,1);
}
else if(ucTimer_led <100 && ucTimer_led >5)//0.5s< ucTimer_led <1s
{
handle_Led(ON,6);
}
ucTimer_led = 0;
}
EXTI_ClearITPendingBit(EXTI_Line0);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>