I have a subroutine which expects two arguments: uint8_t[] array buffer and uint16_t size:
void getData(uint8_t * pData, uint16_t size)
Instead of 2-byte array pointer I would like to pass a pointer to uint16_t variable so I do not have to convert array content to uint16_t variable later on. Here is what I tried:
uint16_t value;
uint8_t values[2];
// instead of:
getData(values, 2);
value = (values[0] << 8) | values[1];
// I want to simply call:
getData((uint8_t *)&value, 2);
The above approach does not yield the expected result. What is the correct way?
Please advise.