common fw: Add hexval() utility function
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I724c14d1dee9e268f666030053fbf62ce5e1ba71
This commit is contained in:
parent
1b89f3bcca
commit
7bed9039e4
|
@ -36,6 +36,19 @@ hexstr(void *d, int n, bool space)
|
|||
return buf;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
hexval(char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
return 10 + (c - 'a');
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
return 10 + (c - 'A');
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_panic(const char *file, int lineno, const char *fmt, ...)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
char *hexstr(void *d, int n, bool space);
|
||||
uint8_t hexval(char c);
|
||||
|
||||
void _panic(const char *file, int lineno, const char *fmt, ...);
|
||||
#define panic(fmt, ...) _panic(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
|
|
Loading…
Reference in New Issue