60 lines
1.0 KiB
C
60 lines
1.0 KiB
C
/*
|
||
* user_main.c
|
||
*
|
||
* Created on: 2023年10月30日
|
||
* Author: wyf
|
||
*/
|
||
|
||
#include "user.h"
|
||
|
||
void user_main(void)
|
||
{
|
||
|
||
PWR_OFF();
|
||
user_init();
|
||
|
||
HAL_TIM_Base_Start_IT(&htim17);
|
||
// HAL_TIM_PWM_Start_IT(&htim17, TIM_CHANNEL_1); //开启PWM波输出
|
||
|
||
bsp_StartTimer(3, 600000); //10分钟无操作,关机
|
||
|
||
while(1)
|
||
{
|
||
if(bsp_CheckTimer(0)) //未收到返回数据
|
||
{
|
||
bell_state.num = 3;
|
||
bell_state.continue_time = 150;
|
||
bell_state.interval_tine = 200;
|
||
BLED_OFF();
|
||
RLED_ON();
|
||
last_send =99;
|
||
|
||
bsp_StartTimer(2, bell_state.interval_tine);
|
||
BELL_ON();
|
||
bsp_StartTimer(1, bell_state.continue_time);
|
||
}
|
||
if(bsp_CheckTimer(1)) //在1定时器关闭蜂鸣器
|
||
{
|
||
BELL_OFF();
|
||
}
|
||
|
||
if(bsp_CheckTimer(2))
|
||
{
|
||
if(--bell_state.num)
|
||
{
|
||
bsp_StartTimer(2, bell_state.interval_tine);
|
||
BELL_ON();
|
||
bsp_StartTimer(1, bell_state.continue_time);
|
||
}
|
||
}
|
||
if(bsp_CheckTimer(3))
|
||
{
|
||
BELL_ON();
|
||
HAL_Delay(100);
|
||
PWR_OFF();
|
||
}
|
||
key_slave(); //按键处理
|
||
uart_slave(); //串口处理
|
||
}
|
||
}
|