From: Michel Pollet Date: Sun, 27 Feb 2011 20:34:07 +0000 (+0000) Subject: uart: Touchup on the xon/xoff IRQs X-Git-Tag: v1.0a7~4 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=80da5988ce9cdccce293fb084880638f1657c52d;p=sx%2Fsimavr.git 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 --- 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);