altos: Remove stdio from stm-flash
authorKeith Packard <keithp@keithp.com>
Sat, 27 Apr 2013 07:25:36 +0000 (00:25 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 8 May 2013 04:30:26 +0000 (21:30 -0700)
This saves enough memory to fit in under 4kB

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm-flash/Makefile
src/stm-flash/ao_pins.h
src/stm-flash/ao_stm_flash.c

index a4dd5ab8f452e192a155caa0a6148d88080bccca..1ea35581c41d0da7af115da74aed1154189c43e6 100644 (file)
@@ -23,16 +23,15 @@ ALTOS_SRC = \
        ao_notask.c \
        ao_timer.c \
        ao_usb_stm.c \
        ao_notask.c \
        ao_timer.c \
        ao_usb_stm.c \
-       ao_stdio.c \
        ao_flash_stm.c
 
        ao_flash_stm.c
 
-PRODUCT=StmFlash-v0.0
-PRODUCT_DEF=-DSTM_FLASH
+PRODUCT=AltosFlash-$(VERSION)
+PRODUCT_DEF=-DALTOS_FLASH
 IDPRODUCT=0x000a
 
 CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -g -Os
 
 IDPRODUCT=0x000a
 
 CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -g -Os
 
-PROG=stm-flash-$(VERSION).elf
+PROG=altos-flash-$(VERSION).elf
 
 SRC=$(ALTOS_SRC) ao_stm_flash.c
 OBJ=$(SRC:.c=.o)
 
 SRC=$(ALTOS_SRC) ao_stm_flash.c
 OBJ=$(SRC:.c=.o)
index 8fb56f7bf36de0c0041b8d03de715a01b3a46994..d6c7265348e317856ff0f474bcaccec66a39e81d 100644 (file)
@@ -45,7 +45,7 @@
 #define AO_RCC_CFGR_PPRE2_DIV  STM_RCC_CFGR_PPRE2_DIV_1
 
 #define HAS_USB                        1
 #define AO_RCC_CFGR_PPRE2_DIV  STM_RCC_CFGR_PPRE2_DIV_1
 
 #define HAS_USB                        1
-#define USE_USB_STDIN          1
+#define USE_USB_STDIO          0
 #define HAS_BEEP               0
 #define HAS_TASK               0
 #define HAS_ECHO               0
 #define HAS_BEEP               0
 #define HAS_TASK               0
 #define HAS_ECHO               0
@@ -71,9 +71,9 @@
 #define AO_BOOT_CHAIN          1
 #define AO_BOOT_PIN            1
 
 #define AO_BOOT_CHAIN          1
 #define AO_BOOT_PIN            1
 
-#define AO_BOOT_APPLICATION_GPIO       stm_gpioa
-#define AO_BOOT_APPLICATION_PIN                0
+#define AO_BOOT_APPLICATION_GPIO       stm_gpiod
+#define AO_BOOT_APPLICATION_PIN                2
 #define AO_BOOT_APPLICATION_VALUE      1
 #define AO_BOOT_APPLICATION_VALUE      1
-#define AO_BOOT_APPLICATION_MODE       0
+#define AO_BOOT_APPLICATION_MODE       AO_EXTI_MODE_PULL_UP
 
 #endif /* _AO_PINS_H_ */
 
 #endif /* _AO_PINS_H_ */
index df06bb098accb473efa3d12e8723448ee9c262ee..f85807350763628f596958f401dba528951e3bfc 100644 (file)
@@ -30,8 +30,11 @@ void
 ao_put_string(__code char *s)
 {
        char    c;
 ao_put_string(__code char *s)
 {
        char    c;
-       while ((c = *s++))
-               putchar(c);
+       while ((c = *s++)) {
+               if (c == '\n')
+                       ao_usb_putchar('\r');
+               ao_usb_putchar(c);
+       }
 }
 
 void
 }
 
 void
@@ -47,7 +50,7 @@ ao_get_hex32(void)
        uint32_t v = 0;
 
        for (;;) {
        uint32_t v = 0;
 
        for (;;) {
-               n = getchar();
+               n = ao_usb_getchar();
                if (n != ' ')
                        break;
        }
                if (n != ' ')
                        break;
        }
@@ -61,7 +64,7 @@ ao_get_hex32(void)
                else
                        break;
                v = (v << 4) | n;
                else
                        break;
                v = (v << 4) | n;
-               n = getchar();
+               n = ao_usb_getchar();
        }
        return v;
 }
        }
        return v;
 }
@@ -91,7 +94,7 @@ ao_block_write(void)
                return;
        }
        for (i = 0; i < 256; i++)
                return;
        }
        for (i = 0; i < 256; i++)
-               u.data8[i] = getchar();
+               u.data8[i] = ao_usb_getchar();
        ao_flash_page(p, u.data32);
 }
 
        ao_flash_page(p, u.data32);
 }
 
@@ -105,23 +108,25 @@ ao_block_read(void)
 
        for (i = 0; i < 256; i++) {
                c = *p++;
 
        for (i = 0; i < 256; i++) {
                c = *p++;
-               putchar(c);
+               ao_usb_putchar(c);
        }
 }
 
 static void
 ao_show_version(void)
 {
        }
 }
 
 static void
 ao_show_version(void)
 {
-       puts("altos-loader");
-       ao_put_string("manufacturer     "); puts(ao_manufacturer);
-       ao_put_string("product          "); puts(ao_product);
-       ao_put_string("software-version "); puts(ao_version);
+       ao_put_string("altos-loader");
+       ao_put_string("\nmanufacturer     "); ao_put_string(ao_manufacturer);
+       ao_put_string("\nproduct          "); ao_put_string(ao_product);
+       ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
+       ao_put_string("\n");
 }
 
 static void
 ao_flash_task(void) {
        for (;;) {
 }
 
 static void
 ao_flash_task(void) {
        for (;;) {
-               switch (getchar()) {
+               ao_usb_flush();
+               switch (ao_usb_getchar()) {
                case 'v': ao_show_version(); break;
                case 'a': ao_application(); break;
                case 'X': ao_block_erase(); break;
                case 'v': ao_show_version(); break;
                case 'a': ao_application(); break;
                case 'X': ao_block_erase(); break;