def write(self, addr, data):
data = data if isinstance(data, list) else [data]
length = len(data)
- self._write([self.msg_type["write"], length])
- self._write(list((addr//4).to_bytes(4, byteorder="big")))
- for i, value in enumerate(data):
- self._write(list(value.to_bytes(4, byteorder="big")))
- if self.debug:
- print("write {:08x} @ {:08x}".format(value, addr + 4*i))
+ offset = 0
+ while length:
+ size = min(length, 8)
+ self._write([self.msg_type["write"], size])
+ self._write(list(((addr+offset)//4).to_bytes(4, byteorder="big")))
+ for i, value in enumerate(data[offset:offset+size]):
+ self._write(list(value.to_bytes(4, byteorder="big")))
+ if self.debug:
+ print("write {:08x} @ {:08x}".format(value, addr + offset, 4*i))
+ offset += size
+ length -= size