HI Michael,

> If you want to allow that behavior in C, it looks like that:
>
> typedef void (*funcpointer)(void);
>
> funcpointer     fp;
>
> ISR(TIMER1_OVF_vect)
> {
>          if (fp)
>                  (*fp)();
> }
>
> Attention: The function pointer has to be set with interrupts disabled,
> because of changing a word and on the AVR isn't atomically.

There's already a vector table. Each entry consists of an rjmp (or
jmp) instruction to a named routine. Right now the ISR macros uses
numbers to line up the routines. By creating a new macro which
declares the ISR handler correctly, but uses a name rather than a
number, you could then write a function which fabricates the
appropriate rjmp (or jmp) instruction and stuffs into the existing
vector table. No performance hit at all.

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/


_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to