summaryrefslogtreecommitdiffstats
path: root/app/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/util.c')
-rw-r--r--app/util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/util.c b/app/util.c
index 7f05a60..b0ffe53 100644
--- a/app/util.c
+++ b/app/util.c
@@ -55,3 +55,13 @@ unsigned le_bcd (uint8_t *d, unsigned s, unsigned e)
}
+unsigned xtoi (char c)
+{
+ if ((c >= '0') && (c <= '9')) return c - '0';
+
+ if ((c >= 'a') && (c <= 'f')) return 0xa + (c - 'a');
+
+ if ((c >= 'A') && (c <= 'F')) return 0xA + (c - 'A');
+
+ return 0;
+}