eeprom driver code c++ overlapping
packet.addr[0] = uint8_t(ROMADDR &amp; 0xff00);
packet.addr[1] = uint8_t((ROMADDR &gt;&gt; 8) &amp; 0x00ff);


This is probably not what you want. Notice that you are masking the low byte of ROMADDR in both lines which results in addr[0] being 0x00 every time.

Try

packet.addr[0] = (uint8_t)(ROMADDR &gt;&gt; 8);  // High byte of ROMADDR
packet.addr[1] = (uint8_t)(ROMADDR); // Low byte of ROMADDR