Use "reset reason" defines (#18462)

This commit is contained in:
Giuliano Zaro 2020-06-29 08:02:36 +02:00 committed by GitHub
parent 69b5b91c91
commit bfcf7ac2fd
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -277,9 +277,8 @@ void HAL_clear_reset_source() { }
/** /**
* TODO: Check this and change or remove. * 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); } void _delay_ms(const int delay_ms) { delay(delay_ms); }

View file

@ -936,11 +936,11 @@ void setup() {
// Check startup - does nothing if bootloader sets MCUSR to 0 // Check startup - does nothing if bootloader sets MCUSR to 0
const byte mcu = HAL_get_reset_source(); const byte mcu = HAL_get_reset_source();
if (mcu & 1) SERIAL_ECHOLNPGM(STR_POWERUP); if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
if (mcu & 2) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
if (mcu & 4) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
if (mcu & 8) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
if (mcu & 32) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
HAL_clear_reset_source(); HAL_clear_reset_source();
serialprintPGM(GET_TEXT(MSG_MARLIN)); serialprintPGM(GET_TEXT(MSG_MARLIN));