summaryrefslogtreecommitdiff
path: root/src/core/ao_cmd.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-11-30 15:04:21 -0800
committerKeith Packard <keithp@keithp.com>2012-11-30 15:04:21 -0800
commit81648829defbaf49fc98c4520540f7a20c50c417 (patch)
treec79636a61586d93f5baaf0d4985acf77612bc329 /src/core/ao_cmd.c
parent289ead258e217bc10493caab12a8b477f1bc2865 (diff)
altos: Share getnibble function
Two implementations of the same function, one in cc1111/ao_dbg.c and the other in core/ao_send_packet.c. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_cmd.c')
-rw-r--r--src/core/ao_cmd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/ao_cmd.c b/src/core/ao_cmd.c
index 1814cecf..a3330974 100644
--- a/src/core/ao_cmd.c
+++ b/src/core/ao_cmd.c
@@ -110,6 +110,22 @@ putnibble(uint8_t v)
putchar(v + ('a' - 10));
}
+uint8_t
+ao_getnibble(void)
+{
+ char c;
+
+ c = getchar();
+ if ('0' <= c && c <= '9')
+ return c - '0';
+ if ('a' <= c && c <= 'f')
+ return c - ('a' - 10);
+ if ('A' <= c && c <= 'F')
+ return c - ('A' - 10);
+ ao_cmd_status = ao_cmd_lex_error;
+ return 0;
+}
+
void
ao_cmd_put16(uint16_t v)
{