From 16c4f1d43c3c013fe2572025db1d789100c97821 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Mon, 4 Nov 2013 17:09:21 +0100
Subject: Increase AVRISP-MKII Clone PDI/TPI handshake to 1ms from 1us for
 targets with high /RESET line capacitance.

---
 LUFA/DoxygenPages/ChangeLog.txt              | 2 ++
 Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt
index 7746be952..70cf6cb66 100644
--- a/LUFA/DoxygenPages/ChangeLog.txt
+++ b/LUFA/DoxygenPages/ChangeLog.txt
@@ -17,6 +17,8 @@
   *   - AVRISP-MKII Clone Project PDI/TPI frequency increased from 250KHz to 2MHz as it is now stable
   *   - Fixed incorrect signature bytes returned in the DFU bootloader
   *   - Added new libUSB host Python and NodeJS application examples for the class driver GenericHID demo (thanks to Laszlo Monda)
+  *   - Increased TPI/PDI handshake delay to 1ms from 1us to support targets with high amounts of capacitance on their
+  *     /RESET lines (thanks to Paul Duke)
   *
   *  \section Sec_ChangeLog130901 Version 130901
   *  <b>New:</b>
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
index 5f48089e4..165c76903 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
@@ -52,7 +52,7 @@ void XPROGTarget_EnableTargetPDI(void)
 
 	/* Set DATA line high for at least 90ns to disable /RESET functionality */
 	PORTD |= (1 << 3);
-	_delay_us(1);
+	_delay_ms(1);
 
 	/* Set up the synchronous USART for XMEGA communications - 8 data bits, even parity, 2 stop bits */
 	UBRR1  = ((F_CPU / 2 / XPROG_HARDWARE_SPEED) - 1);
@@ -72,7 +72,7 @@ void XPROGTarget_EnableTargetTPI(void)
 	/* Set /RESET line low for at least 400ns to enable TPI functionality */
 	AUX_LINE_DDR  |=  AUX_LINE_MASK;
 	AUX_LINE_PORT &= ~AUX_LINE_MASK;
-	_delay_us(1);
+	_delay_ms(1);
 
 	/* Set Tx and XCK as outputs, Rx as input */
 	DDRD |=  (1 << 5) | (1 << 3);
-- 
cgit v1.2.3