summaryrefslogtreecommitdiff
path: root/platforms/avr/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'platforms/avr/platform.c')
-rw-r--r--platforms/avr/platform.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/platforms/avr/platform.c b/platforms/avr/platform.c
index 3e35b4fe4c..37decb6ec8 100644
--- a/platforms/avr/platform.c
+++ b/platforms/avr/platform.c
@@ -16,6 +16,17 @@
#include "platform_deps.h"
+static void disable_jtag(void) {
+// To use PF4-7 (PC2-5 on ATmega32A), disable JTAG by writing JTD bit twice within four cycles.
+#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ MCUCR |= _BV(JTD);
+ MCUCR |= _BV(JTD);
+#elif defined(__AVR_ATmega32A__)
+ MCUCSR |= _BV(JTD);
+ MCUCSR |= _BV(JTD);
+#endif
+}
+
void platform_setup(void) {
- // do nothing
+ disable_jtag();
}