hex.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "stdint.h"
  3. #include "stdbool.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /** Convert ASCII hex value to nibble
  8. * @param c ASCII character
  9. * @param nibble nibble pointer, output
  10. *
  11. * @return bool conversion status
  12. */
  13. bool hex_char_to_hex_nibble(char c, uint8_t* nibble);
  14. /** Convert ASCII hex value to byte
  15. * @param hi hi nibble text
  16. * @param low low nibble text
  17. * @param value output value
  18. *
  19. * @return bool conversion status
  20. */
  21. bool hex_char_to_uint8(char hi, char low, uint8_t* value);
  22. /** Convert ASCII hex values to uint8_t
  23. * @param value_str ASCII data
  24. * @param value output value
  25. *
  26. * @return bool conversion status
  27. */
  28. bool hex_chars_to_uint8(const char* value_str, uint8_t* value);
  29. /** Convert ASCII hex values to uint64_t
  30. * @param value_str ASCII 64 bi data
  31. * @param value output value
  32. *
  33. * @return bool conversion status
  34. */
  35. bool hex_chars_to_uint64(const char* value_str, uint64_t* value);
  36. /** Convert uint8_t to ASCII hex values
  37. * @param src source data
  38. * @param target output value
  39. * @param length data length
  40. *
  41. */
  42. void uint8_to_hex_chars(const uint8_t* src, uint8_t* target, int length);
  43. #ifdef __cplusplus
  44. }
  45. #endif