From df40cc8186f9c2da175dcd8e4953185eded87092 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Fri, 22 Nov 2024 14:18:51 -0500 Subject: [PATCH 1/2] return reset reason as string of one flag --- .../firmware/motor_hardware.h | 7 ++ .../firmware/motor_policy.hpp | 7 ++ .../thermocycler-gen2/gcodes.hpp | 37 ++++++++++ .../thermocycler-gen2/host_comms_task.hpp | 53 +++++++++++++- .../thermocycler-gen2/messages.hpp | 19 +++-- .../thermocycler-gen2/motor_task.hpp | 11 +++ .../firmware/motor_task/motor_hardware.c | 69 +++++++++++++++++++ .../firmware/motor_task/motor_policy.cpp | 5 ++ 8 files changed, 201 insertions(+), 7 deletions(-) diff --git a/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h b/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h index b55888f4..88a2fecd 100644 --- a/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h +++ b/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h @@ -184,6 +184,13 @@ void motor_hardware_seal_switch_set_disarmed(); */ void motor_hardware_seal_switch_interrupt(); +/** + * @brief Returns the reason saved upon startup for the last + * reset of the software. + * @return a string describing the reason for reset. + * */ +char* motor_hardware_reset_reason(); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp b/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp index 05f9ed16..48646393 100644 --- a/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp +++ b/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp @@ -186,6 +186,13 @@ class MotorPolicy { */ [[nodiscard]] auto seal_switches_are_shared() const -> bool; + /** + * @brief Returns the reason saved upon startup for the last + * reset of the software. + * @return a string describing the reason for reset. + * */ + [[nodiscard]] auto last_reset_reason() const -> char*; + /** * @brief Call the seal callback function * diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp index b2c28a47..ce901eb2 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp @@ -146,6 +146,43 @@ struct GetSystemInfo { } }; +struct GetResetReason { + /* + * M114- GetResetReason retrieves the value of the RCC reset flag + * that was captured at the beginning of the hardware setup + * */ + using ParseResult = std::optional; + static constexpr auto prefix = std::array{'M', '1', '1', '4'}; + + template + requires std::forward_iterator && + std::sized_sentinel_for + static auto write_response_into(InputIt buf, InLimit limit, char* reason) + -> InputIt { + int res = 0; + res = snprintf(&*buf, (limit - buf), + "M114 Last Reset Reason: %s OK\n", reason); + if (res <= 0) { + return buf; + } + return buf + res; + } + template + requires std::forward_iterator && + std::sized_sentinel_for + static auto parse(const InputIt& input, Limit limit) + -> std::pair { + auto working = prefix_matches(input, limit, prefix); + if (working == input) { + return std::make_pair(ParseResult(), input); + } + if (working != limit && !std::isspace(*working)) { + return std::make_pair(ParseResult(), input); + } + return std::make_pair(ParseResult(GetResetReason()), working); + } +}; + struct SetSerialNumber { /* ** Set Serial Number uses a random gcode, M996, adjacent to the firmware diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp index 4cb1523c..b72bfc6c 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp @@ -52,7 +52,7 @@ class HostCommsTask { gcode::GetOffsetConstants, gcode::OpenLid, gcode::CloseLid, gcode::LiftPlate, gcode::DeactivateAll, gcode::GetBoardRevision, gcode::GetLidSwitches, gcode::GetFrontButton, gcode::SetLidFans, - gcode::SetLightsDebug>; + gcode::SetLightsDebug, gcode::GetResetReason>; using AckOnlyCache = AckCache<8, gcode::EnterBootloader, gcode::SetSerialNumber, gcode::ActuateSolenoid, gcode::ActuateLidStepperDebug, @@ -72,6 +72,7 @@ class HostCommsTask { using GetLidStatusCache = AckCache<8, gcode::GetLidStatus>; using GetOffsetConstantsCache = AckCache<8, gcode::GetOffsetConstants>; using SealStepperDebugCache = AckCache<8, gcode::ActuateSealStepperDebug>; + using GetResetReasonCache = AckCache<8, gcode::GetResetReason>; // This is a two-stage message since both the Plate and Lid tasks have // to respond. using GetThermalPowerCache = AckCache<8, gcode::GetThermalPowerDebug, @@ -115,6 +116,8 @@ class HostCommsTask { // NOLINTNEXTLINE(readability-redundant-member-init) deactivate_all_cache(), // NOLINTNEXTLINE(readability-redundant-member-init) + get_reset_reason_cache(), + // NOLINTNEXTLINE(readability-redundant-member-init) get_switch_cache() {} HostCommsTask(const HostCommsTask& other) = delete; auto operator=(const HostCommsTask& other) -> HostCommsTask& = delete; @@ -255,7 +258,8 @@ class HostCommsTask { return errors::write_into(tx_into, tx_limit, msg.with_error); } else { - return cache_element.write_response_into(tx_into, tx_limit); + return cache_element.write_response_into( + tx_into, tx_limit); } }, cache_entry); @@ -460,6 +464,28 @@ class HostCommsTask { cache_entry); } + template + requires std::forward_iterator && + std::sized_sentinel_for + auto visit_message(const messages::GetResetReasonResponse& response, + InputIt tx_into, InputLimit tx_limit) -> InputIt { + auto cache_entry = + get_reset_reason_cache.remove_if_present(response.responding_to_id); + return std::visit( + [tx_into, tx_limit, response](auto cache_element) { + using T = std::decay_t; + if constexpr (std::is_same_v) { + return errors::write_into( + tx_into, tx_limit, + errors::ErrorCode::BAD_MESSAGE_ACKNOWLEDGEMENT); + } else { + return cache_element.write_response_into(tx_into, tx_limit, + response.reason); + } + }, + cache_entry); + } + template requires std::forward_iterator && std::sized_sentinel_for @@ -1232,6 +1258,28 @@ class HostCommsTask { return std::make_pair(true, tx_into); } + template + requires std::forward_iterator && + std::sized_sentinel_for + auto visit_gcode(const gcode::GetResetReason& gcode, InputIt tx_into, + InputLimit tx_limit) -> std::pair { + auto id = get_reset_reason_cache.add(gcode); + if (id == 0) { + return std::make_pair( + false, errors::write_into(tx_into, tx_limit, + errors::ErrorCode::GCODE_CACHE_FULL)); + } + auto message = messages::GetResetReasonMessage{.id = id}; + if (!task_registry->motor->get_message_queue().try_send( + message, TICKS_TO_WAIT_ON_SEND)) { + auto wrote_to = errors::write_into( + tx_into, tx_limit, errors::ErrorCode::INTERNAL_QUEUE_FULL); + get_reset_reason_cache.remove_if_present(id); + return std::make_pair(false, wrote_to); + } + return std::make_pair(true, tx_into); + } + template requires std::forward_iterator && std::sized_sentinel_for @@ -1524,6 +1572,7 @@ class HostCommsTask { SealStepperDebugCache seal_stepper_debug_cache; GetThermalPowerCache get_thermal_power_cache; DeactivateAllCache deactivate_all_cache; + GetResetReasonCache get_reset_reason_cache; GetSwitchCache get_switch_cache; bool may_connect_latch = true; }; diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp index 00685eec..b7d81c28 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp @@ -353,6 +353,15 @@ struct GetLidStatusResponse { motor_util::SealStepper::Status seal; }; +struct GetResetReasonMessage { + uint32_t id; +}; + +struct GetResetReasonResponse { + uint32_t responding_to_id; + char* reason; +}; + struct OpenLidMessage { uint32_t id; }; @@ -421,9 +430,9 @@ using HostCommsMessage = ::std::variant< ForceUSBDisconnectMessage, GetSystemInfoResponse, GetLidTemperatureDebugResponse, GetPlateTemperatureDebugResponse, GetPlateTempResponse, GetLidTempResponse, GetSealDriveStatusResponse, - GetLidStatusResponse, GetPlatePowerResponse, GetLidPowerResponse, - GetOffsetConstantsResponse, SealStepperDebugResponse, DeactivateAllResponse, - GetLidSwitchesResponse, GetFrontButtonResponse>; + GetLidStatusResponse, GetResetReasonResponse, GetPlatePowerResponse, + GetLidPowerResponse, GetOffsetConstantsResponse, SealStepperDebugResponse, + DeactivateAllResponse, GetLidSwitchesResponse, GetFrontButtonResponse>; using ThermalPlateMessage = ::std::variant; + GetResetReasonMessage, OpenLidMessage, CloseLidMessage, PlateLiftMessage, + FrontButtonPressMessage, GetLidSwitchesMessage>; }; // namespace messages diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/motor_task.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/motor_task.hpp index b8589adb..53dd3c5d 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/motor_task.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/motor_task.hpp @@ -580,6 +580,17 @@ class MotorTask { messages::HostCommsMessage(response))); } + template + auto visit_message(const messages::GetResetReasonMessage& msg, + Policy& policy) -> void { + auto reason = policy.last_reset_reason(); + + auto response = messages::GetResetReasonResponse{ + .responding_to_id = msg.id, .reason = reason}; + static_cast(_task_registry->comms->get_message_queue().try_send( + messages::HostCommsMessage(response))); + } + template auto visit_message(const messages::OpenLidMessage& msg, Policy& policy) -> void { diff --git a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c index b4a78fc5..148128cb 100644 --- a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c +++ b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c @@ -193,11 +193,14 @@ static void init_dac1(DAC_HandleTypeDef* hdac); static void init_tim2(TIM_HandleTypeDef* htim); static void init_tim6(TIM_HandleTypeDef* htim); static bool lid_active(); +static void save_reset_reason(); +static char* reset_reason; // ---------------------------------------------------------------------------- // Public function implementation void motor_hardware_setup(const motor_hardware_callbacks* callbacks) { + save_reset_reason(); configASSERT(callbacks != NULL); configASSERT(callbacks->lid_stepper_complete != NULL); configASSERT(callbacks->seal_stepper_tick != NULL); @@ -407,6 +410,10 @@ void motor_hardware_seal_switch_set_disarmed() { _motor_hardware.seal.retraction_switch_armed = false; } +char* motor_hardware_reset_reason() { + return reset_reason; +} + // ---------------------------------------------------------------------------- // Local function implementation @@ -623,6 +630,68 @@ static bool lid_active() { != HAL_TIM_CHANNEL_STATE_READY; } +static void save_reset_reason() { + // check various reset flags to see if the HAL RCC + // reset flag matches any of them + + // high speed internal clock ready + if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY)) { + reset_reason = "hsi clock ready"; + } + // high speed external clock ready + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) { + reset_reason = "hse clock ready"; + } + // main phase-locked loop clock ready + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY)) { + reset_reason = "pll clock ready"; + } + // hsi48 clock ready if applicable ? + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSI48RDY)) { + reset_reason = "hsi 48 clock ready"; + } + // low-speed external clock ready + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY)) { + reset_reason = "lsi clock ready"; + } + // lse clock security system failure + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSECSSD)) { + reset_reason = "lse security failure"; + } + // low-speed internal clock ready + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY)) { + reset_reason = "lsi clock ready"; + } + // brown out + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST)) { + reset_reason = "brown out"; + } + // option byte-loader reset + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_OBLRST)) { + reset_reason = "oblrst"; + } + // pin reset ? + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)) { + reset_reason = "pin reset"; + } + // software reset + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) { + reset_reason = "software reset"; + } + // independent watchdog + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) { + reset_reason = "independent watchdog"; + } + // window watchdog + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) { + reset_reason = "window watchdog"; + } + // low power reset + else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST)) { + reset_reason = "low power"; + } +} + // ---------------------------------------------------------------------------- // Overwritten HAL functions diff --git a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp index be9cb640..9817ac08 100644 --- a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp +++ b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp @@ -151,4 +151,9 @@ auto MotorPolicy::seal_switch_set_disarmed() -> void { // NOLINTNEXTLINE(readability-convert-member-functions-to-static) [[nodiscard]] auto MotorPolicy::seal_switches_are_shared() const -> bool { return _shared_seal_switch_lines; +} + +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) +[[nodiscard]] auto MotorPolicy::last_reset_reason() const -> char* { + return motor_hardware_reset_reason(); } \ No newline at end of file From ddaaa771e561b959a16e4e114ed4c6579ed11f81 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Fri, 22 Nov 2024 16:59:01 -0500 Subject: [PATCH 2/2] change to hexadecimal representation to include multiple flags --- .../firmware/motor_hardware.h | 2 +- .../firmware/motor_policy.hpp | 2 +- .../thermocycler-gen2/gcodes.hpp | 7 +- .../thermocycler-gen2/host_comms_task.hpp | 3 +- .../thermocycler-gen2/messages.hpp | 2 +- .../firmware/motor_task/motor_hardware.c | 70 ++++++++++++++----- .../firmware/motor_task/motor_policy.cpp | 2 +- 7 files changed, 61 insertions(+), 27 deletions(-) diff --git a/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h b/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h index 88a2fecd..579a6aae 100644 --- a/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h +++ b/stm32-modules/include/thermocycler-gen2/firmware/motor_hardware.h @@ -189,7 +189,7 @@ void motor_hardware_seal_switch_interrupt(); * reset of the software. * @return a string describing the reason for reset. * */ -char* motor_hardware_reset_reason(); +uint16_t motor_hardware_reset_reason(); #ifdef __cplusplus } // extern "C" diff --git a/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp b/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp index 48646393..b633ee37 100644 --- a/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp +++ b/stm32-modules/include/thermocycler-gen2/firmware/motor_policy.hpp @@ -191,7 +191,7 @@ class MotorPolicy { * reset of the software. * @return a string describing the reason for reset. * */ - [[nodiscard]] auto last_reset_reason() const -> char*; + [[nodiscard]] auto last_reset_reason() const -> uint16_t; /** * @brief Call the seal callback function diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp index ce901eb2..40e58c73 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp @@ -157,11 +157,12 @@ struct GetResetReason { template requires std::forward_iterator && std::sized_sentinel_for - static auto write_response_into(InputIt buf, InLimit limit, char* reason) + static auto write_response_into(InputIt buf, InLimit limit, uint16_t reason) -> InputIt { int res = 0; - res = snprintf(&*buf, (limit - buf), - "M114 Last Reset Reason: %s OK\n", reason); + // print a hexadecimal representation of the reset flags + res = snprintf(&*buf, (limit - buf), "M114 Last Reset Reason: %X OK\n", + reason); if (res <= 0) { return buf; } diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp index b72bfc6c..175d79f8 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/host_comms_task.hpp @@ -258,8 +258,7 @@ class HostCommsTask { return errors::write_into(tx_into, tx_limit, msg.with_error); } else { - return cache_element.write_response_into( - tx_into, tx_limit); + return cache_element.write_response_into(tx_into, tx_limit); } }, cache_entry); diff --git a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp index b7d81c28..b135d72e 100644 --- a/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp +++ b/stm32-modules/include/thermocycler-gen2/thermocycler-gen2/messages.hpp @@ -359,7 +359,7 @@ struct GetResetReasonMessage { struct GetResetReasonResponse { uint32_t responding_to_id; - char* reason; + uint16_t reason; }; struct OpenLidMessage { diff --git a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c index 148128cb..843f374d 100644 --- a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c +++ b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_hardware.c @@ -184,6 +184,38 @@ static motor_hardware_t _motor_hardware = { } }; +enum RCC_FLAGS { + NONE, + // high speed internal clock ready + HSIRDY, // = 1 + // high speed external clock ready + HSERDY, // = 2 + // main phase-locked loop clock ready + PLLRDY, // = 3 + // hsi48 clock ready + HSI48RDY, // = 4 + // low-speed external clock ready + LSERDY, // = 5 + // lse clock security system failure + LSECSSD, // = 6 + // low-speed internal clock ready + LSIRDY, // = 7 + // brown out + BORRST, // = 8 + // option byte-loader reset + OBLRST, // = 9 + // pin reset + PINRST, // = 10 + // software reset + SFTRST, // = 11 + // independent watchdog + IWDGRST, // = 12 + // window watchdog + WWDGRST, // = 13 + // low power reset + LPWRRST, // = 14 +}; + // ---------------------------------------------------------------------------- // Local function declaration @@ -194,7 +226,8 @@ static void init_tim2(TIM_HandleTypeDef* htim); static void init_tim6(TIM_HandleTypeDef* htim); static bool lid_active(); static void save_reset_reason(); -static char* reset_reason; +//static char* reset_reason; +uint16_t reset_reason; // ---------------------------------------------------------------------------- // Public function implementation @@ -410,7 +443,7 @@ void motor_hardware_seal_switch_set_disarmed() { _motor_hardware.seal.retraction_switch_armed = false; } -char* motor_hardware_reset_reason() { +uint16_t motor_hardware_reset_reason() { return reset_reason; } @@ -633,62 +666,63 @@ static bool lid_active() { static void save_reset_reason() { // check various reset flags to see if the HAL RCC // reset flag matches any of them + reset_reason = 0; // high speed internal clock ready if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY)) { - reset_reason = "hsi clock ready"; + reset_reason |= HSIRDY; } // high speed external clock ready else if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) { - reset_reason = "hse clock ready"; + reset_reason |= HSERDY; } // main phase-locked loop clock ready else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY)) { - reset_reason = "pll clock ready"; + reset_reason |= PLLRDY; } - // hsi48 clock ready if applicable ? + // hsi48 clock ready else if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSI48RDY)) { - reset_reason = "hsi 48 clock ready"; + reset_reason |= HSI48RDY; } // low-speed external clock ready else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY)) { - reset_reason = "lsi clock ready"; + reset_reason |= LSERDY; } // lse clock security system failure else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSECSSD)) { - reset_reason = "lse security failure"; + reset_reason |= LSECSSD; } // low-speed internal clock ready else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY)) { - reset_reason = "lsi clock ready"; + reset_reason |= LSIRDY; } // brown out else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST)) { - reset_reason = "brown out"; + reset_reason |= BORRST; } // option byte-loader reset else if (__HAL_RCC_GET_FLAG(RCC_FLAG_OBLRST)) { - reset_reason = "oblrst"; + reset_reason |= OBLRST; } - // pin reset ? + // pin reset else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)) { - reset_reason = "pin reset"; + reset_reason |= PINRST; } // software reset else if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) { - reset_reason = "software reset"; + reset_reason |= SFTRST; } // independent watchdog else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) { - reset_reason = "independent watchdog"; + reset_reason |= IWDGRST; } // window watchdog else if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) { - reset_reason = "window watchdog"; + reset_reason |= WWDGRST; } // low power reset else if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST)) { - reset_reason = "low power"; + reset_reason |= LPWRRST; } } diff --git a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp index 9817ac08..713f26c0 100644 --- a/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp +++ b/stm32-modules/thermocycler-gen2/firmware/motor_task/motor_policy.cpp @@ -154,6 +154,6 @@ auto MotorPolicy::seal_switch_set_disarmed() -> void { } // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -[[nodiscard]] auto MotorPolicy::last_reset_reason() const -> char* { +[[nodiscard]] auto MotorPolicy::last_reset_reason() const -> uint16_t { return motor_hardware_reset_reason(); } \ No newline at end of file