summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-04-29 17:46:56 -0700
committerKeith Packard <keithp@keithp.com>2009-04-29 17:46:56 -0700
commitde7814c738488c2c16c6216c93fa78128895e5d5 (patch)
tree07a295d9f3786623e382a92bbab811ac19a78016
parent4ae74fffb939d67424efa3e7f433637f1f920ebc (diff)
Use 'char' instead of 'uint8_t' for character data
String and character constants are of char type, so using uint8_t causes promotion to 16-bit types when comparing the two.
-rw-r--r--ao.h14
-rw-r--r--ao_cmd.c12
-rw-r--r--ao_config.c4
-rw-r--r--ao_dbg.c2
-rw-r--r--ao_flight_test.c2
-rw-r--r--ao_gps.c15
-rw-r--r--ao_ignite.c6
-rw-r--r--ao_serial.c8
-rw-r--r--ao_stdio.c4
-rw-r--r--ao_test.c2
-rw-r--r--ao_usb.c6
11 files changed, 37 insertions, 38 deletions
diff --git a/ao.h b/ao.h
index 88bcc93a..12948ed3 100644
--- a/ao.h
+++ b/ao.h
@@ -259,10 +259,10 @@ ao_led_init(uint8_t enable);
/* Put one character to the USB output queue */
void
-ao_usb_putchar(uint8_t c);
+ao_usb_putchar(char c);
/* Get one character from the USB input queue */
-uint8_t
+char
ao_usb_getchar(void);
/* Flush the USB output queue */
@@ -296,7 +296,7 @@ enum ao_cmd_status {
};
extern __xdata uint16_t ao_cmd_lex_i;
-extern __xdata uint8_t ao_cmd_lex_c;
+extern __xdata char ao_cmd_lex_c;
extern __xdata enum ao_cmd_status ao_cmd_status;
void
@@ -318,7 +318,7 @@ void
ao_cmd_decimal(void);
struct ao_cmds {
- uint8_t cmd;
+ char cmd;
void (*func)(void);
const char *help;
};
@@ -462,7 +462,7 @@ struct ao_gps_pos {
#define AO_LOG_POS_NONE (~0UL)
struct ao_log_record {
- uint8_t type;
+ char type;
uint8_t csum;
uint16_t tick;
union {
@@ -654,11 +654,11 @@ void
ao_serial_tx1_isr(void) interrupt 14;
#endif
-uint8_t
+char
ao_serial_getchar(void) __critical;
void
-ao_serial_putchar(uint8_t c) __critical;
+ao_serial_putchar(char c) __critical;
void
ao_serial_init(void);
diff --git a/ao_cmd.c b/ao_cmd.c
index abab1463..f0459a73 100644
--- a/ao_cmd.c
+++ b/ao_cmd.c
@@ -18,20 +18,20 @@
#include "ao.h"
__xdata uint16_t ao_cmd_lex_i;
-__xdata uint8_t ao_cmd_lex_c;
+__xdata char ao_cmd_lex_c;
__xdata enum ao_cmd_status ao_cmd_status;
static __xdata uint8_t lex_echo;
#define CMD_LEN 32
-static __xdata uint8_t cmd_line[CMD_LEN];
+static __xdata char cmd_line[CMD_LEN];
static __xdata uint8_t cmd_len;
static __xdata uint8_t cmd_i;
static void
put_string(char *s)
{
- __xdata uint8_t c;
+ __xdata char c;
while (c = *s++)
putchar(c);
}
@@ -39,7 +39,7 @@ put_string(char *s)
static void
readline(void)
{
- __xdata uint8_t c;
+ __xdata char c;
if (lex_echo)
put_string("> ");
cmd_len = 0;
@@ -212,7 +212,7 @@ echo(void)
lex_echo = ao_cmd_lex_i != 0;
}
-static const uint8_t help_txt[] = "All numbers are in hex";
+static const char help_txt[] = "All numbers are in hex";
#define NUM_CMDS 11
@@ -256,7 +256,7 @@ ao_cmd_register(__code struct ao_cmds *cmds)
void
ao_cmd(void *parameters)
{
- __xdata uint8_t c;
+ __xdata char c;
__xdata uint8_t cmd, cmds;
__code struct ao_cmds * __xdata cs;
void (*__xdata func)(void);
diff --git a/ao_config.c b/ao_config.c
index 593029f2..9bb8fd1a 100644
--- a/ao_config.c
+++ b/ao_config.c
@@ -188,7 +188,7 @@ ao_config_accel_zero_g_set(void) __reentrant
}
struct ao_config_var {
- uint8_t cmd;
+ char cmd;
void (*set)(void) __reentrant;
void (*show)(void) __reentrant;
const char *help;
@@ -225,7 +225,7 @@ __code struct ao_config_var ao_config_vars[] = {
void
ao_config_set(void)
{
- uint8_t c;
+ char c;
uint8_t cmd;
void (*__xdata func)(void) __reentrant;
diff --git a/ao_dbg.c b/ao_dbg.c
index d100703f..8a11a444 100644
--- a/ao_dbg.c
+++ b/ao_dbg.c
@@ -287,7 +287,7 @@ debug_get(void)
static uint8_t
getnibble(void)
{
- __xdata uint8_t c;
+ __xdata char c;
c = getchar();
if ('0' <= c && c <= '9')
diff --git a/ao_flight_test.c b/ao_flight_test.c
index aefe3da7..dea7b31c 100644
--- a/ao_flight_test.c
+++ b/ao_flight_test.c
@@ -108,7 +108,7 @@ const char const * const ao_state_names[] = {
};
struct ao_cmds {
- uint8_t cmd;
+ char cmd;
void (*func)(void);
const char *help;
};
diff --git a/ao_gps.c b/ao_gps.c
index 353272f1..e5a5a884 100644
--- a/ao_gps.c
+++ b/ao_gps.c
@@ -19,16 +19,16 @@
#define AO_GPS_LEADER 6
-static const uint8_t ao_gps_header[] = "GPGGA,";
+static const char ao_gps_header[] = "GPGGA,";
__xdata uint8_t ao_gps_mutex;
-static __xdata uint8_t ao_gps_char;
+static __xdata char ao_gps_char;
static __xdata uint8_t ao_gps_cksum;
static __xdata uint8_t ao_gps_error;
__xdata struct ao_gps_data ao_gps_data;
static __xdata struct ao_gps_data ao_gps_next;
-const uint8_t ao_gps_config[] =
+const char ao_gps_config[] =
"$PSRF103,00,00,01,01*25\r\n" /* GGA 1 per sec */
"$PSRF103,01,00,00,01*25\r\n" /* GLL disable */
"$PSRF103,02,00,00,01*26\r\n" /* GSA disable */
@@ -137,7 +137,7 @@ ao_gps_parse_pos(__xdata struct ao_gps_pos * pos, uint8_t deg_width) __reentrant
}
static void
-ao_gps_parse_flag(uint8_t yes_c, uint8_t yes, uint8_t no_c, uint8_t no) __reentrant
+ao_gps_parse_flag(char yes_c, uint8_t yes, char no_c, uint8_t no) __reentrant
{
ao_gps_skip_sep();
if (ao_gps_char == yes_c)
@@ -153,7 +153,7 @@ ao_gps_parse_flag(uint8_t yes_c, uint8_t yes, uint8_t no_c, uint8_t no) __reentr
void
ao_gps(void) __reentrant
{
- uint8_t c;
+ char c;
uint8_t i;
for (i = 0; (c = ao_gps_config[i]); i++)
@@ -238,9 +238,8 @@ ao_gps(void) __reentrant
ao_gps_skip_field();
}
if (ao_gps_char == '*') {
- c = ao_gps_cksum ^ '*';
- i = ao_gps_hex(2);
- if (c != i)
+ uint8_t cksum = ao_gps_cksum ^ '*';
+ if (cksum != ao_gps_hex(2))
ao_gps_error = 1;
} else
ao_gps_error = 1;
diff --git a/ao_ignite.c b/ao_ignite.c
index b89fd2f7..be291523 100644
--- a/ao_ignite.c
+++ b/ao_ignite.c
@@ -118,7 +118,7 @@ ao_igniter(void)
}
static uint8_t
-ao_match_word(__code uint8_t *word)
+ao_match_word(__code char *word)
{
while (*word) {
if (ao_cmd_lex_c != *word) {
@@ -147,12 +147,12 @@ ao_ignite_manual(void)
}
}
-static __code uint8_t *igniter_status_names[] = {
+static __code char *igniter_status_names[] = {
"unknown", "ready", "active", "open"
};
void
-ao_ignite_print_status(enum ao_igniter igniter, __code uint8_t *name) __reentrant
+ao_ignite_print_status(enum ao_igniter igniter, __code char *name) __reentrant
{
enum ao_igniter_status status = ao_igniter_status(igniter);
printf("Igniter: %6s Status: %s\n",
diff --git a/ao_serial.c b/ao_serial.c
index ae5e0764..20bb4f96 100644
--- a/ao_serial.c
+++ b/ao_serial.c
@@ -22,7 +22,7 @@
struct ao_fifo {
uint8_t insert;
uint8_t remove;
- uint8_t fifo[SERIAL_FIFO];
+ char fifo[SERIAL_FIFO];
};
volatile __xdata struct ao_fifo ao_usart1_rx_fifo;
@@ -71,10 +71,10 @@ ao_serial_tx1_isr(void) interrupt 14
ao_wakeup(&ao_usart1_tx_fifo);
}
-uint8_t
+char
ao_serial_getchar(void) __critical
{
- uint8_t c;
+ char c;
while (ao_fifo_empty(ao_usart1_rx_fifo))
ao_sleep(&ao_usart1_rx_fifo);
ao_fifo_remove(ao_usart1_rx_fifo, c);
@@ -82,7 +82,7 @@ ao_serial_getchar(void) __critical
}
void
-ao_serial_putchar(uint8_t c) __critical
+ao_serial_putchar(char c) __critical
{
while (ao_fifo_full(ao_usart1_tx_fifo))
ao_sleep(&ao_usart1_tx_fifo);
diff --git a/ao_stdio.c b/ao_stdio.c
index da57f409..fb8ce093 100644
--- a/ao_stdio.c
+++ b/ao_stdio.c
@@ -26,7 +26,7 @@ putchar(char c)
{
if (c == '\n')
ao_usb_putchar('\r');
- ao_usb_putchar((uint8_t) c);
+ ao_usb_putchar(c);
}
void
@@ -38,5 +38,5 @@ flush(void)
char
getchar(void)
{
- return (char) ao_usb_getchar();
+ return ao_usb_getchar();
}
diff --git a/ao_test.c b/ao_test.c
index 0fdfcfa1..6d005ff6 100644
--- a/ao_test.c
+++ b/ao_test.c
@@ -87,7 +87,7 @@ beep(void)
void
echo(void)
{
- uint8_t c;
+ char c;
for (;;) {
ao_usb_flush();
c = ao_usb_getchar();
diff --git a/ao_usb.c b/ao_usb.c
index d02bfac8..69f87fc4 100644
--- a/ao_usb.c
+++ b/ao_usb.c
@@ -316,7 +316,7 @@ ao_usb_flush(void) __critical
}
void
-ao_usb_putchar(uint8_t c) __critical
+ao_usb_putchar(char c) __critical
{
for (;;) {
USBINDEX = AO_USB_IN_EP;
@@ -332,10 +332,10 @@ ao_usb_putchar(uint8_t c) __critical
}
}
-uint8_t
+char
ao_usb_getchar(void) __critical
{
- __xdata uint8_t c;
+ __xdata char c;
while (ao_usb_out_bytes == 0) {
for (;;) {
USBINDEX = AO_USB_OUT_EP;