You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 lines
1.4 KiB

/*
* @Author: sunlight 2524828700@qq.com
* @Date: 2024-09-18 20:58:48
* @LastEditors: sunlight 2524828700@qq.com
* @LastEditTime: 2024-09-21 11:35:50
* @FilePath: \auxiliary_addition\Usr\time_slice\time_slice.c
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include "time_slice.h"
#include "tim.h"
static uint32_t time1;
static uint32_t time2;
static uint32_t time3;
static bool tjc_process_flag = false;
static bool low_power_flag = false;
static bool debug_light_flag = false;
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
time1++;
time2++;
time3++;
if (time1 == 2) {
tjc_process_flag = true;
time1 = 0;
}
if (time2 == 1000) {
low_power_flag = true;
time2 = 0;
}
if (time3 == 500) {
debug_light_flag = true;
time3 = 0;
}
}
bool GetFlag(uint32_t slice_flag) {
switch (slice_flag) {
case tjc_process:
return tjc_process_flag;
case low_power:
return low_power_flag;
case debug_light:
return debug_light_flag;
}
}
void ClearFlag(uint32_t slice_flag) {
switch (slice_flag) {
case tjc_process:
tjc_process_flag = false;
break;
case low_power:
low_power_flag = false;
break;
case debug_light:
debug_light_flag = false;
break;
}
}