Skip to content

Commit

Permalink
pkg/lwip: add auto-init support for transciever ENC28J60
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciusss89 committed Jan 31, 2020
1 parent 1506ed3 commit c8426ce
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/lwip/contrib/lwip.c
Expand Up @@ -28,6 +28,11 @@
#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"
Expand Down Expand Up @@ -63,6 +68,10 @@
#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
Expand Down Expand Up @@ -95,6 +104,10 @@ static netdev_tap_t netdev_taps[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
Expand Down Expand Up @@ -149,6 +162,23 @@ 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]);
#ifdef MODULE_LWIP_IPV4
if (netif_add(&netif[0], IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY,
&enc28j60_devs[i], lwip_netdev_init, tcpip_input) == NULL) {
DEBUG("Could not add enc28j60 device\n");
return;
}
#else /* MODULE_LWIP_IPV4 */
if (netif_add(&netif[0], &enc28j60_devs[i], lwip_netdev_init,
tcpip_input) == NULL) {
DEBUG("Could not add enc28j60 device\n");
return;
}
#endif /* MODULE_LWIP_IPV4 */
}
#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]);
Expand Down

0 comments on commit c8426ce

Please sign in to comment.