I need to pass a 16-bit long address (for an external EEPROM) to a function (
twi_writeTo) in a buffer.
I am currently doing this
byte buffer; buffer = (byte)(eeaddress >> 8); buffer = (byte)(eeaddress & 0xFF);
eeaddress is an
unsigned int with the address.
I then do
int8_t ret = twi_writeTo(eeprom_i2c_addr, buffer, 2, 1);
Before I tried
int8_t ret = twi_writeTo(eeprom_i2c_addr, (uint8_t*)&eeaddress, 2, 1);
but that returns garbage. Probably the byte order is swapped. Is that the case? And if so, is there a better way than copying the two bytes to a buffer?