altos: Allow building with newlib + avr stdio on ARM
authorKeith Packard <keithp@keithp.com>
Mon, 11 Dec 2017 02:34:49 +0000 (18:34 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 11 Dec 2017 20:20:25 +0000 (12:20 -0800)
Redefines some stdio bits so that we can build with either pdclib or
newlib + avr stdio.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/cc1111/ao_arch.h
src/kernel/ao_stdio.c
src/kernel/ao_task.h
src/lambdakey-v1.0/Makefile
src/stm/ao_serial_stm.c
src/stmf0/Makefile-stmf0.defs

index bacfabb87f53852ba1f63b1803e15f178f76f120..937e6d0c615745695d7efa64cc18a8ca0b36ef5a 100644 (file)
@@ -234,6 +234,10 @@ ao_button_get(uint16_t timeout) __critical;
 void
 ao_button_clear(void) __critical;
 
+/* console I/O funcs */
+#define ao_getchar getchar
+#define ao_putchar putchar
+
 /* ao_string.c */
 
 void
index f0ee0a14e5070f3b0c61b800dec4eda9526b7edf..dc09b5c772cb37fab569824f25dbe9e602cce8bb 100644 (file)
@@ -84,7 +84,7 @@ __pdata int8_t ao_cur_stdio;
 #endif
 
 void
-putchar(char c)
+ao_putchar(char c)
 {
 #if LOW_LEVEL_DEBUG
        if (!ao_cur_task) {
@@ -110,7 +110,7 @@ flush(void)
 __xdata uint8_t ao_stdin_ready;
 
 char
-getchar(void) __reentrant
+ao_getchar(void) __reentrant
 {
        int c;
        int8_t stdio;
index 30b018ffe36aff064afb91b0a8fe1c41e1a20483..7549b59838d6abbc4c85a22e5b42ae4ce7e9449e 100644 (file)
@@ -44,6 +44,9 @@ struct ao_task {
        ao_arch_task_members            /* any architecture-specific fields */
        uint8_t task_id;                /* unique id */
        __code char *name;              /* task name */
+#ifdef NEWLIB
+       int __errno;                    /* storage for errno in newlib libc */
+#endif
 #if HAS_TASK_QUEUE
        struct ao_list  queue;
        struct ao_list  alarm_queue;
index 6b819ffb752fe770dd213ddb15c5450942c69104..4eb045b6ff8d9a10df326e383ae273aa8929e437 100644 (file)
@@ -54,7 +54,7 @@ MAP=$(PROG).map
 NEWLIB=/local/newlib-mini
 MAPFILE=-Wl,-M=$(MAP)
 LDFLAGS=-L../stmf0 -L$(NEWLIB)/arm-none-eabi/lib/thumb/v6-m/ -Wl,-Tlambda.ld $(MAPFILE) -nostartfiles
-AO_CFLAGS=-I. -I../stmf0 -I../kernel -I../drivers -I.. -I../scheme -isystem $(NEWLIB)/arm-none-eabi/include
+AO_CFLAGS=-I. -I../stmf0 -I../kernel -I../drivers -I.. -I../scheme -isystem $(NEWLIB)/arm-none-eabi/include -DNEWLIB
 
 PROGNAME=lambdakey-v1.0
 PROG=$(PROGNAME)-$(VERSION).elf
index ef56231334e28894a980f08042a1e72c8530a40f..2afee5b5da3bd9cc2b9b957e3056cdd1cbc2f9b7 100644 (file)
@@ -60,13 +60,13 @@ _ao_usart_cts(struct ao_stm_usart *usart)
 #endif
 
 static void
-_ao_usart_rx(struct ao_stm_usart *usart, int stdin)
+_ao_usart_rx(struct ao_stm_usart *usart, int is_stdin)
 {
        if (usart->reg->sr & (1 << STM_USART_SR_RXNE)) {
                if (!ao_fifo_full(usart->rx_fifo)) {
                        ao_fifo_insert(usart->rx_fifo, usart->reg->dr);
                        ao_wakeup(&usart->rx_fifo);
-                       if (stdin)
+                       if (is_stdin)
                                ao_wakeup(&ao_stdin_ready);
 #if HAS_SERIAL_SW_FLOW
                        /* If the fifo is nearly full, turn off RTS and wait
@@ -84,9 +84,9 @@ _ao_usart_rx(struct ao_stm_usart *usart, int stdin)
 }
 
 static void
-ao_usart_isr(struct ao_stm_usart *usart, int stdin)
+ao_usart_isr(struct ao_stm_usart *usart, int is_stdin)
 {
-       _ao_usart_rx(usart, stdin);
+       _ao_usart_rx(usart, is_stdin);
 
        if (!_ao_usart_tx_start(usart))
                usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
index f2c53499347be2dcb0b1ca53432dd80cd2a09924..fa6e6e860ebc68a0d6fbd3db4ea91918678d2ab2 100644 (file)
@@ -4,7 +4,7 @@ endif
 
 include $(TOPDIR)/Makedefs
 
-vpath % $(TOPDIR)/stmf0:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/kernel:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR)/aes:$(TOPDIR):$(TOPDIR)/math:$(TOPDIR)/lisp
+vpath % $(TOPDIR)/stmf0:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/kernel:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR)/aes:$(TOPDIR):$(TOPDIR)/math:$(TOPDIR)/scheme
 vpath make-altitude $(TOPDIR)/util
 vpath make-kalman $(TOPDIR)/util
 vpath kalman.5c $(TOPDIR)/kalman