Correct, the ISR offload logic is right.
If you don’t want to use global state variables you can do something like this:
typedef struct sx127x_bhp {
event_t event;
sx127x_t dev;
} sx127x_bhp_t;
static sx127x_bhp_t sx127x_ctx = {.event.handler = _handler_high }; /**< use this one for the device descriptor and the event handler */
/* e.g access the device with*/
netdev_t *netdev = &sx127x_ctx.dev.netdev;
...
/* Re-implement _handler_high to get driver from the event. */
static void _handler_high(event_t *event) {
/* Cast back `event` into `sx127x_bhp_t` */
sx127x_bhp_t ctx = (sx127x_bhp_t*) event;
ctx->dev.netdev.driver->isr(&ctx->dev.netdev);
}
...
static void _event_cb(netdev_t *dev, netdev_event_t event)
{
if (event == NETDEV_EVENT_ISR) {
#ifdef with_event
event_post(EVENT_PRIO_HIGHEST, &sx127x_ctx.event);
#else
dev->driver->isr(dev);
#endif
}