[riot-notifications] [RIOT-OS/RIOT] cpu/atmega: WIP implementation of pin change interrupts (#7610)

Robert Hartung notifications at github.com
Mon Sep 18 15:35:30 CEST 2017


@kYc0o Sorry, should've made it clear that this is a problem on boards where you need almost all pins, because the context switch interrupt occupies the whole port.

> However, as this PR makes use of all PCINT pins available on a given CPU, interrupts will be triggered at each context switch, which if I understand correctly is the problem you're stating too.

The only conflict will happen if you're using both at the same time (pin change + context swap on one port). Context switching already has some overhead anyway, thus checking the last state of the port against the current one, and check if only the context swap pin changed seems to be the best solution to me by now. Of course this has to be done for every single context switch :/

```c
#define AVR_CONTEXT_SWITCH_MASK (1 << PIN4)
uint8_t gpio_state [NUM_PORTS];
ISR(...) {
  if(AVR_CONTEXT_SWITCH_PORT ^ gpio_state[AVR_CONTEXT_SWITCH_PORT_NUM] == AVR_CONTEXT_SWITCH_MASK) {
    do_context_switch();
  } else {
    handle_pin_change_interrupts(AVR_CONTEXT_SWITCH_PORT_NUM);
  }
}
```

Maybe we need to use #ifdef here to enable this, or as you already suggest, we can just leave it as is and ignore the PCINT for the context swap for now and make it *not* usable for pin change interrupts with a big hint in the documentation?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7610#issuecomment-330222720
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170918/3899cb5c/attachment-0001.html>


More information about the notifications mailing list