Move a bunch of variables from __data to __xdata
authorKeith Packard <keithp@keithp.com>
Wed, 15 Apr 2009 21:25:26 +0000 (14:25 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 15 Apr 2009 21:25:26 +0000 (14:25 -0700)
ao.h
ao_cmd.c
ao_log.c
ao_usb.c

diff --git a/ao.h b/ao.h
index 39ad9587d2073d45d9edc519b71a24a8077315bf..23f131722f087a2a1940d2cbc700e7fe8cc79125 100644 (file)
--- a/ao.h
+++ b/ao.h
@@ -29,7 +29,7 @@
 /* Stack runs from above the allocated __data space to 0xfe, which avoids
  * writing to 0xff as that triggers the stack overflow indicator
  */
-#define AO_STACK_START 0x7f
+#define AO_STACK_START 0x5c
 #define AO_STACK_END   0xfe
 #define AO_STACK_SIZE  (AO_STACK_END - AO_STACK_START + 1)
 
index 73c301ac325bf847320a8e6a1f413d1b4b3a357f..74cbb7b12f7727a91487688a595cca93fa11e775 100644 (file)
--- a/ao_cmd.c
+++ b/ao_cmd.c
 #define SYNTAX_ERROR   2
 #define SUCCESS                0
 
-static __data uint16_t lex_i;
-static __data uint8_t  lex_c;
-static __data uint8_t  lex_status;
-static __data uint8_t  lex_echo;
+static __xdata uint16_t lex_i;
+static __xdata uint8_t lex_c;
+static __xdata uint8_t lex_status;
+static __xdata uint8_t lex_echo;
 
 #define CMD_LEN        32
 
 static __xdata uint8_t cmd_line[CMD_LEN];
-static __data uint8_t  cmd_len;
-static __data uint8_t  cmd_i;
+static __xdata uint8_t cmd_len;
+static __xdata uint8_t cmd_i;
 
 void
 putchar(char c)
@@ -56,7 +56,7 @@ getchar(void)
 static void
 put_string(char *s)
 {
-       uint8_t c;
+       __xdata uint8_t c;
        while (c = *s++)
                putchar(c);
 }
@@ -64,7 +64,7 @@ put_string(char *s)
 static void
 readline(void)
 {
-       static uint8_t c;
+       __xdata uint8_t c;
        if (lex_echo)
                put_string("> ");
        cmd_len = 0;
@@ -153,8 +153,8 @@ void
 puti(int i)
 {
        static uint8_t __xdata  num_buffer[NUM_LEN];
-       uint8_t __xdata *num_ptr = num_buffer + NUM_LEN;
-       uint8_t neg = 0;
+       uint8_t __xdata * __xdata num_ptr = num_buffer + NUM_LEN;
+       uint8_t __xdata neg = 0;
        
        *--num_ptr = '\0';
        if (i < 0) {
@@ -183,7 +183,7 @@ white(void)
 static void
 hex(void)
 {
-       uint8_t r = LEX_ERROR;
+       __xdata uint8_t r = LEX_ERROR;
        
        lex_i = 0;
        white();
@@ -207,7 +207,7 @@ hex(void)
 static void
 decimal(void)
 {
-       uint8_t r = LEX_ERROR;
+       __xdata uint8_t r = LEX_ERROR;
        
        lex_i = 0;
        white();
@@ -256,8 +256,8 @@ adc_dump(void)
 static void
 dump(void)
 {
-       uint16_t c;
-       uint8_t __xdata *start, *end;
+       __xdata uint16_t c;
+       __xdata uint8_t * __xdata start, * __xdata end;
 
        hex();
        start = (uint8_t __xdata *) lex_i;
@@ -283,9 +283,9 @@ dump(void)
 static void
 ee_dump(void)
 {
-       uint8_t b;
-       uint16_t block;
-       uint8_t i;
+       __xdata uint8_t b;
+       __xdata uint16_t block;
+       __xdata uint8_t i;
        
        hex();
        block = lex_i;
@@ -309,11 +309,11 @@ ee_dump(void)
 static void
 ee_store(void)
 {
-       uint16_t block;
-       uint8_t i;
-       uint16_t len;
-       uint8_t b;
-       uint32_t addr;
+       __xdata uint16_t block;
+       __xdata uint8_t i;
+       __xdata uint16_t len;
+       __xdata uint8_t b;
+       __xdata uint32_t addr;
 
        hex();
        block = lex_i;
@@ -372,9 +372,9 @@ debug_put(void)
 static void
 debug_get(void)
 {
-       uint16_t count;
-       uint16_t i;
-       uint8_t byte;
+       __xdata uint16_t count;
+       __xdata uint16_t i;
+       __xdata uint8_t byte;
        hex();
        if (lex_status != SUCCESS)
                return;
@@ -396,7 +396,7 @@ debug_get(void)
 static uint8_t
 getnibble(void)
 {
-       uint8_t c;
+       __xdata uint8_t c;
 
        c = getchar();
        if ('0' <= c && c <= '9')
@@ -412,10 +412,10 @@ getnibble(void)
 static void
 debug_input(void)
 {
-       uint16_t count;
-       uint16_t addr;
-       uint8_t b;
-       uint8_t i;
+       __xdata uint16_t count;
+       __xdata uint16_t addr;
+       __xdata uint8_t b;
+       __xdata uint8_t i;
 
        hex();
        count = lex_i;
@@ -438,9 +438,9 @@ debug_input(void)
 static void
 debug_output(void)
 {
-       uint16_t count;
-       uint16_t addr;
-       uint8_t b;
+       __xdata uint16_t count;
+       __xdata uint16_t addr;
+       __xdata uint8_t b;
 
        hex();
        count = lex_i;
@@ -463,7 +463,7 @@ debug_output(void)
 static void
 dump_log(void)
 {
-       uint8_t more;
+       __xdata uint8_t more;
 
        for (more = ao_log_dump_first(); more; more = ao_log_dump_next()) {
                putchar(ao_log_dump.type);
@@ -519,7 +519,7 @@ report(void)
 void
 ao_cmd(void *parameters)
 {
-       uint8_t c;
+       __xdata uint8_t c;
        (void) parameters;
 
        lex_echo = 1;
@@ -583,10 +583,10 @@ ao_cmd(void *parameters)
                
 }
 
-struct ao_task __xdata cmd_task;
+__xdata struct ao_task ao_cmd_task;
 
 void
 ao_cmd_init(void)
 {
-       ao_add_task(&cmd_task, ao_cmd);
+       ao_add_task(&ao_cmd_task, ao_cmd);
 }
index 112ea510faf3f5aa982512cd345b2bacc90b7e3f..65196ae25f17bdac47075b2c7a6910ee13e3fd3e 100644 (file)
--- a/ao_log.c
+++ b/ao_log.c
@@ -61,8 +61,8 @@ ao_log_flush(void)
 }
 
 __xdata struct ao_log_record ao_log_dump;
-static __data uint16_t ao_log_dump_flight;
-static __data uint32_t ao_log_dump_pos;
+static __xdata uint16_t ao_log_dump_flight;
+static __xdata uint32_t ao_log_dump_pos;
 
 static uint8_t
 ao_log_dump_check_data(void)
@@ -107,8 +107,8 @@ ao_log_dump_next(void)
        return ao_log_dump_check_data();
 }
 
-uint8_t        ao_log_adc_pos;
-enum flight_state ao_log_state;
+__xdata uint8_t        ao_log_adc_pos;
+__xdata enum flight_state ao_log_state;
 
 void
 ao_log(void)
index dd0471d182d3adac0784b42616f053a232bc5320..8a0c672c6211f9e72d2881c4775bc1c52aaf1e18 100644 (file)
--- a/ao_usb.c
+++ b/ao_usb.c
@@ -34,8 +34,8 @@ struct ao_task __xdata ao_usb_task;
 
 static __xdata uint16_t        ao_usb_in_bytes;
 static __xdata uint16_t        ao_usb_out_bytes;
-static __data uint8_t  ao_usb_iif;
-static __data uint8_t  ao_usb_oif;
+static __xdata uint8_t ao_usb_iif;
+static __xdata uint8_t ao_usb_oif;
 
 /* This interrupt is shared with port 2, 
  * so when we hook that up, fix this
@@ -67,20 +67,20 @@ struct ao_usb_setup {
        uint16_t        length;
 } __xdata ao_usb_setup;
 
-__data uint8_t ao_usb_ep0_state;
-uint8_t * __data ao_usb_ep0_in_data;
-__data uint8_t ao_usb_ep0_in_len;
+__xdata uint8_t ao_usb_ep0_state;
+uint8_t * __xdata ao_usb_ep0_in_data;
+__xdata uint8_t ao_usb_ep0_in_len;
 __xdata uint8_t        ao_usb_ep0_in_buf[2];
-__data uint8_t ao_usb_ep0_out_len;
+__xdata uint8_t ao_usb_ep0_out_len;
 __xdata uint8_t *__data ao_usb_ep0_out_data;
-__data uint8_t ao_usb_configuration;
+__xdata uint8_t ao_usb_configuration;
 
 /* Send an IN data packet */
 static void
 ao_usb_ep0_flush(void)
 {
-       uint8_t this_len;
-       uint8_t cs0;
+       __xdata uint8_t this_len;
+       __xdata uint8_t cs0;
        
        USBINDEX = 0;
        cs0 = USBCS0;
@@ -120,7 +120,7 @@ struct ao_usb_line_coding {
        uint8_t         data_bits;
 } ;
 
-static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
+__xdata static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
 
 /* USB descriptors in one giant block of bytes */
 static const uint8_t ao_usb_descriptors [] = 
@@ -252,9 +252,9 @@ static const uint8_t ao_usb_descriptors [] =
 static void
 ao_usb_get_descriptor(uint16_t value)
 {
-       const uint8_t   *descriptor;
-       uint8_t         type = value >> 8;
-       uint8_t         index = value;
+       const uint8_t           *__xdata descriptor;
+       __xdata uint8_t         type = value >> 8;
+       __xdata uint8_t         index = value;
 
        descriptor = ao_usb_descriptors;
        while (descriptor[0] != 0) {
@@ -275,7 +275,7 @@ ao_usb_get_descriptor(uint16_t value)
 static void
 ao_usb_ep0_fill(void)
 {
-       uint8_t len;
+       __xdata uint8_t len;
        
        USBINDEX = 0;
        len = USBCNT0;
@@ -417,7 +417,7 @@ ao_usb_ep0_setup(void)
 static void
 ao_usb_ep0(void)
 {
-       uint8_t cs0;
+       __xdata uint8_t cs0;
 
        ao_usb_ep0_state = AO_USB_EP0_IDLE;
        for (;;) {
@@ -493,7 +493,7 @@ ao_usb_putchar(uint8_t c) __critical
 uint8_t
 ao_usb_getchar(void) __critical
 {
-       uint8_t c;
+       __xdata uint8_t c;
        while (ao_usb_out_bytes == 0) {
                for (;;) {
                        USBINDEX = AO_USB_OUT_EP;