Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 29 Nov 2011 13:33:28 +0000 (13:33 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 29 Nov 2011 13:33:28 +0000 (13:33 +0000)
LUFA/DoxygenPages/ChangeLog.txt
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c

index 6e37c6e..28c4dc5 100644 (file)
@@ -39,6 +39,7 @@
   *  - Library Applications:
   *   - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair)
   *   - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled
   *  - Library Applications:
   *   - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair)
   *   - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled
+  *   - Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited
   *
   *  \section Sec_ChangeLog111009 Version 111009
   *  <b>New:</b>
   *
   *  \section Sec_ChangeLog111009 Version 111009
   *  <b>New:</b>
index 26ffb9f..8d74dd4 100644 (file)
@@ -146,9 +146,15 @@ void TINYNVM_DisableTPI(void)
 {
        TINYNVM_WaitWhileNVMBusBusy();
 
 {
        TINYNVM_WaitWhileNVMBusBusy();
 
-       /* Clear the NVMEN bit in the TPI STATUS register to disable TPI mode */
-       XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_STATUS_REG);
-       XPROGTarget_SendByte(0x00);
+       do
+       {
+               /* Clear the NVMEN bit in the TPI STATUS register to disable TPI mode */
+               XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_STATUS_REG);
+               XPROGTarget_SendByte(0x00);
+       
+               /* Read back the STATUS register, check to see if it took effect */
+               XPROGTarget_SendByte(TPI_CMD_SLDCS | PDI_RESET_REG);
+       } while (XPROGTarget_ReceiveByte() != 0x00);
 
        XPROGTarget_DisableTargetTPI();
 }
 
        XPROGTarget_DisableTargetTPI();
 }