From 1de5b34adfa7d09309ad782d08ac20e73f1415eb Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 4 Sep 2020 11:25:56 +0200 Subject: [PATCH] auto_init/cc2538_rf: add support for SubMAC --- .../gnrc/netif/init_devs/auto_init_cc2538_rf.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c b/sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c index 302cda7e24..bd49f1961e 100644 --- a/sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c +++ b/sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c @@ -19,6 +19,8 @@ #include "log.h" #include "net/gnrc/netif/ieee802154.h" +#include "net/ieee802154/radio.h" +#include "net/netdev/ieee802154_submac.h" #include "cc2538_rf.h" @@ -31,7 +33,12 @@ #define CC2538_MAC_PRIO (GNRC_NETIF_PRIO) #endif +#if IS_USED(MODULE_IEEE802154_RADIO_HAL) +extern ieee802154_dev_t cc2538_rf_dev; +static netdev_ieee802154_submac_t cc2538_rf_submac; +#else static cc2538_rf_t cc2538_rf_dev; +#endif static char _cc2538_rf_stack[CC2538_MAC_STACKSIZE]; static gnrc_netif_t _netif; @@ -39,10 +46,18 @@ void auto_init_cc2538_rf(void) { LOG_DEBUG("[auto_init_netif] initializing cc2538 radio\n"); + netdev_t *netdev; +#if IS_USED(MODULE_IEEE802154_RADIO_HAL) + netdev_ieee802154_submac_init(&cc2538_rf_submac, &cc2538_rf_dev); + netdev = (netdev_t*) &cc2538_rf_submac; + cc2538_init(); +#else + netdev = &cc2538_rf_dev.netdev.netdev; cc2538_setup(&cc2538_rf_dev); +#endif gnrc_netif_ieee802154_create(&_netif, _cc2538_rf_stack, CC2538_MAC_STACKSIZE, CC2538_MAC_PRIO, "cc2538_rf", - (netdev_t *)&cc2538_rf_dev); + netdev); } /** @} */