♻️ Refactor HAL as singleton (#23357, #23871, #23897)

This commit is contained in:
Scott Lahteine
2022-02-17 18:50:31 -06:00
committed by Scott Lahteine
parent 428b67db31
commit 56cec9690a
81 changed files with 1976 additions and 1418 deletions

View File

@ -126,10 +126,10 @@ void GcodeSuite::M42() {
extDigitalWrite(pin, pin_status);
#ifdef ARDUINO_ARCH_STM32
// A simple I/O will be set to 0 by set_pwm_duty()
// A simple I/O will be set to 0 by hal.set_pwm_duty()
if (pin_status <= 1 && !PWM_PIN(pin)) return;
#endif
set_pwm_duty(pin, pin_status);
hal.set_pwm_duty(pin, pin_status);
}
#endif // DIRECT_PIN_CONTROL

View File

@ -38,7 +38,7 @@
#include "../sd/cardreader.h"
#include "../MarlinCore.h" // for kill
extern void dump_delay_accuracy_check();
void dump_delay_accuracy_check();
/**
* Dn: G-code for development and testing
@ -54,7 +54,7 @@ void GcodeSuite::D(const int16_t dcode) {
for (;;) { /* loop forever (watchdog reset) */ }
case 0:
HAL_reboot();
hal.reboot();
break;
case 10:
@ -74,7 +74,7 @@ void GcodeSuite::D(const int16_t dcode) {
settings.reset();
settings.save();
#endif
HAL_reboot();
hal.reboot();
} break;
case 2: { // D2 Read / Write SRAM
@ -189,12 +189,12 @@ void GcodeSuite::D(const int16_t dcode) {
SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")");
thermalManager.disable_all_heaters();
delay(1000); // Allow time to print
DISABLE_ISRS();
hal.isr_off();
// Use a low-level delay that does not rely on interrupts to function
// Do not spin forever, to avoid thermal risks if heaters are enabled and
// watchdog does not work.
for (int i = 10000; i--;) DELAY_US(1000UL);
ENABLE_ISRS();
hal.isr_on();
SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset.");
} break;