> On Behalf Of Weddington, Eric > > On Behalf Of Michael Clift > > > > Hi Robert, just a thought... > > > > If the user wanted to programatically assign ISR's to either your > > library handleInterrupt<id>() functions, or their own > > functions, then maybe the main application should contain ISR()'s > > which call function pointers? The function pointers could then > > be loaded with either the address of your library functions, or > > the users own functions. > > > > That could work... Those are typically called "callback" > functions. Note that there is a tradeoff with doing that: > Because a function will be called in an ISR, the ISR prologue > and epilogue will be bloated out because of having to > save/restore a lot of registers. Just a warning.
One other caveat - this idea won't work consistently without some juggling on an ATmega2560 (or any AVR with more than 128 Kbytes of Flash). You will need to force all of the ISRs and the targets of the function pointers into the bottom half of flash to avoid the 16-bit function pointer limitation. It's actually pretty simple to work up a mildly customized linker script and a macro for the function targets and ISRs to force them into special memory section in low memory. See my posting in AVRFreaks.net under Tutorials for FreeRTOS on the ATmega2560 for an example of how to do this. Best regards, Stu Bell DataPlay (DPHI, Inc.) _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list