diff options
author | cpldcpu <cpldcpu@gmail.com> | 2014-03-16 09:29:12 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2014-03-16 09:29:12 +0100 |
commit | bdae3d430ffe822b97382ca2eb4c8a34bee75004 (patch) | |
tree | 1f4f8a822a2991e9e37c08da2d9208f4c5e83f4b /commandline/library/micronucleus_lib.c | |
parent | 8773da4c5ff13ced369e8bc169956dd36a613918 (diff) | |
download | micronucleus-bdae3d430ffe822b97382ca2eb4c8a34bee75004.tar.gz micronucleus-bdae3d430ffe822b97382ca2eb4c8a34bee75004.tar.bz2 micronucleus-bdae3d430ffe822b97382ca2eb4c8a34bee75004.zip |
commandline: Update to 2.0a4 to accomodate for new device configuration reply for attiny841
Diffstat (limited to 'commandline/library/micronucleus_lib.c')
-rw-r--r-- | commandline/library/micronucleus_lib.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c index e2497c2..4961703 100644 --- a/commandline/library/micronucleus_lib.c +++ b/commandline/library/micronucleus_lib.c @@ -1,8 +1,10 @@ /* Created: September 2012 - by ihsan Kehribar <ihsan@kehribar.me> - + (c) 2012 by ihsan Kehribar <ihsan@kehribar.me> + Changes for Micronucleus protocol version V2.x + (c) 2014 T. Bo"scke + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to @@ -74,10 +76,16 @@ micronucleus* micronucleus_connect(int fast_mode) { if ((nucleus->version.major>=2)&&(!fast_mode)) { // firmware v2 reports more aggressive write times. Add 2ms if fast mode is not used. - nucleus->write_sleep = buffer[3]+2; - nucleus->erase_sleep = nucleus->write_sleep * nucleus->pages; + nucleus->write_sleep = (buffer[3] & 127) + 2; + if (buffer[3]&128) { + // if bit 7 of write sleep time is set, divide the erase time by four to + // accomodate to the 4*page erase of the ATtiny841/441 + nucleus->erase_sleep = nucleus->write_sleep * nucleus->pages / 4; + } else { + nucleus->erase_sleep = nucleus->write_sleep * nucleus->pages; + } } else { - nucleus->write_sleep = buffer[3]; + nucleus->write_sleep = (buffer[3] & 127); nucleus->erase_sleep = nucleus->write_sleep * nucleus->pages; } } |