pkg/lwip: Move enc28j60 to netif auto init

This commit is contained in:
Erik Ekman 2021-08-14 18:01:34 +02:00
parent fea0c8d453
commit e8c5ff162a
3 changed files with 48 additions and 22 deletions

View File

@ -27,11 +27,6 @@
#include "at86rf2xx_params.h"
#endif
#ifdef MODULE_ENC28J60
#include "enc28j60.h"
#include "enc28j60_params.h"
#endif
#ifdef MODULE_MRF24J40
#include "mrf24j40.h"
#include "mrf24j40_params.h"
@ -68,10 +63,6 @@
#define LWIP_NETIF_NUMOF ARRAY_SIZE(at86rf2xx_params)
#endif
#ifdef MODULE_ENC28J60 /* is mutual exclusive with above ifdef */
#define LWIP_NETIF_NUMOF ARRAY_SIZE(enc28j60_params)
#endif
#ifdef MODULE_MRF24J40 /* is mutual exclusive with above ifdef */
#define LWIP_NETIF_NUMOF ARRAY_SIZE(mrf24j40_params)
#endif
@ -101,10 +92,6 @@ static struct netif netif[LWIP_NETIF_NUMOF];
static at86rf2xx_t at86rf2xx_devs[LWIP_NETIF_NUMOF];
#endif
#ifdef MODULE_ENC28J60
static enc28j60_t enc28j60_devs[LWIP_NETIF_NUMOF];
#endif
#ifdef MODULE_MRF24J40
static mrf24j40_t mrf24j40_devs[LWIP_NETIF_NUMOF];
#endif
@ -150,15 +137,6 @@ void lwip_bootstrap(void)
return;
}
}
#elif defined(MODULE_ENC28J60)
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
enc28j60_setup(&enc28j60_devs[i], &enc28j60_params[i], i);
if (netif_add_noaddr(&netif[0], &enc28j60_devs[i].netdev, lwip_netdev_init,
tcpip_input) == NULL) {
DEBUG("Could not add enc28j60 device\n");
return;
}
}
#elif defined(MODULE_SOCKET_ZEP)
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
socket_zep_setup(&socket_zep_devs[i], &socket_zep_params[i], i);

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) Giuseppe Tipaldi
*
* 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 enc28j60 network interfaces
*
* @author Giuseppe Tipaldi <ing.giuseppe.tipaldi@gmail.com>
* @author Erik Ekman <eekman@google.com>
*/
#include "enc28j60.h"
#include "enc28j60_params.h"
#include "lwip_init_devs.h"
#define ENABLE_DEBUG 0
#include "debug.h"
#define NETIF_ENC28J60_NUMOF ARRAY_SIZE(enc28j60_params)
static struct netif netif[NETIF_ENC28J60_NUMOF];
static enc28j60_t enc28j60_devs[NETIF_ENC28J60_NUMOF];
void auto_init_enc28j60(void)
{
for (unsigned i = 0; i < NETIF_ENC28J60_NUMOF; i++) {
enc28j60_setup(&enc28j60_devs[i], &enc28j60_params[i], i);
if (lwip_add_ethernet(&netif[i], &enc28j60_devs[i].netdev) == NULL) {
DEBUG("Could not add enc28j60 device\n");
return;
}
}
}
/** @} */

View File

@ -29,6 +29,11 @@ void lwip_netif_init_devs(void)
auto_init_atwinc15x0();
}
if (IS_USED(MODULE_ENC28J60)) {
extern void auto_init_enc28j60(void);
auto_init_enc28j60();
}
if (IS_USED(MODULE_ESP_ETH)) {
extern void auto_init_esp_eth(void);
auto_init_esp_eth();