const char hex2char[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
};
//------------------------------------------------------------------------------
void hex2str( char *s,const u8 hex[], u8 n)
{
s8 i;
for (i = (s8)(n - 1); i >= (s8)0; --i)
{
*s++ = hex2char[hex[i] >> 4];
*s++ = hex2char[hex[i] & (u8)0x0F];
}
*s = '\0';
}
void usart3_printf(sc8 * str,s16 str_len,u16 value)
{
s8 ascii_adc_value[10];
u8 hex_data[2];
hex_data[0] = value&0xff;
hex_data[1] = (value>>8)&0xff;
hex2str((char*)ascii_adc_value,hex_data,2);
(void)usart3_write_wait((u8*)str,(u16)str_len);
(void)usart3_write_wait((u8*)ascii_adc_value,4);
}