aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-03-16 11:47:11 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-03-16 11:47:11 +0000
commit39d56aeffecdd50d1e413c8da6edbe8485d5ac29 (patch)
tree5092eb389b122c8aac74c878a7c7397a086c9c67 /Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
parentb2bdfe437762a9a88b4de1cada7f794b255b0d97 (diff)
downloadlufa-39d56aeffecdd50d1e413c8da6edbe8485d5ac29.tar.gz
lufa-39d56aeffecdd50d1e413c8da6edbe8485d5ac29.tar.bz2
lufa-39d56aeffecdd50d1e413c8da6edbe8485d5ac29.zip
Fixed PDI programming mode in the AVRISP programmer project not exiting programming mode correctly (clear target Reset key twice, set /RESET pin to pullup).
Add newlines to the MIDI event printf() statements in the MIDI host demos.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index 805eaa31f..08936a202 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -119,7 +119,7 @@ static void XPROGProtocol_EnterXPROGMode(void)
{
/* Enable PDI programming mode with the attached target */
XPROGTarget_EnableTargetPDI();
-
+
/* Store the RESET key into the RESET PDI register to keep the XMEGA in reset */
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
XPROGTarget_SendByte(PDI_RESET_KEY);
@@ -170,14 +170,22 @@ static void XPROGProtocol_LeaveXPROGMode(void)
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
{
+ XMEGANVM_WaitWhileNVMBusBusy();
+
/* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
XPROGTarget_SendByte(0x00);
+
+ /* Clear /RESET key twice (for some reason this needs to be done twice to take effect) */
+ XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
+ XPROGTarget_SendByte(0x00);
XPROGTarget_DisableTargetPDI();
}
else
{
+ TINYNVM_WaitWhileNVMBusBusy();
+
/* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */
XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
XPROGTarget_SendByte(0x00);