summaryrefslogtreecommitdiffstats
path: root/libtoprammer/chips
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2012-09-05 17:49:21 +0200
committerMichael Buesch <m@bues.ch>2012-09-05 17:49:21 +0200
commit0cedd110e4208f035765fdefe722dff772fbe2bd (patch)
tree57a22c8f7ba8ec02ac0decd2b58c67bf5078ae28 /libtoprammer/chips
parent9d478916d191cb1d71878be4682c737e4472e9d0 (diff)
downloadtoprammer-0cedd110e4208f035765fdefe722dff772fbe2bd.tar.xz
toprammer-0cedd110e4208f035765fdefe722dff772fbe2bd.zip
atmega-common: Add 3 byte fuse write support
Signed-off-by: Michael Buesch <m@bues.ch>
Diffstat (limited to 'libtoprammer/chips')
-rw-r--r--libtoprammer/chips/atmega_common.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/libtoprammer/chips/atmega_common.py b/libtoprammer/chips/atmega_common.py
index 30ac588..57ba759 100644
--- a/libtoprammer/chips/atmega_common.py
+++ b/libtoprammer/chips/atmega_common.py
@@ -164,22 +164,38 @@ class Chip_ATMega_common(Chip):
return fuse
def writeFuse(self, image):
- if len(image) != 2:
+ if len(image) != self.fuseBytes:
self.throwError("Invalid Fuses image size %d (expected %d)" %\
- (len(image), 2))
+ (len(image), self.fuseBytes))
self.__enterPM()
self.progressMeterInit("Writing Fuse bits", 0)
+
self.__loadCommand(self.CMD_WRITEFUSE)
self.__setBS2(0)
self.__loadDataLow(byte2int(image[0]))
+ self.__setBS1(0)
self.__pulseWR()
self.__waitForRDY()
+
self.__loadCommand(self.CMD_WRITEFUSE)
+ self.__setBS2(0)
self.__loadDataLow(byte2int(image[1]))
self.__setBS1(1)
self.__pulseWR()
self.__waitForRDY()
+
+ if len(image) >= 3:
+ self.__loadCommand(self.CMD_WRITEFUSE)
+ self.__setBS2(1)
+ self.__loadDataLow(byte2int(image[2]))
+ self.__setBS1(0)
+ self.__pulseWR()
+ self.__waitForRDY()
+
+ self.__setBS1(0)
+ self.__setBS2(0)
+
self.progressMeterFinish()
def readLockbits(self):
@@ -235,7 +251,7 @@ class Chip_ATMega_common(Chip):
elif self.fuseBytes == 3:
# fuseLow, fuseHigh, fuseExt
fuses = data[0] + data[3] + data[2]
- else
+ else:
assert(0)
lock = data[1]
return (fuses, lock)
bues.ch cgit interface