打印

分享:按键短按灯长亮,长按灯短亮

[复制链接]
185|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
冷冻链|  楼主 | 2018-7-12 07:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[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);
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

397

主题

397

帖子

0

粉丝