Skip to content

Commit

Permalink
pkg/lwip: Move nrf802154 to netif auto init
Browse files Browse the repository at this point in the history
  • Loading branch information
yarrick committed Aug 20, 2021
1 parent 1897b57 commit 9002da3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 28 deletions.
28 changes: 0 additions & 28 deletions pkg/lwip/contrib/lwip.c
Expand Up @@ -27,14 +27,6 @@
#include "socket_zep_params.h"
#endif

#ifdef MODULE_NRF802154
#include "nrf802154.h"
#endif

#if IS_USED(MODULE_NETDEV_IEEE802154_SUBMAC)
#include "net/netdev/ieee802154_submac.h"
#endif

#include "lwip.h"
#include "lwip_init_devs.h"

Expand All @@ -45,11 +37,6 @@
#define LWIP_NETIF_NUMOF ARRAY_SIZE(socket_zep_params)
#endif

/* is mutual exclusive with above ifdef */
#ifdef MODULE_NRF802154
#define LWIP_NETIF_NUMOF (1)
#endif

#ifdef LWIP_NETIF_NUMOF
static struct netif netif[LWIP_NETIF_NUMOF];
#endif
Expand All @@ -58,10 +45,6 @@ static struct netif netif[LWIP_NETIF_NUMOF];
static socket_zep_t socket_zep_devs[LWIP_NETIF_NUMOF];
#endif

#ifdef MODULE_NRF802154
static netdev_ieee802154_submac_t nrf802154_netdev;
#endif

void lwip_bootstrap(void)
{
lwip_netif_init_devs();
Expand All @@ -76,17 +59,6 @@ void lwip_bootstrap(void)
return;
}
}
#elif defined(MODULE_NRF802154)
netdev_register(&nrf802154_netdev.dev.netdev, NETDEV_NRF802154, 0);
netdev_ieee802154_submac_init(&nrf802154_netdev);

nrf802154_hal_setup(&nrf802154_netdev.submac.dev);
nrf802154_init();
if (netif_add_noaddr(&netif[0], &nrf802154_netdev.dev.netdev, lwip_netdev_init,
tcpip_6lowpan_input) == NULL) {
DEBUG("Could not add nrf802154 device\n");
return;
}
#endif
#endif
/* also allow for external interface definition */
Expand Down
43 changes: 43 additions & 0 deletions pkg/lwip/init_devs/auto_init_nrf802154.c
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 Inria
*
* 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 NRF802154 network interfaces
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Erik Ekman <eekman@google.com>
*/

#include "nrf802154.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 nrf802154_netdev;

void auto_init_nrf802154(void)
{
netdev_register(&nrf802154_netdev.dev.netdev, NETDEV_NRF802154, 0);
netdev_ieee802154_submac_init(&nrf802154_netdev);

nrf802154_hal_setup(&nrf802154_netdev.submac.dev);
nrf802154_init();
if (lwip_add_6lowpan(&netif, &nrf802154_netdev.dev.netdev) == NULL) {
DEBUG("Could not add nrf802154 device\n");
return;
}
}
/** @} */
5 changes: 5 additions & 0 deletions pkg/lwip/init_devs/init.c
Expand Up @@ -76,6 +76,11 @@ void lwip_netif_init_devs(void)
extern void auto_init_mrf24j40(void);
auto_init_mrf24j40();
}

if (IS_USED(MODULE_NRF802154)) {
extern void auto_init_nrf802154(void);
auto_init_nrf802154();
}
}

struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state)
Expand Down

0 comments on commit 9002da3

Please sign in to comment.