From f6d6df03826083a244715b88a30ad681f17b4510 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 27 Apr 2013 00:25:36 -0700 Subject: [PATCH] altos: Remove stdio from stm-flash This saves enough memory to fit in under 4kB Signed-off-by: Keith Packard --- src/stm-flash/Makefile | 7 +++---- src/stm-flash/ao_pins.h | 8 ++++---- src/stm-flash/ao_stm_flash.c | 27 ++++++++++++++++----------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/stm-flash/Makefile b/src/stm-flash/Makefile index a4dd5ab8..1ea35581 100644 --- a/src/stm-flash/Makefile +++ b/src/stm-flash/Makefile @@ -23,16 +23,15 @@ ALTOS_SRC = \ ao_notask.c \ ao_timer.c \ ao_usb_stm.c \ - ao_stdio.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 -PROG=stm-flash-$(VERSION).elf +PROG=altos-flash-$(VERSION).elf SRC=$(ALTOS_SRC) ao_stm_flash.c OBJ=$(SRC:.c=.o) diff --git a/src/stm-flash/ao_pins.h b/src/stm-flash/ao_pins.h index 8fb56f7b..d6c72653 100644 --- a/src/stm-flash/ao_pins.h +++ b/src/stm-flash/ao_pins.h @@ -45,7 +45,7 @@ #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 @@ -71,9 +71,9 @@ #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_MODE 0 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP #endif /* _AO_PINS_H_ */ diff --git a/src/stm-flash/ao_stm_flash.c b/src/stm-flash/ao_stm_flash.c index df06bb09..f8580735 100644 --- a/src/stm-flash/ao_stm_flash.c +++ b/src/stm-flash/ao_stm_flash.c @@ -30,8 +30,11 @@ void 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 @@ -47,7 +50,7 @@ ao_get_hex32(void) uint32_t v = 0; for (;;) { - n = getchar(); + n = ao_usb_getchar(); if (n != ' ') break; } @@ -61,7 +64,7 @@ ao_get_hex32(void) else break; v = (v << 4) | n; - n = getchar(); + n = ao_usb_getchar(); } return v; } @@ -91,7 +94,7 @@ ao_block_write(void) return; } for (i = 0; i < 256; i++) - u.data8[i] = getchar(); + u.data8[i] = ao_usb_getchar(); ao_flash_page(p, u.data32); } @@ -105,23 +108,25 @@ ao_block_read(void) for (i = 0; i < 256; i++) { c = *p++; - putchar(c); + ao_usb_putchar(c); } } 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 (;;) { - 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; -- 2.30.2