tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26912 )
Change subject: common fw: Add hexval() utility function ......................................................................
common fw: Add hexval() utility function
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I724c14d1dee9e268f666030053fbf62ce5e1ba71 --- M firmware/ice40-riscv/common/utils.c M firmware/ice40-riscv/common/utils.h 2 files changed, 14 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/12/26912/1
diff --git a/firmware/ice40-riscv/common/utils.c b/firmware/ice40-riscv/common/utils.c index 1ac111b..7c7d3d0 100644 --- a/firmware/ice40-riscv/common/utils.c +++ b/firmware/ice40-riscv/common/utils.c @@ -36,6 +36,19 @@ 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, ...) diff --git a/firmware/ice40-riscv/common/utils.h b/firmware/ice40-riscv/common/utils.h index 03359ae..37cc88e 100644 --- a/firmware/ice40-riscv/common/utils.h +++ b/firmware/ice40-riscv/common/utils.h @@ -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__)
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26912
to look at the new patch set (#2).
Change subject: common fw: Add hexval() utility function ......................................................................
common fw: Add hexval() utility function
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I724c14d1dee9e268f666030053fbf62ce5e1ba71 --- M firmware/ice40-riscv/common/utils.c M firmware/ice40-riscv/common/utils.h 2 files changed, 14 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/12/26912/2
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26912 )
Change subject: common fw: Add hexval() utility function ......................................................................
Patch Set 2: Code-Review+2
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26912 )
Change subject: common fw: Add hexval() utility function ......................................................................
common fw: Add hexval() utility function
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I724c14d1dee9e268f666030053fbf62ce5e1ba71 --- M firmware/ice40-riscv/common/utils.c M firmware/ice40-riscv/common/utils.h 2 files changed, 14 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified
diff --git a/firmware/ice40-riscv/common/utils.c b/firmware/ice40-riscv/common/utils.c index 1ac111b..7c7d3d0 100644 --- a/firmware/ice40-riscv/common/utils.c +++ b/firmware/ice40-riscv/common/utils.c @@ -36,6 +36,19 @@ 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, ...) diff --git a/firmware/ice40-riscv/common/utils.h b/firmware/ice40-riscv/common/utils.h index 03359ae..37cc88e 100644 --- a/firmware/ice40-riscv/common/utils.h +++ b/firmware/ice40-riscv/common/utils.h @@ -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__)