cores: Use correct extint control register
[simavr] / simavr / sim / avr_extint.h
index be54c30..8beb356 100644 (file)
@@ -65,7 +65,8 @@ void avr_extint_init(avr_t * avr, avr_extint_t * p);
 
 // Declares a typical INT into a avr_extint_t in a core.
 // this is a shortcut since INT declarations are pretty standard.
-// The Tinies are slightly different. see sim_tinyx5.h
+// The Tinies as well as the atmega1280 are slightly different.
+// See sim_tinyx5.h and sim_mega1280.h
 #define AVR_EXTINT_DECLARE(_index, _portname, _portpin) \
                .eint[_index] = { \
                        .port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
@@ -78,6 +79,18 @@ void avr_extint_init(avr_t * avr, avr_extint_t * p);
                        },\
                }
 
+#define AVR_EXTINT_MEGA_DECLARE(_index, _portname, _portpin, _EICR) \
+               .eint[_index] = { \
+                       .port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
+                       .port_pin = _portpin, \
+                       .isc = { AVR_IO_REGBIT(EICR##_EICR, ISC##_index##0), AVR_IO_REGBIT(EICR##_EICR, ISC##_index##1) },\
+                       .vector = { \
+                               .enable = AVR_IO_REGBIT(EIMSK, INT##_index), \
+                               .raised = AVR_IO_REGBIT(EIFR, INTF##_index), \
+                               .vector = INT##_index##_vect, \
+                       },\
+               }
+
 #define AVR_EXTINT_TINY_DECLARE(_index, _portname, _portpin, _IFR) \
                .eint[_index] = { \
                        .port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \