|
@ -16,7 +16,8 @@ uint8_t s_now_interval_duty = 0; |
|
|
WORK_GEARS_T now_gears; |
|
|
WORK_GEARS_T now_gears; |
|
|
WORK_GEARS_T shutdown_before_gears; //关机前的档位 |
|
|
WORK_GEARS_T shutdown_before_gears; //关机前的档位 |
|
|
uint8_t s_intervalkey_press_count = 0; |
|
|
uint8_t s_intervalkey_press_count = 0; |
|
|
|
|
|
|
|
|
|
|
|
ERROR_EVEN_T error_even; |
|
|
|
|
|
static bool error_even_trigger_after_stop_ozone_work_state; |
|
|
// /*********************************************************************************************************************** |
|
|
// /*********************************************************************************************************************** |
|
|
// * =====================================================HOOK实现====================================================== * |
|
|
// * =====================================================HOOK实现====================================================== * |
|
|
// ***********************************************************************************************************************/ |
|
|
// ***********************************************************************************************************************/ |
|
@ -87,7 +88,7 @@ void before_resuming_flicker_rgb_mode(void) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* @brief 间歇功能开启时,rgb亮3s闪烁1s |
|
|
|
|
|
|
|
|
* @brief 间歇功能开启时,rgb亮3s灭1s |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
void process_rgb_flicker(void) { |
|
|
void process_rgb_flicker(void) { |
|
@ -230,7 +231,9 @@ void shutdown(void) { |
|
|
starting_up_state = false; |
|
|
starting_up_state = false; |
|
|
update_ozone_work_gears(WORK_GEARS_CLOSE); |
|
|
update_ozone_work_gears(WORK_GEARS_CLOSE); |
|
|
light_module_set_timing_light_mode(CLOSE_ALL_LED); |
|
|
light_module_set_timing_light_mode(CLOSE_ALL_LED); |
|
|
port_fan_set(false); //打开你风扇 |
|
|
|
|
|
|
|
|
port_fan_set(false); //关闭风扇 |
|
|
|
|
|
error_even = NO_ERROR_EVENT; |
|
|
|
|
|
error_even_trigger_after_stop_ozone_work_state = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -325,6 +328,64 @@ void try_shutdown(void) { |
|
|
} |
|
|
} |
|
|
bool timing_function_is_enable(void) { return timing_function_enable_falg; } |
|
|
bool timing_function_is_enable(void) { return timing_function_enable_falg; } |
|
|
|
|
|
|
|
|
|
|
|
void iwdt_init(void) { |
|
|
|
|
|
/** |
|
|
|
|
|
* @brief 看门狗介绍:当计数到0时,窗口计数器+1 |
|
|
|
|
|
* 当窗口计数为“2”的时候,产生中断 |
|
|
|
|
|
* 当窗口计数器为“4”的之前没有进行喂狗操作,产生复位 |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
|
|
|
IWDT_InitStruType x; |
|
|
|
|
|
|
|
|
|
|
|
x.WDT_Tms = 4000; |
|
|
|
|
|
x.WDT_IE = Enable; /* IWDT中断使能 */ |
|
|
|
|
|
x.WDT_Rst = Enable; /* IWDT复位使能 */ |
|
|
|
|
|
x.WDT_Clock = IWDT_CLOCK_WDT; /* LRC */ |
|
|
|
|
|
IWDT_Init(&x); |
|
|
|
|
|
|
|
|
|
|
|
/* 使能IWDT */ |
|
|
|
|
|
IWDT_Enable(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void feed_iwdt(void) { |
|
|
|
|
|
//喂狗 |
|
|
|
|
|
if (0x01 == IWDT_GetFlagStatus()) //产生中断 |
|
|
|
|
|
{ |
|
|
|
|
|
IWDT_Clear(); |
|
|
|
|
|
// printf("喂狗\r\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void process_error_even(void) { |
|
|
|
|
|
if (error_even == NO_ERROR_EVENT) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (!error_even_trigger_after_stop_ozone_work_state) { |
|
|
|
|
|
error_even_trigger_after_stop_ozone_work_state = true; |
|
|
|
|
|
set_pwm_modbul_freq_duty(1, 0); |
|
|
|
|
|
light_module_set_rgb_mode(RGB_CLOSE); |
|
|
|
|
|
light_module_set_timing_light_mode(CLOSE_ALL_LED); |
|
|
|
|
|
port_fan_set(false); //关闭风扇 |
|
|
|
|
|
} else if (error_even == ERROR_EVEN_FAN) { |
|
|
|
|
|
static uint32_t error_even_fan_ticket = 0; |
|
|
|
|
|
static uint8_t one_led_flicker_state = 1; |
|
|
|
|
|
if (port_haspassedms(error_even_fan_ticket) > 500) { |
|
|
|
|
|
error_even_fan_ticket = get_sys_ticket(); |
|
|
|
|
|
one_led_flicker_state = !one_led_flicker_state; |
|
|
|
|
|
port_led0_set(one_led_flicker_state); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (error_even == ERROR_EVEN_WAY_CIRCUIT) { |
|
|
|
|
|
static uint32_t error_even_way_circuit = 0; |
|
|
|
|
|
static uint8_t two_led_flicker_state = 1; |
|
|
|
|
|
if (port_haspassedms(error_even_way_circuit) > 500) { |
|
|
|
|
|
error_even_way_circuit = get_sys_ticket(); |
|
|
|
|
|
two_led_flicker_state = !two_led_flicker_state; |
|
|
|
|
|
port_led0_set(two_led_flicker_state); |
|
|
|
|
|
port_led1_set(two_led_flicker_state); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @brief 间歇功能使能后,rgb闪烁 |
|
|
* @brief 间歇功能使能后,rgb闪烁 |
|
|
* |
|
|
* |
|
@ -342,7 +403,9 @@ int main(void) { |
|
|
gpio_init(); |
|
|
gpio_init(); |
|
|
zkey_init(&key_module); |
|
|
zkey_init(&key_module); |
|
|
t16_pa4_init(); |
|
|
t16_pa4_init(); |
|
|
|
|
|
iwdt_init(); |
|
|
power_on_ozone_working_status(); |
|
|
power_on_ozone_working_status(); |
|
|
|
|
|
error_even = ERROR_EVEN_WAY_CIRCUIT; |
|
|
while (true) { |
|
|
while (true) { |
|
|
static uint32_t keylastprocess = 0; |
|
|
static uint32_t keylastprocess = 0; |
|
|
if (port_haspassedms(keylastprocess) > 20) { |
|
|
if (port_haspassedms(keylastprocess) > 20) { |
|
@ -351,6 +414,8 @@ int main(void) { |
|
|
} |
|
|
} |
|
|
if (starting_up_state) { //开机中 |
|
|
if (starting_up_state) { //开机中 |
|
|
port_do_debug_light_state(); |
|
|
port_do_debug_light_state(); |
|
|
|
|
|
process_error_even(); |
|
|
|
|
|
try_adc_gather(); |
|
|
if (timing_function_is_enable()) { //定时功能是开启的 |
|
|
if (timing_function_is_enable()) { //定时功能是开启的 |
|
|
try_shutdown(); |
|
|
try_shutdown(); |
|
|
} |
|
|
} |
|
@ -360,6 +425,7 @@ int main(void) { |
|
|
} |
|
|
} |
|
|
} else { //关机中 |
|
|
} else { //关机中 |
|
|
} |
|
|
} |
|
|
|
|
|
feed_iwdt(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -369,5 +435,7 @@ int main(void) { |
|
|
* 定时按键测试通过 |
|
|
* 定时按键测试通过 |
|
|
* 间歇按键闪烁测试通过 |
|
|
* 间歇按键闪烁测试通过 |
|
|
* 档位按键测试通过 |
|
|
* 档位按键测试通过 |
|
|
|
|
|
* 模拟风扇错误触发后led0闪烁测试通过 |
|
|
|
|
|
* 模拟总电路错误触发后led0,led1闪烁测试通过 |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |