CMD_ERASE_ALL = 0x5
CMD_JUMP = 0x6
CMD_PAGESIZE = 0x7
+CMD_I2C_ADDR = 0x80
CMD_INFO = 0x99
class bootloader:
raise Exception("Unsupported pagesize")
return i
+ def set_i2c_addr(self, addr):
+ self.run_cmd(CMD_I2C_ADDR, addr)
+
def to_bootloader(addr):
dev = i2c(addr)
parser = OptionParser(usage=usage)
parser.add_option("-b", "--start-bootloader", action="store_true", dest="bToBoot", default=False, help="Start Bootloader")
parser.add_option("-j", "--jump", action="store_true", dest="bJump", default=False, help="Jump to Program")
+ parser.add_option("-s", "--set-i2c-addr", dest="i2c_addr", type="int", help="Set I2C address")
(options, args) = parser.parse_args()
if not args:
to_bootloader(addr)
sleep(1)
loader = bootloader(addr)
+ if options.i2c_addr is not None:
+ print "Setting i2c address to 0x%X" % (options.i2c_addr)
+ loader.set_i2c_addr(options.i2c_addr)
if len(args) > 1:
loader.load(args[1])
if options.bJump: