From 0b1ce8b614740665c29ff26a8ecce2e471192742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 22 May 2021 12:13:43 +0200 Subject: [PATCH] Fix #32: * Implement clear flags command for profile language. --- .../config-parser/temp-profile-parser.c | 3 ++- .../config-parser/temp-profile-parser.h | 1 + stm-firmware/temp-profile-executer.c | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/stm-firmware/config-parser/temp-profile-parser.c b/stm-firmware/config-parser/temp-profile-parser.c index 08c42c8..b1ccb58 100644 --- a/stm-firmware/config-parser/temp-profile-parser.c +++ b/stm-firmware/config-parser/temp-profile-parser.c @@ -41,7 +41,8 @@ static const struct pl_command_list_map cmd_list_map[_PL_NUM_CMDS] = { {PL_WAIT_FOR_TIME, "wait_time", 1u}, {PL_SET_RAMP, "temp_ramp", 2u}, {PL_LOUDSPEAKER_SET, "beep", 1u}, - {PL_OFF, "temp_off", 0u} + {PL_OFF, "temp_off", 0u}, + {PL_CLEAR_FLAGS, "clear_flags", 0u}, }; /** diff --git a/stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h b/stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h index 2b4e945..08a117c 100644 --- a/stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h +++ b/stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h @@ -32,6 +32,7 @@ enum pl_command_type { PL_WAIT_FOR_TIME, PL_LOUDSPEAKER_SET, PL_OFF, + PL_CLEAR_FLAGS, _PL_NUM_CMDS, }; diff --git a/stm-firmware/temp-profile-executer.c b/stm-firmware/temp-profile-executer.c index 042e584..4faaecd 100644 --- a/stm-firmware/temp-profile-executer.c +++ b/stm-firmware/temp-profile-executer.c @@ -26,6 +26,8 @@ #include #include +#include + static struct tpe_current_state IN_SECTION(.ccm.data) state = { .status = TPE_OFF, .start_timestamp = 0, @@ -161,6 +163,22 @@ static bool cmd_ramp(struct pl_command *cmd, bool cmd_continue) return ret; } +static void cmd_ack_flags(void) +{ + uint32_t flag_cnt; + uint32_t i; + enum safety_flag flag_enum; + bool status; + + flag_cnt = safety_controller_get_flag_count(); + for (i = 0; i < flag_cnt; i++) { + safety_controller_get_flag_by_index(i, &status, &flag_enum); + if (status) + (void)safety_controller_ack_flag(flag_enum); + } + +} + int temp_profile_executer_handle(void) { struct pl_command *current_cmd; @@ -222,6 +240,10 @@ int temp_profile_executer_handle(void) case PL_SET_RAMP: advance = cmd_ramp(current_cmd, cmd_continue); break; + case PL_CLEAR_FLAGS: + cmd_ack_flags(); + advance = true; + break; default: tpe_abort(); advance = true;