From 172996f2b3142c68544d5fe9feb33ebcb89d5eff Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 1 Nov 2020 23:38:10 -0300 Subject: [PATCH] Fix STM32 HW Serial + EP compile (#19990) --- Marlin/src/HAL/STM32/HAL.cpp | 10 ++++++++-- Marlin/src/HAL/STM32/HAL.h | 1 + Marlin/src/HAL/STM32/usb_serial.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 83604b110..c886f9c0b 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -81,7 +81,9 @@ void HAL_init() { SetTimerInterruptPriorities(); - TERN_(EMERGENCY_PARSER, USB_Hook_init()); + #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC + USB_Hook_init(); + #endif } void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } @@ -128,8 +130,12 @@ uint16_t HAL_adc_get_result() { return HAL_adc_result; } void flashFirmware(const int16_t) { NVIC_SystemReset(); } // Maple Compatibility +volatile uint32_t systick_uptime_millis = 0; systickCallback_t systick_user_callback; void systick_attach_callback(systickCallback_t cb) { systick_user_callback = cb; } -void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); } +void HAL_SYSTICK_Callback() { + systick_uptime_millis++; + if (systick_user_callback) systick_user_callback(); +} #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index a1f7515d6..3cd138ba6 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -184,3 +184,4 @@ void flashFirmware(const int16_t); typedef void (*systickCallback_t)(void); void systick_attach_callback(systickCallback_t cb); void HAL_SYSTICK_Callback(); +extern volatile uint32_t systick_uptime_millis; diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index 2dd1bef12..25c47d694 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -21,7 +21,7 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(EMERGENCY_PARSER) +#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC #include "usb_serial.h" #include "../../feature/e_parser.h"