diff --git a/Marlin/src/HAL/HAL_AVR/HAL.cpp b/Marlin/src/HAL/HAL_AVR/HAL.cpp index c240c787ac..902b4cf1a2 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.cpp +++ b/Marlin/src/HAL/HAL_AVR/HAL.cpp @@ -67,6 +67,22 @@ // Public functions // -------------------------------------------------------------------------- +void HAL_init(void) { + // Init Servo Pins + #if PIN_EXISTS(SERVO0) + OUT_WRITE(SERVO0_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO1) + OUT_WRITE(SERVO1_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO2) + OUT_WRITE(SERVO2_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO3) + OUT_WRITE(SERVO3_PIN, LOW); + #endif +} + #if ENABLED(SDSUPPORT) #include "../../sd/SdFatUtil.h" diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index c6d2137c2f..ec88eac67d 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -109,6 +109,8 @@ typedef int8_t pin_t; // Public functions // -------------------------------------------------------------------------- +void HAL_init(void); + //void cli(void); //void _delay_ms(const int delay); diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h index 27855da018..4abbc40e00 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.h +++ b/Marlin/src/HAL/HAL_DUE/HAL.h @@ -153,7 +153,6 @@ void noTone(const pin_t _pin); // Enable hooks into idle and setup for HAL #define HAL_IDLETASK 1 -#define HAL_INIT 1 void HAL_idletask(void); void HAL_init(void); diff --git a/Marlin/src/HAL/HAL_ESP32/HAL.h b/Marlin/src/HAL/HAL_ESP32/HAL.h index 9e4ab78a9a..403f7bb7a2 100644 --- a/Marlin/src/HAL/HAL_ESP32/HAL.h +++ b/Marlin/src/HAL/HAL_ESP32/HAL.h @@ -123,7 +123,6 @@ void HAL_adc_start_conversion(uint8_t adc_pin); // Enable hooks into idle and setup for HAL #define HAL_IDLETASK 1 -#define HAL_INIT 1 #define BOARD_INIT() HAL_init_board(); void HAL_idletask(void); void HAL_init(void); diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/HAL_LINUX/HAL.h index bf537293e5..935f0661d0 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.h +++ b/Marlin/src/HAL/HAL_LINUX/HAL.h @@ -82,7 +82,9 @@ extern HalSerial usb_serial; #define ENABLE_ISRS() #define DISABLE_ISRS() -//Utility functions +inline void HAL_init(void) { } + +// Utility functions int freeMemory(void); // SPI: Extended functions which take a channel number (hardware SPI only) diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 5a11dfd671..c88f201774 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -27,9 +27,8 @@ */ #define CPU_32_BIT -#define HAL_INIT -void HAL_init(); +void HAL_init(void); #include #include diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index 86e7b5f996..6a734c5416 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -48,9 +48,9 @@ void SysTick_Callback() { disk_timerproc(); } -void HAL_init() { +void HAL_init(void) { - // Support the 4 LEDs some LPC176x boards have + // Init LEDs #if PIN_EXISTS(LED) SET_DIR_OUTPUT(LED_PIN); WRITE_PIN_CLR(LED_PIN); @@ -74,6 +74,20 @@ void HAL_init() { } #endif + // Init Servo Pins + #if PIN_EXISTS(SERVO0) + OUT_WRITE(SERVO0_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO1) + OUT_WRITE(SERVO1_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO2) + OUT_WRITE(SERVO2_PIN, LOW); + #endif + #if PIN_EXISTS(SERVO3) + OUT_WRITE(SERVO3_PIN, LOW); + #endif + //debug_frmwrk_init(); //_DBG("\n\nDebug running\n"); // Initialise the SD card chip select pins as soon as possible diff --git a/Marlin/src/HAL/HAL_STM32/HAL.h b/Marlin/src/HAL/HAL_STM32/HAL.h index bc0ad10115..1cd8c7fa6e 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.h +++ b/Marlin/src/HAL/HAL_STM32/HAL.h @@ -151,7 +151,6 @@ extern uint16_t HAL_adc_result; #define __bss_end __bss_end__ // Enable hooks into setup for HAL -#define HAL_INIT 1 void HAL_init(void); /** clear reset reason */ diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index 8ad09e64d7..ac0dd88d79 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -117,9 +117,8 @@ #define NUM_SERIAL 1 #endif -// Use HAL_init() to set interrupt grouping. -#define HAL_INIT -void HAL_init(); +// Set interrupt grouping for this MCU +void HAL_init(void); /** * TODO: review this to return 1 for pins that are not analog input diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.h b/Marlin/src/HAL/HAL_STM32F4/HAL.h index 4f621e348a..b381a67623 100644 --- a/Marlin/src/HAL/HAL_STM32F4/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F4/HAL.h @@ -158,6 +158,8 @@ extern uint16_t HAL_adc_result; // Memory related #define __bss_end __bss_end__ +inline void HAL_init(void) { } + /** clear reset reason */ void HAL_clear_reset_source (void); diff --git a/Marlin/src/HAL/HAL_STM32F7/HAL.h b/Marlin/src/HAL/HAL_STM32F7/HAL.h index 729547e94e..5d6da6ba20 100644 --- a/Marlin/src/HAL/HAL_STM32F7/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F7/HAL.h @@ -145,6 +145,8 @@ extern uint16_t HAL_adc_result; // Memory related #define __bss_end __bss_end__ +inline void HAL_init(void) { } + /** clear reset reason */ void HAL_clear_reset_source (void); diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h index dbc75540b3..2bd6fdd22e 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h @@ -89,6 +89,8 @@ typedef int8_t pin_t; #undef pgm_read_word #define pgm_read_word(addr) (*((uint16_t*)(addr))) +inline void HAL_init(void) { } + // Clear the reset reason void HAL_clear_reset_source(void); diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h index 9ead7405a7..223ad8499d 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h @@ -97,6 +97,8 @@ typedef int8_t pin_t; #undef pgm_read_word #define pgm_read_word(addr) (*((uint16_t*)(addr))) +inline void HAL_init(void) { } + /** clear reset reason */ void HAL_clear_reset_source(void); diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 08042dd5c5..6224f95f1b 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -822,9 +822,7 @@ void stop() { */ void setup() { - #ifdef HAL_INIT - HAL_init(); - #endif + HAL_init(); #if HAS_DRIVER(L6470) L6470.init(); // setup SPI and then init chips