From 33c05fb002222858d4fc18f7175324d9e738dae5 Mon Sep 17 00:00:00 2001 From: Jakob Gruber Date: Tue, 31 Jul 2012 12:43:46 +0200 Subject: [PATCH] interrupts: Introduce raise_sticky flag If set, the raise bit is not cleared in avr_clear_interrupt. This corresponds to the hardware not clearing the interrupt flag when executing the interrupt routine. The only known example of this is the TWI Interrupt Flag TWINT. --- simavr/sim/sim_interrupts.c | 2 +- simavr/sim/sim_interrupts.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/simavr/sim/sim_interrupts.c b/simavr/sim/sim_interrupts.c index e84bf7d..f76375e 100644 --- a/simavr/sim/sim_interrupts.c +++ b/simavr/sim/sim_interrupts.c @@ -138,7 +138,7 @@ avr_clear_interrupt( printf("%s cleared %d\n", __FUNCTION__, vector->vector); vector->pending = 0; avr_raise_irq(&vector->irq, 0); - if (vector->raised.reg) + if (vector->raised.reg && !vector->raise_sticky) avr_regbit_clear(avr, vector->raised); } diff --git a/simavr/sim/sim_interrupts.h b/simavr/sim/sim_interrupts.h index 148b28c..2e86882 100644 --- a/simavr/sim/sim_interrupts.h +++ b/simavr/sim/sim_interrupts.h @@ -37,7 +37,9 @@ typedef struct avr_int_vector_t { avr_irq_t irq; // raised to 1 when queued, to zero when called uint8_t pending : 1, // 1 while scheduled in the fifo - trace : 1; // only for debug of a vector + trace : 1, // only for debug of a vector + raise_sticky : 1; // 1 if the interrupt flag (= the raised regbit) is not cleared + // by the hardware when executing the interrupt routine (see TWINT) } avr_int_vector_t; // interrupt vectors, and their enable/clear registers -- 2.39.5