C question on pointers???
Hello all....
Ok....not sure what i am missing here but this fails miserably....
The compiler hates when I try and assign test =
The return function works fine, I have made the return variable static so as not to lose the scope....test is an array so I expect test is the same as me doing &test[0]...What am I missing here?
uint8_t test[6];
for (uint8_t k = 0; k < NO_ADC_CH; k++)
{
test = hex2Ascii(&stream[k]);
test[4] = '\r';
test[5] = '\n'; //new line
HAL_UART_Transmit_IT(&huart2, test, sizeof(test));
}
char*hex2Ascii(uint16_t *val)
{
unsigned char d;
static char buff[4];
buff[0] = (char)((d = (*val >> 12)) > 9 ? ('A' + d - 10) : ('0' + d));
buff[1] = (char)((d = ((*val >> 8) & 0xf)) > 9 ? ('A' + d - 10) : ('0' + d));
buff[2] = (char)((d = ((*val >> 4) & 0xf)) > 9 ? ('A' + d - 10) : ('0' + d));
buff[3] = (char)((d = (*val & 0xf)) > 9 ? ('A' + d - 10) : ('0' + d));
return buff;
}