diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index 84cdc865f0..5a7f41ed2d 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -352,6 +352,10 @@ inline void HAL_adc_init(void) { #define HAL_SENSITIVE_PINS 0, 1 +#ifdef __AVR_AT90USB1286__ + #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) +#endif + // AVR compatibility #define strtof strtod diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index 8a436d999a..bf925c0a14 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -249,4 +249,6 @@ void HAL_enable_AdcFreerun(void); #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) +#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) + #endif // _HAL_STM32F1_H diff --git a/Marlin/src/HAL/HAL_STM32F4/HAL.h b/Marlin/src/HAL/HAL_STM32F4/HAL.h index c7565e47ab..6d51f6e776 100644 --- a/Marlin/src/HAL/HAL_STM32F4/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F4/HAL.h @@ -248,4 +248,6 @@ void HAL_enable_AdcFreerun(void); #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) +#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) + #endif // _HAL_STM32F4_H diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index ba9a0862da..6d787fac48 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -687,9 +687,12 @@ void setup() { #endif #if ENABLED(DISABLE_JTAG) - // Disable JTAG on AT90USB chips to free up pins for IO - MCUCR = 0x80; - MCUCR = 0x80; + // Disable JTAG to free up pins for IO + #ifdef JTAG_DISABLE + JTAG_DISABLE(); + #else + #error "DISABLE_JTAG is not supported for the selected MCU/Board" + #endif #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR)