Merge commit '61e2bfc5f44267a7a3b0b25ff3ab922fca2a199c'
[osmocom-bb.git] / src / shared / libosmocore / src / utils.c
index 0d878c7..2a73d39 100644 (file)
@@ -30,3 +30,17 @@ int get_string_value(const struct value_string *vs, const char *str)
        }
        return -EINVAL;
 }
+
+char bcd2char(uint8_t bcd)
+{
+       if (bcd < 0xa)
+               return '0' + bcd;
+       else
+               return 'A' + (bcd - 0xa);
+}
+
+/* only works for numbers in ascci */
+uint8_t char2bcd(char c)
+{
+       return c - 0x30;
+}