Skip to content

Commit

Permalink
Merge pull request buserror#301 from aznoohwee/bugfix/polling-flag-wi…
Browse files Browse the repository at this point in the history
…thin-isr

allow polling interrupt flag within ISR
  • Loading branch information
buserror authored Jul 26, 2018
2 parents b3e5922 + dd79f41 commit b3a8e8f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions simavr/sim/sim_interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,26 @@ avr_raise_interrupt(
{
if (!vector || !vector->vector)
return 0;
if (vector->pending) {
if (vector->trace)
printf("IRQ%d:I=%d already raised (enabled %d) (cycle %lld pc 0x%x)\n",
vector->vector, !!avr->sreg[S_I], avr_regbit_get(avr, vector->enable),
(long long int)avr->cycle, avr->pc);
return 0;
}

if (vector->trace)
printf("IRQ%d raising (enabled %d)\n",
vector->vector, avr_regbit_get(avr, vector->enable));

// always mark the 'raised' flag to one, even if the interrupt is disabled
// this allow "polling" for the "raised" flag, like for non-interrupt
// driven UART and so so. These flags are often "write one to clear"
if (vector->raised.reg)
avr_regbit_set(avr, vector->raised);

if (vector->pending) {
if (vector->trace)
printf("IRQ%d:I=%d already raised (enabled %d) (cycle %lld pc 0x%x)\n",
vector->vector, !!avr->sreg[S_I], avr_regbit_get(avr, vector->enable),
(long long int)avr->cycle, avr->pc);

return 0;
}

avr_raise_irq(vector->irq + AVR_INT_IRQ_PENDING, 1);
avr_raise_irq(avr->interrupts.irq + AVR_INT_IRQ_PENDING, 1);

Expand Down

0 comments on commit b3a8e8f

Please sign in to comment.