We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 90dca3e + 0453ec8 commit 1ce3462Copy full SHA for 1ce3462
simavr/cores/sim_mega2560.h
@@ -102,7 +102,17 @@ const struct mcu_t {
102
AVR_IOPORT_DECLARE(f, 'F', F),
103
AVR_IOPORT_DECLARE(g, 'G', G),
104
AVR_IOPORT_DECLARE(h, 'H', H),
105
- AVR_IOPORT_DECLARE(j, 'J', J),
+ .portj = {
106
+ .name = 'J', .r_port = PORTJ, .r_ddr = DDRJ, .r_pin = PINJ,
107
+ .pcint = {
108
+ .enable = AVR_IO_REGBIT(PCICR, PCIE1),
109
+ .raised = AVR_IO_REGBIT(PCIFR, PCIF1),
110
+ .vector = PCINT1_vect,
111
+ .mask = 0b11111110,
112
+ .shift = -1
113
+ },
114
+ .r_pcint = PCMSK1,
115
116
AVR_IOPORT_DECLARE(k, 'K', K),
117
AVR_IOPORT_DECLARE(l, 'L', L),
118
@@ -353,7 +363,7 @@ const struct mcu_t {
353
363
.r_tcnt = TCNT2,
354
364
// asynchronous timer source bit.. if set, use 32khz frequency
355
365
.as2 = AVR_IO_REGBIT(ASSR, AS2),
356
-
366
+
357
367
.overflow = {
358
368
.enable = AVR_IO_REGBIT(TIMSK2, TOIE2),
359
369
.raised = AVR_IO_REGBIT(TIFR2, TOV2),
simavr/sim/avr_ioport.c
@@ -153,7 +153,18 @@ avr_ioport_irq_notify(
153
154
if (p->r_pcint) {
155
// if the pcint bit is on, try to raise it
156
- int raise = avr->data[p->r_pcint] & mask;
+ int raisedata = avr->data[p->r_pcint];
157
+ uint8_t uiRegMask = p->pcint.mask;
158
+ int8_t iShift = p->pcint.shift;
159
+ if (uiRegMask) // If mask is 0, do nothing (backwards compat)
160
+ raisedata &= uiRegMask; // Mask off
161
162
+ if (iShift>0) // Shift data if necessary for alignment.
163
+ raisedata <<= iShift;
164
+ else if (iShift<0)
165
+ raisedata >>= -iShift;
166
167
+ int raise = raisedata & mask;
168
if (raise)
169
avr_raise_interrupt(avr, &p->pcint);
170
}
@@ -279,4 +290,3 @@ void avr_ioport_init(avr_t * avr, avr_ioport_t * p)
279
290
avr_register_io_write(avr, p->r_pin, avr_ioport_pin_write, p);
280
291
avr_register_io_write(avr, p->r_ddr, avr_ioport_ddr_write, p);
281
292
282
simavr/sim/sim_interrupts.h
@@ -42,6 +42,9 @@ typedef struct avr_int_vector_t {
42
avr_regbit_t enable; // IO register index for the "interrupt enable" flag for this vector
43
avr_regbit_t raised; // IO register index for the register where the "raised" flag is (optional)
44
45
+ uint8_t mask; // Mask for PCINTs. this is needed for chips like the 2560 where PCINT do not align with IRQs
46
+ int8_t shift; // PCINT8 = E0, PCINT9-15 are on J0-J6. Shift shifts down (<0) or up (>0) for alignment with IRQ#.
47
48
// 'pending' IRQ, and 'running' status as signaled here
49
avr_irq_t irq[AVR_INT_IRQ_COUNT];
50
uint8_t pending : 1, // 1 while scheduled in the fifo
0 commit comments