X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/1ed6925b5bf417848b83887b32e3ede05a1c691b..bd5e8f07b71b4fa0c058c0edfa8ff3f59ab31610:/Projects/AVRISP/Lib/ISPProtocol.c diff --git a/Projects/AVRISP/Lib/ISPProtocol.c b/Projects/AVRISP/Lib/ISPProtocol.c index bfd917a09..e769cee8a 100644 --- a/Projects/AVRISP/Lib/ISPProtocol.c +++ b/Projects/AVRISP/Lib/ISPProtocol.c @@ -35,6 +35,8 @@ #include "ISPProtocol.h" +#if defined(ENABLE_ISP_PROTOCOL) || defined(__DOXYGEN__) + /** Handler for the CMD_ENTER_PROGMODE_ISP command, which attempts to enter programming mode on * the attached device, returning success or failure back to the host. */ @@ -61,7 +63,7 @@ void ISPProtocol_EnterISPMode(void) CurrentAddress = 0; - V2Protocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS); + ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS); SPI_Init(ISPTarget_GetSPIPrescalerMask() | SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING | SPI_MODE_MASTER); while (Enter_ISP_Params.SynchLoops-- && (ResponseStatus == STATUS_CMD_FAILED)) @@ -69,11 +71,11 @@ void ISPProtocol_EnterISPMode(void) uint8_t ResponseBytes[4]; ISPTarget_ChangeTargetResetLine(true); - V2Protocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); + ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++) { - V2Protocol_DelayMS(Enter_ISP_Params.ByteDelay); + ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay); ResponseBytes[RByte] = SPI_TransferByte(Enter_ISP_Params.EnterProgBytes[RByte]); } @@ -85,7 +87,7 @@ void ISPProtocol_EnterISPMode(void) else { ISPTarget_ChangeTargetResetLine(false); - V2Protocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); + ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS); } } @@ -108,10 +110,10 @@ void ISPProtocol_LeaveISPMode(void) Endpoint_ClearOUT(); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); - V2Protocol_DelayMS(Leave_ISP_Params.PreDelayMS); + ISPProtocol_DelayMS(Leave_ISP_Params.PreDelayMS); ISPTarget_ChangeTargetResetLine(false); SPI_ShutDown(); - V2Protocol_DelayMS(Leave_ISP_Params.PostDelayMS); + ISPProtocol_DelayMS(Leave_ISP_Params.PostDelayMS); Endpoint_Write_Byte(CMD_LEAVE_PROGMODE_ISP); Endpoint_Write_Byte(STATUS_CMD_OK); @@ -136,7 +138,10 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command) uint8_t ProgData[256]; // Note, the Jungo driver has a very short ACK timeout period, need to buffer the } Write_Memory_Params; // whole page and ACK the packet as fast as possible to prevent it from aborting - Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData)); + Endpoint_Read_Stream_LE(&Write_Memory_Params, (sizeof(Write_Memory_Params) - + sizeof(Write_Memory_Params.ProgData))); + + Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite); if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData)) @@ -352,7 +357,7 @@ void ISPProtocol_ChipErase(void) SPI_SendByte(Erase_Chip_Params.EraseCommandBytes[SByte]); if (!(Erase_Chip_Params.PollMethod)) - V2Protocol_DelayMS(Erase_Chip_Params.EraseDelayMS); + ISPProtocol_DelayMS(Erase_Chip_Params.EraseDelayMS); else ResponseStatus = ISPTarget_WaitWhileTargetBusy(); @@ -465,3 +470,5 @@ void ISPProtocol_SPIMulti(void) Endpoint_Write_Byte(STATUS_CMD_OK); Endpoint_ClearIN(); } + +#endif \ No newline at end of file