1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

fmt: add fmt_u16_hex()

This commit is contained in:
Vincent Dupont 2018-08-23 13:59:48 +02:00
parent 99e75948ef
commit a542e954cf
2 changed files with 19 additions and 0 deletions

View File

@ -153,6 +153,11 @@ size_t fmt_hex_bytes(uint8_t *out, const char *hex)
return final_len;
}
size_t fmt_u16_hex(char *out, uint16_t val)
{
return fmt_bytes_hex_reverse(out, (uint8_t*) &val, 2);
}
size_t fmt_u32_hex(char *out, uint32_t val)
{
return fmt_bytes_hex_reverse(out, (uint8_t*) &val, 4);

View File

@ -119,6 +119,20 @@ uint8_t fmt_hex_byte(const char *hex);
*/
size_t fmt_hex_bytes(uint8_t *out, const char *hex);
/**
* @brief Convert a uint16 value to hex string.
*
* Will write 4 bytes to @p out.
* If @p out is NULL, will only return the number of bytes that would have
* been written.
*
* @param[out] out Pointer to output buffer, or NULL
* @param[in] val Value to convert
*
* @return 4
*/
size_t fmt_u16_hex(char *out, uint16_t val);
/**
* @brief Convert a uint32 value to hex string.
*