public static QsiMessage getEraseFlash(int addr, int rows) { QsiMessage m = new QsiMessage(6); m.setOpCode(ER_FLASH); // Erase a number of 64 byte rows m.setLength(rows); m.setAddress(addr); m.setChecksum(); return m.frame(); }
public static QsiMessage getWriteEE(int addr, int[] data) { QsiMessage m = new QsiMessage(6 + data.length); m.setOpCode(WT_EEDATA); m.setLength(data.length); m.setAddress(addr & 0xff); m.setData(data); m.setChecksum(); return m.frame(); }
public static QsiMessage getWriteFlash(int addr, int[] data) { int l = data.length; // Writes are rounded up to multiples of 8 bytes if (l % 8 != 0) { l = l + (8 - l % 8); } // and data padded with erased condition int padded[] = new int[l]; for (int i = 0; i < l; i++) { if (i < data.length) { padded[i] = data[i]; } else { padded[i] = 0xff; } } QsiMessage m = new QsiMessage(6 + l); m.setOpCode(WT_FLASH); // length is number of 8 byte blocks m.setLength(l / 8); m.setAddress(addr); m.setData(padded); m.setChecksum(); return m.frame(); }