altos: Add initial TeleBT code
[fw/altos] / src / ao_stdio.c
index 7bc416e1cf2a35ccce874033f61bf583e2f93830..c7080ec147407916c59fcf174cdba68d51ea2aba 100644 (file)
@@ -21,7 +21,7 @@
  * Basic I/O functions to support SDCC stdio package
  */
 
-#define AO_NUM_STDIOS  2
+#define AO_NUM_STDIOS  (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)
 
 static __xdata struct ao_stdio stdios[AO_NUM_STDIOS];
 static __data int8_t ao_cur_stdio;
@@ -38,13 +38,14 @@ putchar(char c)
 void
 flush(void)
 {
-       stdios[ao_cur_stdio].flush();
+       if (stdios[ao_cur_stdio].flush)
+               stdios[ao_cur_stdio].flush();
 }
 
 __xdata uint8_t ao_stdin_ready;
 
 char
-getchar(void) __reentrant
+getchar(void) __reentrant __critical
 {
        char c;
        int8_t stdio = ao_cur_stdio;
@@ -65,7 +66,7 @@ getchar(void) __reentrant
 void
 ao_add_stdio(char (*pollchar)(void),
             void (*putchar)(char),
-            void (*flush)(void))
+            void (*flush)(void)) __reentrant
 {
        if (ao_num_stdios == AO_NUM_STDIOS)
                ao_panic(AO_PANIC_STDIO);