️ Refactor still needs work

Reverting #23295
This commit is contained in:
Scott Lahteine
2021-12-25 23:15:17 -06:00
parent 00e6e90648
commit 6a8b9274a3
69 changed files with 1301 additions and 1771 deletions

View File

@@ -53,18 +53,16 @@
// Public Variables
// ------------------------
uint16_t MarlinHAL::adc_result;
uint16_t HAL_adc_result;
// ------------------------
// Public functions
// ------------------------
#if ENABLED(POSTMORTEM_DEBUGGING)
extern void install_min_serial();
#endif
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
// HAL initialization task
void MarlinHAL::init() {
void HAL_init() {
// Ensure F_CPU is a constant expression.
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
// So better safe than sorry here.
@@ -105,7 +103,7 @@ void MarlinHAL::init() {
}
// HAL idle task
void MarlinHAL::idletask() {
void HAL_idletask() {
#if HAS_SHARED_MEDIA
// Stm32duino currently doesn't have a "loop/idle" method
CDC_resume_receive();
@@ -113,9 +111,9 @@ void MarlinHAL::idletask() {
#endif
}
void MarlinHAL::reboot() { NVIC_SystemReset(); }
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
uint8_t MarlinHAL::get_reset_source() {
uint8_t HAL_get_reset_source() {
return
#ifdef RCC_FLAG_IWDGRST // Some sources may not exist...
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG :
@@ -139,14 +137,24 @@ uint8_t MarlinHAL::get_reset_source() {
;
}
void MarlinHAL::clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
void HAL_reboot() { NVIC_SystemReset(); }
void _delay_ms(const int delay_ms) { delay(delay_ms); }
extern "C" {
extern unsigned int _ebss; // end of bss section
}
// ------------------------
// ADC
// ------------------------
// TODO: Make sure this doesn't cause any delay
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
WEAK void flashFirmware(const int16_t) { hal.reboot(); }
WEAK void flashFirmware(const int16_t) { HAL_reboot(); }
// Maple Compatibility
volatile uint32_t systick_uptime_millis = 0;