diff --git a/components/ethernet/emac_dev.c b/components/ethernet/emac_dev.c index cceea4f1b5..9ec1822bb5 100644 --- a/components/ethernet/emac_dev.c +++ b/components/ethernet/emac_dev.c @@ -98,7 +98,6 @@ void emac_dma_init(void) REG_SET_BIT(EMAC_DMAOPERATION_MODE_REG, EMAC_FWD_UNDER_GF); REG_SET_BIT(EMAC_DMAOPERATION_MODE_REG, EMAC_OPT_SECOND_FRAME); REG_SET_FIELD(EMAC_DMABUSMODE_REG, EMAC_PROG_BURST_LEN, 4); - REG_SET_BIT(EMAC_DMAOPERATION_MODE_REG, EMAC_DMAOPERATION_MODE_REG); } void emac_mac_enable_txrx(void) diff --git a/components/tcpip_adapter/Kconfig b/components/tcpip_adapter/Kconfig index eecf120540..5c76b66d13 100644 --- a/components/tcpip_adapter/Kconfig +++ b/components/tcpip_adapter/Kconfig @@ -1,4 +1,4 @@ -menu "tcpip adapter" +menu "TCP/IP Adapter" config IP_LOST_TIMER_INTERVAL int "IP Address lost timer interval (seconds)" @@ -13,4 +13,15 @@ config IP_LOST_TIMER_INTERVAL the timer expires. The IP lost timer is stopped if the station get the IP again before the timer expires. +choice USE_TCPIP_STACK_LIB + prompt "TCP/IP Stack Library" + default TCPIP_LWIP + help + Choose the TCP/IP Stack to work, for example, LwIP, uIP, etc. +config TCPIP_LWIP + bool "LwIP" + help + lwIP is a small independent implementation of the TCP/IP protocol suite. +endchoice + endmenu diff --git a/components/tcpip_adapter/include/tcpip_adapter.h b/components/tcpip_adapter/include/tcpip_adapter.h index 7ab31d1c12..4644bd81ed 100644 --- a/components/tcpip_adapter/include/tcpip_adapter.h +++ b/components/tcpip_adapter/include/tcpip_adapter.h @@ -33,15 +33,13 @@ * get free station list APIs in application side. Other APIs are used in esp-idf internal, * otherwise the state maybe wrong. * - * TODO: ipv6 support will be added, use menuconfig to disable CONFIG_TCPIP_LWIP + * TODO: ipv6 support will be added */ #include #include "rom/queue.h" #include "esp_wifi_types.h" - -#define CONFIG_TCPIP_LWIP 1 -#define CONFIG_DHCP_STA_LIST 1 +#include "sdkconfig.h" #if CONFIG_TCPIP_LWIP #include "lwip/ip_addr.h" @@ -81,7 +79,6 @@ typedef struct { typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t; -#if CONFIG_DHCP_STA_LIST typedef struct { uint8_t mac[6]; ip4_addr_t ip; @@ -91,12 +88,10 @@ typedef struct { tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; int num; } tcpip_adapter_sta_list_t; -#endif #endif -#define ESP_ERR_TCPIP_ADAPTER_BASE 0x5000 // TODO: move base address to esp_err.h - +#define ESP_ERR_TCPIP_ADAPTER_BASE 0x5000 #define ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS ESP_ERR_TCPIP_ADAPTER_BASE + 0x01 #define ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY ESP_ERR_TCPIP_ADAPTER_BASE + 0x02 #define ESP_ERR_TCPIP_ADAPTER_DHCPC_START_FAILED ESP_ERR_TCPIP_ADAPTER_BASE + 0x03 @@ -105,7 +100,6 @@ typedef struct { #define ESP_ERR_TCPIP_ADAPTER_NO_MEM ESP_ERR_TCPIP_ADAPTER_BASE + 0x06 #define ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED ESP_ERR_TCPIP_ADAPTER_BASE + 0x07 -/* TODO: add Ethernet interface */ typedef enum { TCPIP_ADAPTER_IF_STA = 0, /**< ESP32 station interface */ TCPIP_ADAPTER_IF_AP, /**< ESP32 soft-AP interface */ @@ -522,8 +516,17 @@ esp_err_t tcpip_adapter_dhcpc_start(tcpip_adapter_if_t tcpip_if); */ esp_err_t tcpip_adapter_dhcpc_stop(tcpip_adapter_if_t tcpip_if); - - +/** + * @brief Get data from ethernet interface + * + * This function should be installed by esp_eth_init, so Ethernet packets will be forward to TCPIP stack. + * + * @param[in] void *buffer: the received data point + * @param[in] uint16_t len: the received data length + * @param[in] void *eb: parameter + * + * @return ESP_OK + */ esp_err_t tcpip_adapter_eth_input(void *buffer, uint16_t len, void *eb); /** @@ -561,7 +564,7 @@ esp_err_t tcpip_adapter_ap_input(void *buffer, uint16_t len, void *eb); * * @return ESP_IF_WIFI_STA * ESP_IF_WIFI_AP - ESP_IF_ETH + * ESP_IF_ETH * ESP_IF_MAX */ esp_interface_t tcpip_adapter_get_esp_if(void *dev); diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 8198cb3446..31b9db24e8 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -161,7 +161,7 @@ static esp_err_t tcpip_adapter_update_default_netif(void) return ESP_OK; } -esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info) +static esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info) { netif_init_fn netif_init;