X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7c8f4a716f01f6598234fd60cd53345da4903fde..f5951d15936f397afbeb31bf467a90e6e9b5e161:/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c index 39f82a0df..1633fb24d 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c @@ -124,6 +124,10 @@ static void XPROGProtocol_EnterXPROGMode(void) XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG); XPROGTarget_SendByte(PDI_RESET_KEY); + /* Lower direction change guard time to 8 USART bits */ + XPROGTarget_SendByte(PDI_CMD_STCS | PDI_CTRL_REG); + XPROGTarget_SendByte(0x04); + /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */ XPROGTarget_SendByte(PDI_CMD_KEY); for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--) @@ -137,6 +141,10 @@ static void XPROGProtocol_EnterXPROGMode(void) /* Enable TPI programming mode with the attached target */ XPROGTarget_EnableTargetTPI(); + /* Lower direction change guard time to 8 USART bits */ + XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG); + XPROGTarget_SendByte(0x04); + /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */ XPROGTarget_SendByte(TPI_CMD_SKEY); for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--) @@ -313,9 +321,14 @@ static void XPROGProtocol_WriteMemory(void) } else { + Serial_TxByte((uint8_t)WriteMemory_XPROG_Params.Length); + /* Send write command to the TPI device, indicate timeout if occurred */ - if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData[0]))) - ReturnStatus = XPRG_ERR_TIMEOUT; + if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData, + WriteMemory_XPROG_Params.Length))) + { + ReturnStatus = XPRG_ERR_TIMEOUT; + } } Endpoint_Write_Byte(CMD_XPROG); @@ -355,6 +368,8 @@ static void XPROGProtocol_ReadMemory(void) } else { + Serial_TxByte((uint8_t)ReadMemory_XPROG_Params.Length); + /* Read the TPI target's memory, indicate timeout if occurred */ if (!(TINYNVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length))) ReturnStatus = XPRG_ERR_TIMEOUT;