♻️ Refactor HAL as singleton (#23295)
This commit is contained in:
@@ -790,7 +790,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#endif
|
||||
|
||||
// Run HAL idle tasks
|
||||
TERN_(HAL_IDLETASK, HAL_idletask());
|
||||
hal.idletask();
|
||||
|
||||
// Check network connection
|
||||
TERN_(HAS_ETHERNET, ethernet.check());
|
||||
@@ -929,7 +929,7 @@ void minkill(const bool steppers_off/*=false*/) {
|
||||
watchdog_refresh();
|
||||
|
||||
// Reboot the board
|
||||
HAL_reboot();
|
||||
hal.reboot();
|
||||
|
||||
#else
|
||||
|
||||
@@ -1041,7 +1041,7 @@ inline void tmc_standby_setup() {
|
||||
* • L64XX Stepper Drivers (SPI)
|
||||
* • Stepper Driver Reset: DISABLE
|
||||
* • TMC Stepper Drivers (SPI)
|
||||
* • Run BOARD_INIT if defined
|
||||
* • Run hal.init_board() for additional pins setup
|
||||
* • ESP WiFi
|
||||
* - Get the Reset Reason and report it
|
||||
* - Print startup messages and diagnostics
|
||||
@@ -1119,8 +1119,8 @@ void setup() {
|
||||
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = HAL_get_reset_source();
|
||||
HAL_clear_reset_source();
|
||||
const byte mcu = hal.get_reset_source();
|
||||
hal.clear_reset_source();
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
auto log_current_ms = [&](PGM_P const msg) {
|
||||
@@ -1181,23 +1181,20 @@ void setup() {
|
||||
JTAGSWD_RESET();
|
||||
#endif
|
||||
|
||||
#if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
delay(10);
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif defined(JTAG_DISABLE)
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#else
|
||||
#error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
|
||||
#endif
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE)
|
||||
delay(10);
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#endif
|
||||
|
||||
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
|
||||
|
||||
SETUP_RUN(HAL_init());
|
||||
SETUP_RUN(hal.init());
|
||||
|
||||
// Init and disable SPI thermocouples; this is still needed
|
||||
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0))
|
||||
@@ -1243,19 +1240,16 @@ void setup() {
|
||||
SETUP_RUN(tmc_init_cs_pins());
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_INIT
|
||||
SETUP_LOG("BOARD_INIT");
|
||||
BOARD_INIT();
|
||||
#endif
|
||||
SETUP_RUN(hal.init_board());
|
||||
|
||||
SETUP_RUN(esp_wifi_init());
|
||||
|
||||
// Report Reset Reason
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_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);
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
|
||||
// Identify myself as Marlin x.x.x
|
||||
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
|
||||
@@ -1266,7 +1260,7 @@ void setup() {
|
||||
);
|
||||
#endif
|
||||
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
|
||||
// Some HAL need precise delay adjustment
|
||||
calibrate_delay_loop();
|
||||
@@ -1538,7 +1532,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call
|
||||
SETUP_RUN(watchdog_init()); // Reinit watchdog after hal.get_reset_source call
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||
|
||||
Reference in New Issue
Block a user