Added support to the MIDI Class drivers for packed data, where multiple MIDI events...
[pub/USBasp.git] / Projects / AVRISP-MKII / Lib / XPROG / XPROGProtocol.c
index 5275cca..9c6ee7e 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -124,6 +124,10 @@ static void XPROGProtocol_EnterXPROGMode(void)
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(PDI_RESET_KEY);\r
 \r
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(PDI_RESET_KEY);\r
 \r
+               /* Lower direction change guard time to 8 USART bits */\r
+               XPROGTarget_SendByte(PDI_CMD_STCS | PDI_CTRL_REG);      \r
+               XPROGTarget_SendByte(0x04);\r
+\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(PDI_CMD_KEY);      \r
                for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(PDI_CMD_KEY);      \r
                for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)\r
@@ -134,10 +138,13 @@ static void XPROGProtocol_EnterXPROGMode(void)
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
-       #if 0\r
                /* Enable TPI programming mode with the attached target */\r
                XPROGTarget_EnableTargetTPI();\r
                \r
                /* Enable TPI programming mode with the attached target */\r
                XPROGTarget_EnableTargetTPI();\r
                \r
+               /* Lower direction change guard time to 8 USART bits */\r
+               XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);\r
+               XPROGTarget_SendByte(0x04);             \r
+               \r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(TPI_CMD_SKEY);     \r
                for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(TPI_CMD_SKEY);     \r
                for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)\r
@@ -145,8 +152,6 @@ static void XPROGProtocol_EnterXPROGMode(void)
 \r
                /* Wait until the NVM bus becomes active */\r
                NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
 \r
                /* Wait until the NVM bus becomes active */\r
                NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
-       #endif\r
-               NVMBusEnabled = true;\r
        }\r
        \r
        Endpoint_Write_Byte(CMD_XPROG);\r
        }\r
        \r
        Endpoint_Write_Byte(CMD_XPROG);\r