Adding an argument to PAL event callbacks
Posted: Wed Apr 12, 2017 12:20 am
I was excited to see that the PAL driver is getting events -- this seems like it'll be a much better way to handle sharing of interrupt resources between modules than the EXT driver.
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:
with the event enable function then defined to be:
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.
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.