Browse Source

HAL general support for DISABLE_JTAG option (#11211)

Some STM32-based boards may use multiplexed JTAG pins as IO. Up to now the `DISABLE_JTAG` option (defined in pins files) was only supported for AT90-based boards. This commit generalizes the code and adds support for boards based on STM32F1 and STM32F4.
Alexander Amelkin 6 years ago
parent
commit
84926b1d5a

+ 4
- 0
Marlin/src/HAL/HAL_AVR/HAL.h View File

352
 
352
 
353
 #define HAL_SENSITIVE_PINS 0, 1
353
 #define HAL_SENSITIVE_PINS 0, 1
354
 
354
 
355
+#ifdef __AVR_AT90USB1286__
356
+  #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
357
+#endif
358
+
355
 // AVR compatibility
359
 // AVR compatibility
356
 #define strtof strtod
360
 #define strtof strtod
357
 
361
 

+ 2
- 0
Marlin/src/HAL/HAL_STM32F1/HAL.h View File

249
 #define GET_PIN_MAP_INDEX(pin) pin
249
 #define GET_PIN_MAP_INDEX(pin) pin
250
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
250
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
251
 
251
 
252
+#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
253
+
252
 #endif // _HAL_STM32F1_H
254
 #endif // _HAL_STM32F1_H

+ 2
- 0
Marlin/src/HAL/HAL_STM32F4/HAL.h View File

248
 #define GET_PIN_MAP_INDEX(pin) pin
248
 #define GET_PIN_MAP_INDEX(pin) pin
249
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
249
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
250
 
250
 
251
+#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
252
+
251
 #endif // _HAL_STM32F4_H
253
 #endif // _HAL_STM32F4_H

+ 6
- 3
Marlin/src/Marlin.cpp View File

687
   #endif
687
   #endif
688
 
688
 
689
   #if ENABLED(DISABLE_JTAG)
689
   #if ENABLED(DISABLE_JTAG)
690
-    // Disable JTAG on AT90USB chips to free up pins for IO
691
-    MCUCR = 0x80;
692
-    MCUCR = 0x80;
690
+    // Disable JTAG to free up pins for IO
691
+    #ifdef JTAG_DISABLE
692
+      JTAG_DISABLE();
693
+    #else
694
+      #error "DISABLE_JTAG is not supported for the selected MCU/Board"
695
+    #endif
693
   #endif
696
   #endif
694
 
697
 
695
   #if ENABLED(FILAMENT_RUNOUT_SENSOR)
698
   #if ENABLED(FILAMENT_RUNOUT_SENSOR)

Loading…
Cancel
Save