From f39d6089e29379ee4ee1d8a3a5026ef66ebc5e49 Mon Sep 17 00:00:00 2001 From: GMagician Date: Sun, 28 Jun 2020 17:28:09 +0200 Subject: [PATCH] Use predefined "define" for reset reason Not sure but in esp32 function 'rtc_get_reset_reason' maybe doesn't return Marlin compatible codes: read https://github.com/espressif/arduino-esp32/issues/449#issuecomment-309022135 --- Marlin/src/HAL/STM32F1/HAL.cpp | 3 +-- Marlin/src/MarlinCore.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 658882943845..202d3bd5be4e 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -277,9 +277,8 @@ void HAL_clear_reset_source() { } /** * TODO: Check this and change or remove. - * currently returns 1 that's equal to poweron reset. */ -uint8_t HAL_get_reset_source() { return 1; } +uint8_t HAL_get_reset_source() { return RST_POWER_ON; } void _delay_ms(const int delay_ms) { delay(delay_ms); } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 66d3c78ca464..749db78a0af8 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -936,11 +936,11 @@ void setup() { // Check startup - does nothing if bootloader sets MCUSR to 0 const byte mcu = HAL_get_reset_source(); - if (mcu & 1) SERIAL_ECHOLNPGM(STR_POWERUP); - if (mcu & 2) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); - if (mcu & 4) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); - if (mcu & 8) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); - if (mcu & 32) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); + if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); + if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); + if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); + if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); + if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); HAL_clear_reset_source(); serialprintPGM(GET_TEXT(MSG_MARLIN));