diff --git a/pkg/lwip/init_devs/auto_init_at86rf215.c b/pkg/lwip/init_devs/auto_init_at86rf215.c new file mode 100644 index 0000000000..6932026581 --- /dev/null +++ b/pkg/lwip/init_devs/auto_init_at86rf215.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2021 ML!PA Consulting GmbH + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_auto_init_lwip_netif + * @{ + * + * @file + * @brief Auto initialization for at86rf215 network interfaces + * + * @author Benjamin Valentin + * @author Erik Ekman + */ + +#include "at86rf215.h" +#include "at86rf215_params.h" + +#include "lwip_init_devs.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +#define USED_BANDS (IS_USED(MODULE_AT86RF215_SUBGHZ) + IS_USED(MODULE_AT86RF215_24GHZ)) +#define NETIF_AT86RF215_NUMOF ARRAY_SIZE(at86rf215_params) + +static struct netif netif[NETIF_AT86RF215_NUMOF * USED_BANDS]; +static at86rf215_t at86rf215_devs[NETIF_AT86RF215_NUMOF * USED_BANDS]; + +static void auto_init_at86rf215(void) +{ + unsigned i = 0; + for (unsigned j = 0; j < NETIF_AT86RF215_NUMOF;j++) { + + at86rf215_t *dev_09 = NULL; + at86rf215_t *dev_24 = NULL; + struct netif *netif_09 = NULL; + struct netif *netif_24 = NULL; + + if (IS_USED(MODULE_AT86RF215_SUBGHZ)) { + dev_09 = &at86rf215_devs[i]; + netif_09 = &netif[i]; + ++i; + } + + if (IS_USED(MODULE_AT86RF215_24GHZ)) { + dev_24 = &at86rf215_devs[i]; + netif_24 = &netif[i]; + ++i; + } + + at86rf215_setup(dev_09, dev_24, &at86rf215_params[j], j); + + if (dev_09) { + if (lwip_add_6lowpan(netif_09, &dev_09->netdev.netdev) == NULL) { + DEBUG("Could not add sub-GHz at86rf215 device #%u\n", j); + } + } + if (dev_24) { + if (lwip_add_6lowpan(netif_24, &dev_24->netdev.netdev) == NULL) { + DEBUG("Could not add 2.4-GHz at86rf215 device #%u\n", j); + } + } + } +} + +LWIP_INIT_6LOWPAN_NETIF(auto_init_at86rf215); +/** @} */ diff --git a/pkg/lwip/init_devs/auto_init_cc2538_rf.c b/pkg/lwip/init_devs/auto_init_cc2538_rf.c new file mode 100644 index 0000000000..24539fd4fa --- /dev/null +++ b/pkg/lwip/init_devs/auto_init_cc2538_rf.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2021 ML!PA Consulting GmbH + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_auto_init_lwip_netif + * @{ + * + * @file + * @brief Auto initialization for cc2538 network interfaces + * + * @author Benjamin Valentin + * @author Erik Ekman + */ + +#include "cc2538_rf.h" +#include "net/netdev/ieee802154_submac.h" + +#include "lwip_init_devs.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +static struct netif netif; +static netdev_ieee802154_submac_t cc2538_rf_netdev; + +static void auto_init_cc2538_rf(void) +{ + netdev_register(&cc2538_rf_netdev.dev.netdev, NETDEV_CC2538, 0); + netdev_ieee802154_submac_init(&cc2538_rf_netdev); + cc2538_rf_hal_setup(&cc2538_rf_netdev.submac.dev); + + cc2538_init(); + + if (lwip_add_6lowpan(&netif, &cc2538_rf_netdev.dev.netdev) == NULL) { + DEBUG("Could not add CC2538 device\n"); + } +} + +LWIP_INIT_6LOWPAN_NETIF(auto_init_cc2538_rf); +/** @} */ diff --git a/pkg/lwip/init_devs/auto_init_dose.c b/pkg/lwip/init_devs/auto_init_dose.c new file mode 100644 index 0000000000..604d67b81b --- /dev/null +++ b/pkg/lwip/init_devs/auto_init_dose.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 ML!PA Consulting GmbH + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_auto_init_lwip_netif + * @{ + * + * @file + * @brief Auto initialization for DOSE network interfaces + * + * @author Benjamin Valentin + * @author Erik Ekman + */ + +#include "dose.h" +#include "dose_params.h" + +#include "lwip_init_devs.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +#define NETIF_DOSE_NUMOF ARRAY_SIZE(dose_params) + +static struct netif netif[NETIF_DOSE_NUMOF]; +static dose_t dose_devs[NETIF_DOSE_NUMOF]; + +static void auto_init_dose(void) +{ + for (unsigned i = 0; i < NETIF_DOSE_NUMOF; i++) { + dose_setup(&dose_devs[i], &dose_params[i], i); + if (lwip_add_ethernet(&netif[i], &dose_devs[i].netdev) == NULL) { + DEBUG("Could not add DOSE device #%u\n", i); + } + } +} + +LWIP_INIT_ETH_NETIF(auto_init_dose); +/** @} */