1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12950 from gschorcht/cpu/esp32/lwip_eth

pkg/lwip: add support for esp32 Ethernet device
This commit is contained in:
benpicco 2019-12-16 10:33:47 +01:00 committed by GitHub
commit 8c4498ad8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 7 deletions

View File

@ -67,7 +67,7 @@
* not provide an argument that could be used as pointer to the ESP-ETH
* device which triggers the interrupt.
*/
static esp_eth_netdev_t _esp_eth_dev;
esp_eth_netdev_t _esp_eth_dev;
/* device thread stack */
static char _esp_eth_stack[ESP_ETH_STACKSIZE];
@ -280,7 +280,7 @@ static int _esp_eth_get(netdev_t *netdev, netopt_t opt, void *val, size_t max_le
switch (opt) {
case NETOPT_ADDRESS:
assert(max_len == ETHERNET_ADDR_LEN);
assert(max_len >= ETHERNET_ADDR_LEN);
esp_eth_get_mac((uint8_t *)val);
return ETHERNET_ADDR_LEN;
case NETOPT_LINK_CONNECTED:
@ -385,8 +385,10 @@ static const netdev_driver_t _esp_eth_driver =
extern esp_err_t esp_system_event_add_handler (system_event_cb_t handler,
void *arg);
void auto_init_esp_eth (void)
void esp_eth_setup(esp_eth_netdev_t* dev)
{
(void)dev;
LOG_TAG_INFO("esp_eth", "initializing ESP32 Ethernet MAC (EMAC) device\n");
/* initialize locking */
@ -403,11 +405,16 @@ void auto_init_esp_eth (void)
_esp_eth_dev.link_up = false;
_esp_eth_dev.rx_len = 0;
_esp_eth_dev.tx_len = 0;
}
void auto_init_esp_eth(void)
{
esp_eth_setup(&_esp_eth_dev);
_esp_eth_dev.netif = gnrc_netif_ethernet_create(_esp_eth_stack,
ESP_ETH_STACKSIZE,
ESP_ETH_PRIO,
"netdev-esp-eth",
(netdev_t *)&_esp_eth_dev);
ESP_ETH_STACKSIZE,
ESP_ETH_PRIO,
"esp_eth",
(netdev_t *)&_esp_eth_dev);
}
#endif /* MODULE_ESP_ETH */

View File

@ -38,6 +38,10 @@
#include "socket_zep_params.h"
#endif
#ifdef MODULE_ESP_ETH
#include "esp-eth/esp_eth_netdev.h"
#endif
#ifdef MODULE_ESP_WIFI
#include "esp-wifi/esp_wifi_netdev.h"
#endif
@ -67,6 +71,10 @@
#define LWIP_NETIF_NUMOF ARRAY_SIZE(socket_zep_params)
#endif
#ifdef MODULE_ESP_ETH /* is mutual exclusive with above ifdef */
#define LWIP_NETIF_NUMOF (1)
#endif
#ifdef MODULE_ESP_WIFI /* is mutual exclusive with above ifdef */
#define LWIP_NETIF_NUMOF (1)
#endif
@ -95,6 +103,11 @@ static mrf24j40_t mrf24j40_devs[LWIP_NETIF_NUMOF];
static socket_zep_t socket_zep_devs[LWIP_NETIF_NUMOF];
#endif
#ifdef MODULE_ESP_ETH
extern esp_eth_netdev_t _esp_eth_dev;
extern void esp_eth_setup (esp_eth_netdev_t* dev);
#endif
#ifdef MODULE_ESP_WIFI
extern esp_wifi_netdev_t _esp_wifi_dev;
extern void esp_wifi_setup (esp_wifi_netdev_t* dev);
@ -145,6 +158,21 @@ void lwip_bootstrap(void)
return;
}
}
#elif defined(MODULE_ESP_ETH)
esp_eth_setup(&_esp_eth_dev);
#ifdef MODULE_LWIP_IPV4
if (netif_add(&netif[0], IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY,
&_esp_eth_dev, lwip_netdev_init, tcpip_input) == NULL) {
DEBUG("Could not add esp_eth device\n");
return;
}
#else /* MODULE_LWIP_IPV4 */
if (netif_add(&netif[0], &_esp_eth_dev, lwip_netdev_init,
tcpip_input) == NULL) {
DEBUG("Could not add esp_eth device\n");
return;
}
#endif /* MODULE_LWIP_IPV4 */
#elif defined(MODULE_ESP_WIFI)
esp_wifi_setup(&_esp_wifi_dev);
if (netif_add(&netif[0], &_esp_wifi_dev, lwip_netdev_init,