Add check to the PROGRAM FLASH ISP and PROGRAM EEPROM ISP handler to return an explicit error when the host attempts to write more data than the device is able to buffer.
\r
Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));\r
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);\r
\r
Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));\r
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);\r
+ \r
+ if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))\r
+ {\r
+ Endpoint_ClearOUT();\r
+ Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);\r
+\r
+ Endpoint_Write_Byte(V2Command);\r
+ Endpoint_Write_Byte(STATUS_CMD_FAILED);\r
+ Endpoint_ClearIN();\r
+ return;\r
+ }\r
+ \r
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite);\r
\r
Endpoint_ClearOUT();\r
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite);\r
\r
Endpoint_ClearOUT();\r
\r
Endpoint_Write_Byte(V2Command);\r
Endpoint_Write_Byte(ProgrammingStatus);\r
\r
Endpoint_Write_Byte(V2Command);\r
Endpoint_Write_Byte(ProgrammingStatus);\r
Endpoint_ClearIN();\r
}\r
\r
Endpoint_ClearIN();\r
}\r
\r
+ bool DeviceBusy;\r
+ \r
do\r
{\r
SPI_SendByte(0xF0);\r
SPI_SendByte(0x00);\r
\r
SPI_SendByte(0x00);\r
do\r
{\r
SPI_SendByte(0xF0);\r
SPI_SendByte(0x00);\r
\r
SPI_SendByte(0x00);\r
- bool DeviceBusy = (SPI_ReceiveByte() & 0x01);\r
+ DeviceBusy = (SPI_ReceiveByte() & 0x01);\r
}\r
while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
\r
}\r
while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));\r
\r
#define TOTAL_PROGRAMMING_SPEEDS 7\r
\r
/** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */\r
#define TOTAL_PROGRAMMING_SPEEDS 7\r
\r
/** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */\r
- #define TARGET_BUSY_TIMEOUT_MS 150\r
+ #define TARGET_BUSY_TIMEOUT_MS 240\r
\r
/* External Variables: */\r
extern uint32_t CurrentAddress;\r
\r
/* External Variables: */\r
extern uint32_t CurrentAddress;\r