Commit 574c005c878b186dec3a1cef3ca41e16d8200305
authorvintagepc <53943260+vintagepc@users.noreply.github.com>
Wed, 5 Aug 2020 01:54:08 +0000 (21:54 -0400)
committervintagepc <53943260+vintagepc@users.noreply.github.com>
Wed, 5 Aug 2020 01:54:08 +0000 (21:54 -0400)
2 files changed:
simavr/sim/avr_timer.c
simavr/sim/avr_timer.h

index 3fcfd8b8554adf8caaafefbc75e8cf97438b7262..f85b884a8e84bd049f73f74f7dc342613f64ad3c 100644 (file)
@@ -624,6 +624,8 @@ avr_timer_write_ocr(
                                avr_timer_reconfigure(timer, 0); // if OCRA is the top, reconfigure needed
                        }
                        avr_raise_irq(timer->io.irq + TIMER_IRQ_OUT_PWM1, _timer_get_ocr(timer, AVR_TIMER_COMPB));
+                       if (sizeof(timer->comp)>2)
+                               avr_raise_irq(timer->io.irq + TIMER_IRQ_OUT_PWM2, _timer_get_ocr(timer, AVR_TIMER_COMPC));
                        break;
                case avr_timer_wgm_fast_pwm:
                        if (oldv != _timer_get_comp_ocr(avr, comp))
@@ -632,6 +634,9 @@ avr_timer_write_ocr(
                                        _timer_get_ocr(timer, AVR_TIMER_COMPA));
                        avr_raise_irq(timer->io.irq + TIMER_IRQ_OUT_PWM1,
                                        _timer_get_ocr(timer, AVR_TIMER_COMPB));
+                       if (sizeof(timer->comp)>2)
+                               avr_raise_irq(timer->io.irq + TIMER_IRQ_OUT_PWM2,
+                                               _timer_get_ocr(timer, AVR_TIMER_COMPC));
                        break;
                default:
                        AVR_LOG(avr, LOG_WARNING, "TIMER: %s-%c mode %d UNSUPPORTED\n",
@@ -851,6 +856,7 @@ avr_timer_reset(
 static const char * irq_names[TIMER_IRQ_COUNT] = {
        [TIMER_IRQ_OUT_PWM0] = "8>pwm0",
        [TIMER_IRQ_OUT_PWM1] = "8>pwm1",
+       [TIMER_IRQ_OUT_PWM2] = "8>pwm2",
        [TIMER_IRQ_IN_ICP] = "<icp",
        [TIMER_IRQ_OUT_COMP + 0] = ">compa",
        [TIMER_IRQ_OUT_COMP + 1] = ">compb",
@@ -883,6 +889,7 @@ avr_timer_init(
        // pwm value it makes sense not to bother.
        p->io.irq[TIMER_IRQ_OUT_PWM0].flags |= IRQ_FLAG_FILTERED;
        p->io.irq[TIMER_IRQ_OUT_PWM1].flags |= IRQ_FLAG_FILTERED;
+       p->io.irq[TIMER_IRQ_OUT_PWM2].flags |= IRQ_FLAG_FILTERED;
 
        if (p->wgm[0].reg) // these are not present on older AVRs
                avr_register_io_write(avr, p->wgm[0].reg, avr_timer_write, p);
index 8e998571e433336c3498d34ebf00b3dbc08edb61..fd503983ec75c48aa900813da95994db98e24fcf 100644 (file)
@@ -39,6 +39,7 @@ enum {
 enum {
        TIMER_IRQ_OUT_PWM0 = 0,
        TIMER_IRQ_OUT_PWM1,
+       TIMER_IRQ_OUT_PWM2,
        TIMER_IRQ_IN_ICP,       // input capture
        TIMER_IRQ_OUT_COMP,     // comparator pins output IRQ
 
@@ -71,7 +72,7 @@ enum {
        avr_timer_com_toggle,   // Toggle OCnx on compare match
        avr_timer_com_clear,    // clear OCnx on compare match
        avr_timer_com_set,      // set OCnx on compare match
-       
+
 };
 
 enum {