Common pin change interrupt handling

This is a work in progress. Currently it suffers from some linking issues.