X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fcore%2Fao_stdio.c;h=977d74b1800bdafc2cc24be64bcc99331f608ed1;hb=aa7eac32adf4c2cdf441991d02411758f2682d1e;hp=9b4ea4738f5c63317e838900e76d304792e021bf;hpb=1a84d34fa08f43a5f79b1a5f8d8de7674d04647d;p=fw%2Faltos diff --git a/src/core/ao_stdio.c b/src/core/ao_stdio.c index 9b4ea473..977d74b1 100644 --- a/src/core/ao_stdio.c +++ b/src/core/ao_stdio.c @@ -53,14 +53,14 @@ #endif #define USE_SERIAL_STDIN (USE_SERIAL_0_STDIN + \ - USE_SERIAL_1_STDIN | \ - USE_SERIAL_2_STDIN | \ - USE_SERIAL_3_STDIN | \ - USE_SERIAL_4_STDIN | \ - USE_SERIAL_5_STDIN | \ - USE_SERIAL_6_STDIN | \ - USE_SERIAL_7_STDIN | \ - USE_SERIAL_8_STDIN | \ + USE_SERIAL_1_STDIN + \ + USE_SERIAL_2_STDIN + \ + USE_SERIAL_3_STDIN + \ + USE_SERIAL_4_STDIN + \ + USE_SERIAL_5_STDIN + \ + USE_SERIAL_6_STDIN + \ + USE_SERIAL_7_STDIN + \ + USE_SERIAL_8_STDIN + \ USE_SERIAL_9_STDIN) #define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN) @@ -96,13 +96,15 @@ flush(void) __xdata uint8_t ao_stdin_ready; char -getchar(void) __reentrant __critical +getchar(void) __reentrant { - char c; - int8_t stdio = ao_cur_stdio; + int c; + int8_t stdio; + ao_arch_block_interrupts(); + stdio = ao_cur_stdio; for (;;) { - c = ao_stdios[stdio].pollchar(); + c = ao_stdios[stdio]._pollchar(); if (c != AO_READ_AGAIN) break; if (++stdio == ao_num_stdios) @@ -111,6 +113,7 @@ getchar(void) __reentrant __critical ao_sleep(&ao_stdin_ready); } ao_cur_stdio = stdio; + ao_arch_release_interrupts(); return c; } @@ -121,13 +124,13 @@ ao_echo(void) } int8_t -ao_add_stdio(char (*pollchar)(void), +ao_add_stdio(int (*_pollchar)(void), void (*putchar)(char), void (*flush)(void)) __reentrant { if (ao_num_stdios == AO_NUM_STDIOS) ao_panic(AO_PANIC_STDIO); - ao_stdios[ao_num_stdios].pollchar = pollchar; + ao_stdios[ao_num_stdios]._pollchar = _pollchar; ao_stdios[ao_num_stdios].putchar = putchar; ao_stdios[ao_num_stdios].flush = flush; ao_stdios[ao_num_stdios].echo = 1;