I have four registers on my slave (an arduino)
0x00 - device id 0x01 - button state (four buttons) 0x02 - led state (four buttons) 0x03 - led mode (how the leds react to button presses if at all)
Currently, to get a value off the slave I issue a write with an address. This address is stored in a pointer on the slave and then when the next read comes in I return the data in the register at that pointer address.
Basically, on address 0x48
W 0x48 0x01 R 0x48 ; button state at 0x01 W 0x48 0x02 R 0x48 ; led state at 0x02
And I do this over and over checking for state changes. I'm not really sure why I did it this way, some datasheet or blog post lead me in this direction but now I'm questioning it. Now I'm thinking I should just skip the writes and return all the register values on every read. So one read would return four bytes in this example instead of one.
Is this better? It seems less error prone but I'm not sure what costs are associate with returning multiple bytes etc.