uint8_t mode = avr_regbit_get(avr, p->comp[comp].com);
avr_irq_t * irq = &p->io.irq[TIMER_IRQ_OUT_COMP + comp];
+ uint32_t flags = 0;
+ if (p->comp[comp].com_pin.reg) // we got a physical pin
+ flags |= AVR_IOPORT_OUTPUT;
+ AVR_LOG(avr, LOG_TRACE, "Timer comp: irq %p, mode %d @%d\n", irq, mode, when);
switch (mode) {
case avr_timer_com_normal: // Normal mode OCnA disconnected
break;
case avr_timer_com_toggle: // Toggle OCnA on compare match
if (p->comp[comp].com_pin.reg) // we got a physical pin
avr_raise_irq(irq,
- AVR_IOPORT_OUTPUT |
+ flags |
(avr_regbit_get(avr, p->comp[comp].com_pin) ? 0 : 1));
else // no pin, toggle the IRQ anyway
avr_raise_irq(irq,
p->io.irq[TIMER_IRQ_OUT_COMP + comp].value ? 0 : 1);
break;
case avr_timer_com_clear:
- avr_raise_irq(irq, 0);
+ avr_raise_irq(irq, flags | 0);
break;
case avr_timer_com_set:
- avr_raise_irq(irq, 1);
+ avr_raise_irq(irq, flags | 1);
break;
}