diff --git a/pkg/lwip/contrib/lwip.c b/pkg/lwip/contrib/lwip.c index 7775fb97ed..a33bb8e649 100644 --- a/pkg/lwip/contrib/lwip.c +++ b/pkg/lwip/contrib/lwip.c @@ -37,10 +37,6 @@ #include "socket_zep_params.h" #endif -#ifdef MODULE_SAM0_ETH -#include "sam0_eth_netdev.h" -#endif - #ifdef MODULE_STM32_ETH #include "stm32_eth.h" #endif @@ -72,10 +68,6 @@ #endif /* is mutual exclusive with above ifdef */ -#ifdef MODULE_SAM0_ETH -#define LWIP_NETIF_NUMOF (1) -#endif - #ifdef MODULE_STM32_ETH #define LWIP_NETIF_NUMOF (1) #endif @@ -100,11 +92,6 @@ static mrf24j40_t mrf24j40_devs[LWIP_NETIF_NUMOF]; static socket_zep_t socket_zep_devs[LWIP_NETIF_NUMOF]; #endif -#ifdef MODULE_SAM0_ETH -static netdev_t sam0_eth; -extern void sam0_eth_setup(netdev_t *netdev); -#endif - #ifdef MODULE_STM32_ETH static netdev_t stm32_eth; extern void stm32_eth_netdev_setup(netdev_t *netdev); @@ -146,13 +133,6 @@ void lwip_bootstrap(void) return; } } -#elif defined(MODULE_SAM0_ETH) - sam0_eth_setup(&sam0_eth); - if (netif_add_noaddr(&netif[0], &sam0_eth, lwip_netdev_init, - tcpip_input) == NULL) { - DEBUG("Could not add sam0_eth device\n"); - return; - } #elif defined(MODULE_STM32_ETH) stm32_eth_netdev_setup(&stm32_eth); if (netif_add_noaddr(&netif[0], &stm32_eth, lwip_netdev_init, diff --git a/pkg/lwip/init_devs/auto_init_sam0_eth.c b/pkg/lwip/init_devs/auto_init_sam0_eth.c new file mode 100644 index 0000000000..f3b7743c39 --- /dev/null +++ b/pkg/lwip/init_devs/auto_init_sam0_eth.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) Benjamin Valentin + * + * 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 sam0_eth network interfaces + * + * @author Benjamin Valentin + * @author Erik Ekman + */ + +#include "sam0_eth_netdev.h" + +#include "lwip_init_devs.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +static netdev_t sam0_eth; +extern void sam0_eth_setup(netdev_t *netdev); + +static struct netif netif; + +void auto_init_sam0_eth(void) +{ + sam0_eth_setup(&sam0_eth); + if (lwip_add_ethernet(&netif, &sam0_eth) == NULL) { + DEBUG("Could not add sam0_eth device\n"); + return; + } +} +/** @} */ diff --git a/pkg/lwip/init_devs/init.c b/pkg/lwip/init_devs/init.c index b716136f2f..2bc251b4ee 100644 --- a/pkg/lwip/init_devs/init.c +++ b/pkg/lwip/init_devs/init.c @@ -44,6 +44,11 @@ void lwip_netif_init_devs(void) auto_init_esp_wifi(); } + if (IS_USED(MODULE_SAM0_ETH)) { + extern void auto_init_sam0_eth(void); + auto_init_sam0_eth(); + } + if (IS_USED(MODULE_NETDEV_TAP)) { extern void auto_init_netdev_tap(void); auto_init_netdev_tap();