Merge branch 'feature/move_CONFIG_TCPIP_LWIP_to_menuconfig' into 'master'

tcpip_adapter: optimise tcpip_adapter and fix a bug in emac_dev.c

See merge request idf/esp-idf!3017
This commit is contained in:
Ivan Grokhotkov 2018-08-21 11:37:15 +08:00
commit a6a9484084
4 changed files with 28 additions and 15 deletions

View file

@ -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_FWD_UNDER_GF);
REG_SET_BIT(EMAC_DMAOPERATION_MODE_REG, EMAC_OPT_SECOND_FRAME); REG_SET_BIT(EMAC_DMAOPERATION_MODE_REG, EMAC_OPT_SECOND_FRAME);
REG_SET_FIELD(EMAC_DMABUSMODE_REG, EMAC_PROG_BURST_LEN, 4); 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) void emac_mac_enable_txrx(void)

View file

@ -1,4 +1,4 @@
menu "tcpip adapter" menu "TCP/IP Adapter"
config IP_LOST_TIMER_INTERVAL config IP_LOST_TIMER_INTERVAL
int "IP Address lost timer interval (seconds)" 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. The IP lost timer is stopped if the station get the IP again before
the timer expires. 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 endmenu

View file

@ -33,15 +33,13 @@
* get free station list APIs in application side. Other APIs are used in esp-idf internal, * get free station list APIs in application side. Other APIs are used in esp-idf internal,
* otherwise the state maybe wrong. * 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 <stdint.h> #include <stdint.h>
#include "rom/queue.h" #include "rom/queue.h"
#include "esp_wifi_types.h" #include "esp_wifi_types.h"
#include "sdkconfig.h"
#define CONFIG_TCPIP_LWIP 1
#define CONFIG_DHCP_STA_LIST 1
#if CONFIG_TCPIP_LWIP #if CONFIG_TCPIP_LWIP
#include "lwip/ip_addr.h" #include "lwip/ip_addr.h"
@ -81,7 +79,6 @@ typedef struct {
typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t; typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t;
#if CONFIG_DHCP_STA_LIST
typedef struct { typedef struct {
uint8_t mac[6]; uint8_t mac[6];
ip4_addr_t ip; ip4_addr_t ip;
@ -91,12 +88,10 @@ typedef struct {
tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM];
int num; int num;
} tcpip_adapter_sta_list_t; } tcpip_adapter_sta_list_t;
#endif
#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_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_IF_NOT_READY ESP_ERR_TCPIP_ADAPTER_BASE + 0x02
#define ESP_ERR_TCPIP_ADAPTER_DHCPC_START_FAILED ESP_ERR_TCPIP_ADAPTER_BASE + 0x03 #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_NO_MEM ESP_ERR_TCPIP_ADAPTER_BASE + 0x06
#define ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED ESP_ERR_TCPIP_ADAPTER_BASE + 0x07 #define ESP_ERR_TCPIP_ADAPTER_DHCP_NOT_STOPPED ESP_ERR_TCPIP_ADAPTER_BASE + 0x07
/* TODO: add Ethernet interface */
typedef enum { typedef enum {
TCPIP_ADAPTER_IF_STA = 0, /**< ESP32 station interface */ TCPIP_ADAPTER_IF_STA = 0, /**< ESP32 station interface */
TCPIP_ADAPTER_IF_AP, /**< ESP32 soft-AP 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); 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); 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 * @return ESP_IF_WIFI_STA
* ESP_IF_WIFI_AP * ESP_IF_WIFI_AP
ESP_IF_ETH * ESP_IF_ETH
* ESP_IF_MAX * ESP_IF_MAX
*/ */
esp_interface_t tcpip_adapter_get_esp_if(void *dev); esp_interface_t tcpip_adapter_get_esp_if(void *dev);

View file

@ -161,7 +161,7 @@ static esp_err_t tcpip_adapter_update_default_netif(void)
return ESP_OK; 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; netif_init_fn netif_init;