Soft Reset via Serial or post-kill button click (#21652)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@ -58,6 +58,15 @@ void HAL_init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_reboot() {
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
while (1) { /* run out the watchdog */ }
|
||||
#else
|
||||
void (*resetFunc)() = 0; // Declare resetFunc() at address 0
|
||||
resetFunc(); // Jump to address 0
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
#include "../../sd/SdFatUtil.h"
|
||||
|
@ -135,7 +135,7 @@ void HAL_init();
|
||||
inline void HAL_clear_reset_source() { MCUSR = 0; }
|
||||
inline uint8_t HAL_get_reset_source() { return MCUSR; }
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic push
|
||||
|
@ -77,6 +77,8 @@ uint8_t HAL_get_reset_source() {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_reboot() { rstc_start_software_reset(RSTC); }
|
||||
|
||||
void _delay_ms(const int delay_ms) {
|
||||
// Todo: port for Due?
|
||||
delay(delay_ms);
|
||||
|
@ -113,7 +113,7 @@ void sei(); // Enable interrupts
|
||||
void HAL_clear_reset_source(); // clear reset reason
|
||||
uint8_t HAL_get_reset_source(); // get reset reason
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
//
|
||||
// ADC
|
||||
|
@ -141,6 +141,8 @@ void HAL_clear_reset_source() { }
|
||||
|
||||
uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); }
|
||||
|
||||
void HAL_reboot() { ESP.restart(); }
|
||||
|
||||
void _delay_ms(int delay_ms) { delay(delay_ms); }
|
||||
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
|
@ -101,7 +101,7 @@ void HAL_clear_reset_source();
|
||||
// reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(int delay);
|
||||
|
||||
|
@ -73,4 +73,6 @@ void HAL_pwm_init() {
|
||||
|
||||
}
|
||||
|
||||
void HAL_reboot() { /* Reset the application state and GPIO */ }
|
||||
|
||||
#endif // __PLAT_LINUX__
|
||||
|
@ -107,7 +107,7 @@ uint16_t HAL_adc_get_result();
|
||||
inline void HAL_clear_reset_source(void) {}
|
||||
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot(); // Reset the application state and GPIO
|
||||
|
||||
/* ---------------- Delay in cycles */
|
||||
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
|
||||
|
@ -67,7 +67,7 @@ void flashFirmware(const int16_t) {
|
||||
delay(500); // Give OS time to disconnect
|
||||
USB_Connect(false); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
NVIC_SystemReset();
|
||||
HAL_reboot();
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source(void) {
|
||||
@ -81,4 +81,6 @@ uint8_t HAL_get_reset_source(void) {
|
||||
return RST_POWER_ON;
|
||||
}
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
@ -218,4 +218,4 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255,
|
||||
void HAL_clear_reset_source(void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
@ -436,6 +436,8 @@ uint8_t HAL_get_reset_source() {
|
||||
}
|
||||
#pragma pop_macro("WDT")
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
|
||||
extern "C" {
|
||||
void * _sbrk(int incr);
|
||||
|
||||
|
@ -109,7 +109,7 @@ typedef int8_t pin_t;
|
||||
void HAL_clear_reset_source(); // clear reset reason
|
||||
uint8_t HAL_get_reset_source(); // get reset reason
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
//
|
||||
// ADC
|
||||
|
@ -133,6 +133,8 @@ uint8_t HAL_get_reset_source() {
|
||||
;
|
||||
}
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
extern "C" {
|
||||
@ -147,8 +149,8 @@ extern "C" {
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
|
||||
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
|
||||
|
||||
// Reset the system (to initiate a firmware flash)
|
||||
void flashFirmware(const int16_t) { NVIC_SystemReset(); }
|
||||
// Reset the system to initiate a firmware flash
|
||||
void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
|
||||
// Maple Compatibility
|
||||
volatile uint32_t systick_uptime_millis = 0;
|
||||
|
@ -144,7 +144,7 @@ void HAL_clear_reset_source();
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
|
@ -453,6 +453,8 @@ void analogWrite(pin_t pin, int pwm_val8) {
|
||||
analogWrite(uint8_t(pin), pwm_val8);
|
||||
}
|
||||
|
||||
void flashFirmware(const int16_t) { nvic_sys_reset(); }
|
||||
void HAL_reboot() { nvic_sys_reset(); }
|
||||
|
||||
void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
|
||||
#endif // __STM32F1__
|
||||
|
@ -207,7 +207,7 @@ void HAL_clear_reset_source();
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
|
@ -78,6 +78,8 @@ uint8_t HAL_get_reset_source() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "fastio.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define ST7920_DELAY_1 DELAY_NS(600)
|
||||
@ -93,7 +92,7 @@ void HAL_clear_reset_source();
|
||||
// Get the reason for the reset
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
|
@ -86,6 +86,8 @@ uint8_t HAL_get_reset_source() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
|
@ -101,7 +101,7 @@ void HAL_clear_reset_source();
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
inline void HAL_reboot() {} // reboot the board or restart the bootloader
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
|
@ -120,6 +120,8 @@ uint8_t HAL_get_reset_source() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
#define __bss_end _ebss
|
||||
|
||||
extern "C" {
|
||||
|
@ -121,6 +121,8 @@ void HAL_clear_reset_source();
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
|
||||
#if GCC_VERSION <= 50000
|
||||
|
Reference in New Issue
Block a user