summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-12-04 23:36:54 -0800
committerKeith Packard <keithp@keithp.com>2009-12-04 23:41:19 -0800
commitc671a3f31f54715284beef5baa4a72ca922e4018 (patch)
tree2b38738516cf96b66cef381ca3d6d1132f3198b4
parente6d6ad66ce177eb6e49eaa04b1ecc6426f4bbdbf (diff)
Make ao_cmd_decimal produce both 32 and 16 bit values.
ao_cmd_lex_u32 is produced in addition to ao_cmd_lex_i so that functions can easily read 32-bit values from the command line. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/ao.h1
-rw-r--r--src/ao_cmd.c6
2 files changed, 5 insertions, 2 deletions
diff --git a/src/ao.h b/src/ao.h
index b72cac5c..287c912d 100644
--- a/src/ao.h
+++ b/src/ao.h
@@ -330,6 +330,7 @@ enum ao_cmd_status {
};
extern __xdata uint16_t ao_cmd_lex_i;
+extern __xdata uint32_t ao_cmd_lex_u32;
extern __xdata char ao_cmd_lex_c;
extern __xdata enum ao_cmd_status ao_cmd_status;
diff --git a/src/ao_cmd.c b/src/ao_cmd.c
index 58039f3a..b6d2b886 100644
--- a/src/ao_cmd.c
+++ b/src/ao_cmd.c
@@ -18,6 +18,7 @@
#include "ao.h"
__xdata uint16_t ao_cmd_lex_i;
+__xdata uint32_t ao_cmd_lex_u32;
__xdata char ao_cmd_lex_c;
__xdata enum ao_cmd_status ao_cmd_status;
static __xdata uint8_t lex_echo;
@@ -157,11 +158,11 @@ ao_cmd_decimal(void)
{
__xdata uint8_t r = ao_cmd_lex_error;
- ao_cmd_lex_i = 0;
+ ao_cmd_lex_u32 = 0;
ao_cmd_white();
for(;;) {
if ('0' <= ao_cmd_lex_c && ao_cmd_lex_c <= '9')
- ao_cmd_lex_i = (ao_cmd_lex_i * 10) + (ao_cmd_lex_c - '0');
+ ao_cmd_lex_u32 = (ao_cmd_lex_u32 * 10) + (ao_cmd_lex_c - '0');
else
break;
r = ao_cmd_success;
@@ -169,6 +170,7 @@ ao_cmd_decimal(void)
}
if (r != ao_cmd_success)
ao_cmd_status = r;
+ ao_cmd_lex_i = (uint16_t) ao_cmd_lex_u32;
}
uint8_t