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

José Alamos notifications at github.com
Thu May 14 16:47:26 CEST 2020

@maribu @benpicco @PeterKietzmann I wrote a PoC (at86rf2xx) patch that uses the technique described in https://github.com/RIOT-OS/RIOT/pull/13943#issuecomment-628641459 for a blocking send function.

<details><summary> <b> PATCH </b> </summary>

diff --git a/drivers/at86rf2xx/at86rf2xx_radio_ops.c b/drivers/at86rf2xx/at86rf2xx_radio_ops.c
index 43825f369e..a0c6d391c8 100644
--- a/drivers/at86rf2xx/at86rf2xx_radio_ops.c
+++ b/drivers/at86rf2xx/at86rf2xx_radio_ops.c
@@ -286,7 +286,18 @@ static int set_promiscuous(ieee802154_dev_t *dev, bool enable)
     return 0;
-int at86rf2xx_init(at86rf2xx_t *dev, const at86rf2xx_params_t *params, void (*isr)(void *arg))
+static void _isr(void *arg)
+    ieee802154_dev_t *dev = arg;
+    if (((at86rf2xx_t*) dev)->trx_state == AT86RF2XX_TRX_STATE_TX_ON) {
+        dev->cb(dev, IEEE802154_RF_CONFIRM);
+    }
+    else {
+        dev->cb(dev, IEEE802154_RF_INDICATION);
+    }
+int at86rf2xx_init(at86rf2xx_t *dev, const at86rf2xx_params_t *params)
     /* State to return after receiving or transmitting */
     dev->trx_state = AT86RF2XX_STATE_TRX_OFF;
@@ -301,7 +312,7 @@ int at86rf2xx_init(at86rf2xx_t *dev, const at86rf2xx_params_t *params, void (*is
     gpio_init(dev->params.reset_pin, GPIO_OUT);
-    gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, isr, dev);
+    gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, _isr, dev);
     /* Intentionally check if bus can be acquired,
        since getbus() drops the return value */
diff --git a/drivers/include/at86rf2xx.h b/drivers/include/at86rf2xx.h
index 6255e266cd..24a4be51fa 100644
--- a/drivers/include/at86rf2xx.h
+++ b/drivers/include/at86rf2xx.h
@@ -532,7 +532,7 @@ void at86rf2xx_set_internal_state(const at86rf2xx_t *dev, int state);
 void at86rf2xx_sleep(at86rf2xx_t *dev);
 void at86rf2xx_init_int(at86rf2xx_t *dev);
-int at86rf2xx_init(at86rf2xx_t *dev, const at86rf2xx_params_t *params, void (*isr)(void *arg));
+int at86rf2xx_init(at86rf2xx_t *dev, const at86rf2xx_params_t *params);
 #ifdef __cplusplus
diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h
index 071991e168..869c7403ad 100644
--- a/sys/include/net/ieee802154/radio.h
+++ b/sys/include/net/ieee802154/radio.h
@@ -108,6 +108,8 @@ typedef enum {
      * @brief the transceiver received a packet but the CRC check failed
+    IEEE802154_RF_CONFIRM,
 } ieee802154_trx_ev_t;
 typedef struct {
@@ -138,7 +140,7 @@ typedef struct ieee802154_dev ieee802154_dev_t;
  * @param[in] status the status 
 typedef void (*ieee802154_cb_t)(ieee802154_dev_t *dev,
-                                ieee802154_tx_status_t status);
+                                ieee802154_trx_ev_t status);
  * @brief the IEEE802.15.4 device descriptor


The radio generates an RF_CONFIRM event if it waits for a TX_DONE event. I use that to unlock a mutex and immediately call the `irq_handler`. I think we could go with this pattern.

Maybe we should think on separating the `irq_notification` (RF_CONFIRM, RF_INDICATION) and "event_notification" function? The `irq_notification` function might be reused by several stacks, but the `event_notification` part is stack specific. 

What do you think? 

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200514/6dd51119/attachment.htm>

More information about the notifications mailing list