As someone who'd like to have his cake and eat it too, however, I'd love to see palcallback_t be modified to have a generic pointer argument. Something like:
Code: Select all
typedef void (*palcallback_t)(void *);
with the event enable function then defined to be:
Code: Select all
#if !defined(pal_lld_enablepadevent) || defined(__DOXYGEN__)
#define palPadEnableEventI(port, pad, mode, callback, arg)
#else
#define palPadEnableEventI(port, pad, mode, callback, arg) \
pal_lld_enablepadevent(port, pad, mode, callback, arg)
#endif
I've found this pattern greatly increases code reusability, and avoids forcing the use of file- or project-global variables. The cost (as far as I understand it) should be fairly low -- just an extra pointer saved alongside the callback itself.
I figured this would be a good time to make the request, since PAL event handling is still in its infancy.