I stumbled on some code in the project I'm working on and I wanted to be sure to understand it correctly. So here it is:
uint16_t* tmp;
tmp = (uint16_t*) ((uint8_t*)getVariableAddress(variable) + offset);
tmp = (uint16_t*)((uint8_t*)tmp + otherOffset);
Set_Register((unsigned long) tmp[0]);
Set_OtherRegister((unsigned long) tmp[2]);
At first I got a bit lost between all the casts but the way I see it the uint8_t* are being used to move byte per byte and add the offset values to the base address we place in tmp, this was the first part that got me troubled. The second part was the use of [] on a uint16_t* , for this one I'm not sure at all on the result, anyone care to explain this in detail ?
Thanks