diff options
author | cpldcpu <cpldcpu@gmail.com> | 2014-02-21 07:25:00 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2014-02-21 07:25:00 +0100 |
commit | eef6c9736b07669aee8965533dba963a363b8494 (patch) | |
tree | b4113c7ce866b155dc571596aa99a7063695d42b /firmware | |
parent | 5b257aa2044dcc64ca7bfb63fdfdcbefadb42004 (diff) | |
download | micronucleus-eef6c9736b07669aee8965533dba963a363b8494.tar.gz micronucleus-eef6c9736b07669aee8965533dba963a363b8494.tar.bz2 micronucleus-eef6c9736b07669aee8965533dba963a363b8494.zip |
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.
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/main.c | 9 |
1 files changed, 6 insertions, 3 deletions
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 |