From e4002611fc614c1c323aac7575cf4eedc8d15aca Mon Sep 17 00:00:00 2001 From: Konstantin Begun Date: Wed, 10 May 2017 23:38:32 +0100 Subject: [PATCH] timer: Added an IRQ for input capture trigger (ICP) --- simavr/sim/avr_timer.c | 6 +++++- simavr/sim/avr_timer.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index 81131a1..c54bd76 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -828,13 +828,16 @@ avr_timer_reset( avr_connect_irq(&port->irq[TIMER_IRQ_OUT_COMP + compi], req.irq[0]); } } + + avr_irq_register_notify(port->irq + TIMER_IRQ_IN_ICP, avr_timer_irq_icp, p); + avr_ioport_getirq_t req = { .bit = p->icp }; if (avr_ioctl(port->avr, AVR_IOCTL_IOPORT_GETIRQ_REGBIT, &req) > 0) { // cool, got an IRQ for the input capture pin //printf("%s-%c ICP Connecting PIN IRQ %d\n", __func__, p->name, req.irq[0]->irq); - avr_irq_register_notify(req.irq[0], avr_timer_irq_icp, p); + avr_connect_irq(req.irq[0], port->irq + TIMER_IRQ_IN_ICP); } p->ext_clock_flags &= ~(AVR_TIMER_EXTCLK_FLAG_STARTED | AVR_TIMER_EXTCLK_FLAG_TN | AVR_TIMER_EXTCLK_FLAG_AS2 | AVR_TIMER_EXTCLK_FLAG_REVDIR); @@ -844,6 +847,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_IN_ICP] = "