Nothing to do with the flag, sorry, but this caught my eye:
ASSERT(callback);
...
if (INVALID_PIN_NUMBER != pin) {
callback(pin);
break; /* stop processing this interrupt */
}
ASSERT() is generally there to force a crash on some unexpected situation during development, but you would normally disable them for production. If you do that here and callback is not defined, the ISR will crash. But if you leave the assert enabled, the ISR will crash anyway.
I think that it would be better to check for callback being defined before you call it regardless (i.e. if (callback) callback(pin)
, which makes it safe. The assert can then be left in for development to tell you it's screwed, but disabling it won't cause an issue for production.