I'm writing a program that will need timer interrupts (which I haven't used on Arduino before).
The program can operate in several modes, each needing its own interrupt code. Because time is critical in interrupt handlers I'd rather not have code like
if (mode == foo) do this; else do that;
but rather replace the entire interrupt handler when switching between modes. Example code i have seen uses a macro ISR() which seems to do two things:
1) define code one might want to use as an interrupt handler. 2) ensure that the code following ISR will be called when a particular interrupt triggers.
Is there a way to switch interrupt handlers under program control? I've seen attachInterrupt(), but it claims to be for "external" interrupts only, and I suppose timer interrupts are "internal".