X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_serial.c;h=7bc11b979ac38137abd5e62c4a263711c5f097bf;hp=e926b4e4fb24d656a04fbea8434e2b169440669d;hb=5195fcfe239e430e1f9f11774c9a245c7b29dae9;hpb=34f148500df427c148188c0ada20bf914a7c74ba diff --git a/src/ao_serial.c b/src/ao_serial.c index e926b4e4..7bc11b97 100644 --- a/src/ao_serial.c +++ b/src/ao_serial.c @@ -50,6 +50,8 @@ ao_serial_tx1_isr(void) interrupt 14 ao_wakeup(&ao_usart1_tx_fifo); } +static __pdata serial_echo; + char ao_serial_getchar(void) __critical { @@ -57,6 +59,10 @@ ao_serial_getchar(void) __critical while (ao_fifo_empty(ao_usart1_rx_fifo)) ao_sleep(&ao_usart1_rx_fifo); ao_fifo_remove(ao_usart1_rx_fifo, c); + if (serial_echo) { + printf("%02x\n", ((int) c) & 0xff); + flush(); + } return c; } @@ -79,8 +85,16 @@ send_serial(void) } } +static void +monitor_serial(void) +{ + ao_cmd_hex(); + serial_echo = ao_cmd_lex_i != 0; +} + __code struct ao_cmds ao_serial_cmds[] = { { 'S', send_serial, "S Send data to serial line" }, + { 'M', monitor_serial, "M Monitor serial data" }, { 0, send_serial, NULL }, };