X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao_serial.c;h=ce11694002162ea5b70ab650c25f2c6dc14cae5f;hp=a2292980c21b66cf1489cbcdc45ae9ac0c5138e5;hb=35ac66969abe24ca23776618306a59fc17770e06;hpb=43c8f7012102cdb591ace899420c10e4a78385ad diff --git a/ao_serial.c b/ao_serial.c index a2292980..ce116940 100644 --- a/ao_serial.c +++ b/ao_serial.c @@ -17,30 +17,9 @@ #include "ao.h" -#define SERIAL_FIFO 32 - -struct ao_fifo { - uint8_t insert; - uint8_t remove; - uint8_t fifo[SERIAL_FIFO]; -}; - volatile __xdata struct ao_fifo ao_usart1_rx_fifo; volatile __xdata struct ao_fifo ao_usart1_tx_fifo; -#define ao_fifo_insert(f,c) do { \ - (f).fifo[(f).insert] = (c); \ - (f).insert = ((f).insert + 1) & (SERIAL_FIFO-1); \ -} while(0) - -#define ao_fifo_remove(f,c) do {\ - c = (f).fifo[(f).remove]; \ - (f).remove = ((f).remove + 1) & (SERIAL_FIFO-1); \ -} while(0) - -#define ao_fifo_full(f) ((((f).insert + 1) & (SERIAL_FIFO-1)) == (f).remove) -#define ao_fifo_empty(f) ((f).insert == (f).remove) - void ao_serial_rx1_isr(void) interrupt 3 { @@ -71,10 +50,10 @@ ao_serial_tx1_isr(void) interrupt 14 ao_wakeup(&ao_usart1_tx_fifo); } -uint8_t +char ao_serial_getchar(void) __critical { - uint8_t c; + char c; while (ao_fifo_empty(ao_usart1_rx_fifo)) ao_sleep(&ao_usart1_rx_fifo); ao_fifo_remove(ao_usart1_rx_fifo, c); @@ -82,7 +61,7 @@ ao_serial_getchar(void) __critical } void -ao_serial_putchar(uint8_t c) __critical +ao_serial_putchar(char c) __critical { while (ao_fifo_full(ao_usart1_tx_fifo)) ao_sleep(&ao_usart1_tx_fifo); @@ -101,7 +80,7 @@ send_serial(void) } __code struct ao_cmds ao_serial_cmds[] = { - { 'S', send_serial, "S Send data to serial line\n" }, + { 'S', send_serial, "S Send data to serial line" }, { 0, send_serial, NULL }, };