irq->value not updated by the time callbacks are run

15 views
Skip to first unread message

Gergő Érdi

unread,
Jul 30, 2017, 7:35:22 AM7/30/17
to simavr
Hi,

What is the intended semantics of `irq->value` from inside an irq callback?

I've been playing around with it using the following code: https://gist.github.com/gergoerdi/37448e22eb92542f6ac8284ae2952bc8
The important bit is that I make an irq myself, then connect it to an AVR pin, and then I attach callbacks to both pins:


    avr_irq_t *external_trigger = avr_alloc_irq(&(avr->irq_pool), 0, 1, &trigger_name);
    avr_irq_t *internal_trigger = avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 1);

    avr_irq_register_notify(external_trigger, ext_cb, internal_trigger);
    avr_irq_register_notify(internal_trigger, int_cb, external_trigger);

    avr_connect_irq(internal_trigger, external_trigger);

In ext_cb and int_cb, I am printing both the value as supplied to the callback (which is, of course, the new value of the irq), as well as the value of external_trigger and internal_trigger:

ext_cb: arg = 00 external->value = 01 internal->value = 01
int_cb: arg = 00 external->value = 00 internal->value = 01
ext_cb: arg = 01 external->value = 00 internal->value = 00
int_cb: arg = 01 external->value = 01 internal->value = 00

So what I can observe is that when the AVR pin's value changes, this triggers the external, connected irq before updating its value; then, after the cb runs and after the external irq's value is updated, it then runs the internal pin's cb before updating the internal pin's irq's value. Is this correct? Is this the intended behavior, or is this unspecified? 

Thanks,
Gergo

Peter Ross

unread,
Jul 30, 2017, 9:45:44 AM7/30/17
to simavr+un...@googlegroups.com, simavr
> --
> You received this message because you are subscribed to the Google Groups "simavr" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to simavr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Reply all
Reply to author
Forward
0 new messages