From 80da5988ce9cdccce293fb084880638f1657c52d Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Sun, 27 Feb 2011 20:34:07 +0000 Subject: [PATCH] uart: Touchup on the xon/xoff IRQs Set/reset XON & XOFF irqs following the status of the fifo. It means they can be added to a VCD file and help debug a "part". Signed-off-by: Michel Pollet --- simavr/sim/avr_uart.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/simavr/sim/avr_uart.c b/simavr/sim/avr_uart.c index 3193575..a297bb9 100644 --- a/simavr/sim/avr_uart.c +++ b/simavr/sim/avr_uart.c @@ -71,8 +71,8 @@ static uint8_t avr_uart_rxc_read(struct avr_t * avr, avr_io_addr_t addr, void * usleep(1); } // if reception is idle and the fifo is empty, tell whomever there is room - if (avr_regbit_get(avr, p->rxen) && uart_fifo_isempty(&p->input)) - avr_raise_irq(p->io.irq + UART_IRQ_OUT_XON, 1); + if (avr_regbit_get(avr, p->rxen)) + avr_raise_irq(p->io.irq + UART_IRQ_OUT_XON, uart_fifo_isempty(&p->input) != 0); return v; } @@ -185,8 +185,7 @@ static void avr_uart_irq_input(struct avr_irq_t * irq, uint32_t value, void * pa // printf("UART IRQ in %02x (%d/%d) %s\n", value, p->input.read, p->input.write, uart_fifo_isfull(&p->input) ? "FULL!!" : ""); - if (uart_fifo_isfull(&p->input)) - avr_raise_irq(p->io.irq + UART_IRQ_OUT_XOFF, 1); + avr_raise_irq(p->io.irq + UART_IRQ_OUT_XOFF, uart_fifo_isfull(&p->input) != 0); } @@ -254,6 +253,9 @@ void avr_uart_init(avr_t * avr, avr_uart_t * p) // allocate this module's IRQ avr_io_setirqs(&p->io, AVR_IOCTL_UART_GETIRQ(p->name), UART_IRQ_COUNT, NULL); + // Only call callbacks when the value change... + p->io.irq[UART_IRQ_OUT_XOFF].flags |= IRQ_FLAG_FILTERED; + p->io.irq[UART_IRQ_OUT_XON].flags |= IRQ_FLAG_FILTERED; avr_register_io_write(avr, p->r_udr, avr_uart_write, p); avr_register_io_write(avr, p->udrc.enable.reg, avr_uart_write, p); -- 2.39.5