From fdb3ceb3e95257fe56e8471eb5e57ff8ba5514f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 22 May 2021 16:40:08 +0200 Subject: [PATCH] Restructuring and comments --- stm-firmware/CMakeLists.txt | 4 +- .../reflow-controller/temp-profile-executer.h | 52 ---------- .../temp-profile/temp-profile-executer.h | 94 +++++++++++++++++++ .../temp-profile-parser.h | 0 stm-firmware/main.c | 2 +- stm-firmware/shell.c | 2 +- .../temp-profile-executer.c | 9 +- .../temp-profile-parser.c | 9 +- stm-firmware/ui/gui.c | 2 +- stm-firmware/ui/lcd.c | 2 - 10 files changed, 116 insertions(+), 60 deletions(-) delete mode 100644 stm-firmware/include/reflow-controller/temp-profile-executer.h create mode 100644 stm-firmware/include/reflow-controller/temp-profile/temp-profile-executer.h rename stm-firmware/include/reflow-controller/{config-parser => temp-profile}/temp-profile-parser.h (100%) rename stm-firmware/{ => temp-profile}/temp-profile-executer.c (98%) rename stm-firmware/{config-parser => temp-profile}/temp-profile-parser.c (97%) diff --git a/stm-firmware/CMakeLists.txt b/stm-firmware/CMakeLists.txt index 38ab3d5..8bb0dfd 100644 --- a/stm-firmware/CMakeLists.txt +++ b/stm-firmware/CMakeLists.txt @@ -88,10 +88,12 @@ aux_source_directory("settings" SETTINGS_SRCS) aux_source_directory("safety" SAFETY_SRCS) aux_source_directory("shellmatta/src" SHELLMATTA_SRCS) aux_source_directory("updater" UPDATER_SRCS) +aux_source_directory("temp-profile" PROFILE_SRCS) add_executable(${ELFFILE} ${MAIN_SOURCES} ${CFG_PARSER_SRCS} ${UI_SRCS} ${FAT_SRCS} ${SDIO_SRCS} ${BOOT_SRCS} ${SETUP_SRCS} - ${STM_PERIPH_SRCS} ${SETTINGS_SRCS} ${SAFETY_SRCS} ${SHELLMATTA_SRCS} ${UPDATER_SRCS} + ${STM_PERIPH_SRCS} ${SETTINGS_SRCS} ${SAFETY_SRCS} + ${SHELLMATTA_SRCS} ${UPDATER_SRCS} ${PROFILE_SRCS} ) add_dependencies(${ELFFILE} updater-ram-code-header-blob) diff --git a/stm-firmware/include/reflow-controller/temp-profile-executer.h b/stm-firmware/include/reflow-controller/temp-profile-executer.h deleted file mode 100644 index 0fc025b..0000000 --- a/stm-firmware/include/reflow-controller/temp-profile-executer.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Reflow Oven Controller -* -* Copyright (C) 2021 Mario Hüttel -* -* This file is part of the Reflow Oven Controller Project. -* -* The reflow oven controller is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with the reflow oven controller project. -* If not, see . -*/ - -#ifndef __TEMP_PROFILE_EXECUTER_H__ -#define __TEMP_PROFILE_EXECUTER_H__ - -#include -#include - -#define MAX_PROFILE_LENGTH 64 - -enum tpe_status { - TPE_OFF, - TPE_RUNNING, - TPE_ABORT, -}; - -struct tpe_current_state { - enum tpe_status status; - float setpoint; - uint64_t start_timestamp; - uint32_t step; - uint32_t profile_steps; - enum pl_command_type current_command; -}; - -enum pl_ret_val temp_profile_executer_start(const char *filename); - -int temp_profile_executer_handle(void); - -const struct tpe_current_state *temp_profile_executer_status(void); - -int temp_profile_executer_stop(void); - -#endif /* __TEMP_PROFILE_EXECUTER_H__ */ diff --git a/stm-firmware/include/reflow-controller/temp-profile/temp-profile-executer.h b/stm-firmware/include/reflow-controller/temp-profile/temp-profile-executer.h new file mode 100644 index 0000000..e646b6a --- /dev/null +++ b/stm-firmware/include/reflow-controller/temp-profile/temp-profile-executer.h @@ -0,0 +1,94 @@ +/* Reflow Oven Controller +* +* Copyright (C) 2021 Mario Hüttel +* +* This file is part of the Reflow Oven Controller Project. +* +* The reflow oven controller is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* The Reflow Oven Control Firmware is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with the reflow oven controller project. +* If not, see . +*/ + +/** + * @addtogroup temp-profile + * @{ + */ + +#ifndef __TEMP_PROFILE_EXECUTER_H__ +#define __TEMP_PROFILE_EXECUTER_H__ + +#include +#include + +/** + * @brief Maximum command count of a temperature profile the parser will handle + */ +#define MAX_PROFILE_LENGTH 64 + +/** + * @brief Status of the temperature profile execution + */ +enum tpe_status { + TPE_OFF, /**< @brief No profile execution */ + TPE_RUNNING, /**< @brief Profile currently running */ + TPE_ABORT, /**< @brief Profile execution aborted due to event / error */ +}; + +/** + * @brief The current execution state of the temperature profile + */ +struct tpe_current_state { + enum tpe_status status; /**< @brief Execution status */ + float setpoint; /**< @brief Temperature setpoint in degrees Celsius */ + uint64_t start_timestamp; /**< @brief The millisicend tick timestamp, the profile execution was started */ + uint32_t step; /**< @brief Current execution step. Starts at 0 */ + uint32_t profile_steps; /**< @brief Number of steps (commands) in profile */ + enum pl_command_type current_command; /**< @brief The currently executed command */ +}; + +/** + * @brief Start a temperature profile execution from a file on SD card. + * @param filename Filename of the temperature profile + * @return Status. PL_RET_SUCCESS id profile was parsed and started successfully + */ +enum pl_ret_val temp_profile_executer_start(const char *filename); + +/** + * @brief Handle the profile execution + * + * The function checks if since the last time it ran, 100 ms have passed. If yes, + * it proceeds with the command execution. + * + * @note This must be periodically called. + * @return 0 if successul, negative if profile not running or aborted or temperature set and PID not configured. + */ +int temp_profile_executer_handle(void); + +/** + * @brief Get the curretn execution state of the temperature profile executer + * @warning The returned state structure is static and used internally. You must not modify it. + * @return Execution state + */ +const struct tpe_current_state *temp_profile_executer_status(void); + +/** + * @brief Stop the temperature profile execution. + * + * The profile execution is stopped and the beeper is deactivated. + * + * @return always 0. This function cannot fail. + */ +int temp_profile_executer_stop(void); + +#endif /* __TEMP_PROFILE_EXECUTER_H__ */ + +/** @} */ diff --git a/stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h b/stm-firmware/include/reflow-controller/temp-profile/temp-profile-parser.h similarity index 100% rename from stm-firmware/include/reflow-controller/config-parser/temp-profile-parser.h rename to stm-firmware/include/reflow-controller/temp-profile/temp-profile-parser.h diff --git a/stm-firmware/main.c b/stm-firmware/main.c index c7c1a65..ad7876b 100644 --- a/stm-firmware/main.c +++ b/stm-firmware/main.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include static void setup_nvic_priorities(void) diff --git a/stm-firmware/shell.c b/stm-firmware/shell.c index 3725182..65b6036 100644 --- a/stm-firmware/shell.c +++ b/stm-firmware/shell.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #ifndef GIT_VER diff --git a/stm-firmware/temp-profile-executer.c b/stm-firmware/temp-profile/temp-profile-executer.c similarity index 98% rename from stm-firmware/temp-profile-executer.c rename to stm-firmware/temp-profile/temp-profile-executer.c index 4faaecd..f701320 100644 --- a/stm-firmware/temp-profile-executer.c +++ b/stm-firmware/temp-profile/temp-profile-executer.c @@ -18,7 +18,12 @@ * If not, see . */ -#include +/** + * @addtogroup temp-profile + * @{ + */ + +#include #include #include #include @@ -288,3 +293,5 @@ int temp_profile_executer_stop(void) return 0; } + +/** @} */ diff --git a/stm-firmware/config-parser/temp-profile-parser.c b/stm-firmware/temp-profile/temp-profile-parser.c similarity index 97% rename from stm-firmware/config-parser/temp-profile-parser.c rename to stm-firmware/temp-profile/temp-profile-parser.c index b1ccb58..a6c9685 100644 --- a/stm-firmware/config-parser/temp-profile-parser.c +++ b/stm-firmware/temp-profile/temp-profile-parser.c @@ -18,7 +18,12 @@ * If not, see . */ -#include +/** + * @addtogroup temp-profile + * @{ + */ + +#include #include #include #include @@ -241,3 +246,5 @@ void temp_profile_free_command_list(SlList **list) sl_list_free_full(*list, delete_pl_command); *list = NULL; } + +/** @} */ diff --git a/stm-firmware/ui/gui.c b/stm-firmware/ui/gui.c index 3a07939..8d42138 100644 --- a/stm-firmware/ui/gui.c +++ b/stm-firmware/ui/gui.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/stm-firmware/ui/lcd.c b/stm-firmware/ui/lcd.c index 1fcd759..e20dffa 100644 --- a/stm-firmware/ui/lcd.c +++ b/stm-firmware/ui/lcd.c @@ -51,9 +51,7 @@ static void lcd_enable(void) __ASM("nop"); __ASM("nop"); __ASM("nop"); - //systick_wait_ms(10); LCD_DPORT->ODR &= ~LCD_E_MASK; - //systick_wait_ms(10); __ASM("nop"); __ASM("nop"); __ASM("nop");