# HG changeset patch # User Paul Boddie # Date 1439142689 -7200 # Node ID ad17e0dbe2277aaaa48ab49daa681c167cf2cb11 # Parent deaef57647e7da71a0764668193ed49bc1519d6e Fixed address high portion initialisation in read and write operations. Added missing erase and program operation support for 17-bit addresses. Updated the upload script to support 17-bit addresses. diff -r deaef57647e7 -r ad17e0dbe227 ArduinoAm29F010.cpp --- a/ArduinoAm29F010.cpp Sun Aug 09 19:08:15 2015 +0200 +++ b/ArduinoAm29F010.cpp Sun Aug 09 19:51:29 2015 +0200 @@ -170,7 +170,10 @@ i = 2; } else + { + high = 0; i = 1; + } high |= (fromHex(buffer[i]) << 4) + (fromHex(buffer[i+1])); low = (fromHex(buffer[i+2]) << 4) + (fromHex(buffer[i+3])); @@ -188,7 +191,10 @@ i = 2; } else + { + high = 0; i = 1; + } high |= (fromHex(buffer[i]) << 4) + (fromHex(buffer[i+1])); low = (fromHex(buffer[i+2]) << 4) + (fromHex(buffer[i+3])); @@ -238,10 +244,10 @@ { int high; - // 3-bit number shifted to A16...A14 with A16 discarded. - // Thus, only sectors from 0 to 3 are supported. + // 3-bit number shifted to A16...A14. + // Thus, only sectors from 0 to 7 are supported. - high = (fromHex(buffer[1]) << 6) & 0xff; + high = (fromHex(buffer[1]) << 6) & 0x1ff; for (int i = 0; i < 5; i++) { @@ -256,11 +262,22 @@ bool program(const char buffer[]) { - int high, low, data; + int high, low, data, i; - high = (fromHex(buffer[1]) << 4) + (fromHex(buffer[2])); - low = (fromHex(buffer[3]) << 4) + (fromHex(buffer[4])); - data = (fromHex(buffer[5]) << 4) + (fromHex(buffer[6])); + if (nread > 7) + { + high = fromHex(buffer[1]) << 8; + i = 2; + } + else + { + high = 0; + i = 1; + } + + high |= (fromHex(buffer[i]) << 4) + (fromHex(buffer[i+1])); + low = (fromHex(buffer[i+2]) << 4) + (fromHex(buffer[i+3])); + data = (fromHex(buffer[i+4]) << 4) + (fromHex(buffer[i+5])); for (int i = 0; i < 3; i++) { diff -r deaef57647e7 -r ad17e0dbe227 upload.py --- a/upload.py Sun Aug 09 19:08:15 2015 +0200 +++ b/upload.py Sun Aug 09 19:51:29 2015 +0200 @@ -84,13 +84,13 @@ addr = (sector << 14) | i if not verify_only: - writeToPort("P%04x%02x\n" % (addr, value)) + writeToPort("P%05x%02x\n" % (addr, value)) resp = readFromPort() if resp != "P": print >>sys.stderr, "Program of location %04x failed: %s" % (addr, resp) return False else: - writeToPort("R%04x\n" % addr) + writeToPort("R%05x\n" % addr) resp = readFromPort() if resp != "%02X" % value and resp != "%X" % value: print >>sys.stderr, "Verify of location %04x failed: %s" % (addr, resp)