From: Jakob Gruber <jakob.gruber@gmail.com>
Date: Tue, 31 Jul 2012 10:43:46 +0000 (+0200)
Subject: interrupts: Introduce raise_sticky flag
X-Git-Tag: v1.0~39
X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=33c05fb002222858d4fc18f7175324d9e738dae5;p=sx%2Fsimavr.git

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.
---

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