From eef6c9736b07669aee8965533dba963a363b8494 Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Fri, 21 Feb 2014 07:25:00 +0100 Subject: firmware: Fix USB error during --run firmware will wait for 5ms after reception of last packet before exiting to user program. This prevents collisions with the last ACK from host PC. --- firmware/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'firmware/main.c') diff --git a/firmware/main.c b/firmware/main.c index b0aaa6b..cf61d3e 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -282,15 +282,18 @@ int main(void) { } while(--fastctr); - // commands are only evaluated after next USB transmission or after 5ms passed - if (command==cmd_exit) break; + // commands are only evaluated after next USB transmission or after 5 ms passed if (command==cmd_erase_application) eraseApplication(); // Attention: eraseApplication will set command=cmd_write_page! if (command==cmd_write_page) writeFlashPage(); - command=cmd_local_nop; + if (command==cmd_exit) { + if (!fastctr) break; // Only exit after 5 ms timeout + } else { + command=cmd_local_nop; + } { // This is usbpoll() minus reset logic and double buffering -- cgit v1.2.3