[riot-notifications] [RIOT-OS/RIOT] RDM: The 802.15.4 Radio HAL (#13943)

José Alamos notifications at github.com
Mon May 25 16:08:19 CEST 2020


> We could have a small shim thread that only deals with reading the IRQ status register when woken by the IRQ. It could then trigger the appropriate action in the radio HAL.

Since the IRQ processing is somehow device dependent, maybe we would get the best out of all if we decouple the `irq_handler` from the HAL. I explain:

Most SoC radios don't need a Bottom Half Processor to detect which event occurred. As described above, we don't gain so much with copying the event and processing it later within the `irq_handler`. So, we can just call the Event Notification callback within ISR context.

In case a radio needs a Bottom Half Processor, the "irq_handler" should still probably be fast enough in most cases to handle other events from other devices. So, it can be seen as a "software ISR".

In practice, both the real and software ISR would do something like "event_post(&the_event, &ev_queue);" to handle the event, so the user of the Radio HAL would always see that such event come "from an interrupt".

Also, radios with shared IRQ can expose their own mechanism to resolve into the corresponding Radio HAL pointer.

In a nutshell:

### SoC radios
Event Notification is called from interrupt context with the right event and pointer to the HAL. No need to expose the internal ISR function.

### SPI radios (with shared and non shared IRQ line)
The trick is to expose the ISR function of the device and the "irq_handler". The "irq_handler" should resolve to an Event Notification callback with a pointer to the HAL instance.

For instance, we could assume by convention that the first element of the device descriptor is the IRQ handlerI would expect the `AT86RF215` device descriptor to be something like this:
```c
struct at86rf215_t {
    irq_handler_t irq_handler; /**< IRQ handler function */
    ieee802154_dev_t radio_subghz; /**< SubGHz radio */
    ieee802154_dev_t radio_24gh; /**< 2.4 GHz radio */
}

...

void _irq_handler(void *arg)
{
    at86rf215_t *dev = arg;
    if (at86rf215_radio_that_triggered_event(dev) == SUBGHZ) {
        dev->radio_subghz->cb(&dev->radio_subghz, which_event(dev));
    }
    else {
        dev->radio_24ghz->cb(&dev->radio_24ghz, which_event(dev));
    }
}

...

void at86rf215_init(at86rf215_t *dev, void (*isr)(void *arg))
{
   ...
   gpio_init_int(..., isr, dev); /* Register ISR callback */
}

...

How does this sound?
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/13943#issuecomment-633589810
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200525/ff41169a/attachment-0001.htm>


More information about the notifications mailing list