]> granicus.if.org Git - esp-idf/commitdiff
emac:optimise tcpip_adapter and fix emac_dev.c
authormorris <maoshengrong@espressif.com>
Wed, 15 Aug 2018 08:33:32 +0000 (16:33 +0800)
committermorris <maoshengrong@espressif.com>
Mon, 20 Aug 2018 11:52:48 +0000 (19:52 +0800)
1. move CONFIG_xx macros to Kconfig
2. fix a bug that make EMAC_DMAOPERATION_MODE_ERG mess

components/ethernet/emac_dev.c
components/tcpip_adapter/Kconfig
components/tcpip_adapter/include/tcpip_adapter.h
components/tcpip_adapter/tcpip_adapter_lwip.c

index cceea4f1b5834b72e3729914803371b01d70eb68..9ec1822bb53897d7de0a5929539c370a7a81e9b5 100644 (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_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)
index eecf120540a99278c6fde5dfddca8fa023445463..5c76b66d13e972ff62f800cbb1c8df8cd7369ec8 100644 (file)
@@ -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
index 7ab31d1c12bf9a7d49357db23706869781127f10..4644bd81ed09afd7f0dec2d98ed64c61ba189e31 100644 (file)
  * 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 <stdint.h>
 #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);
index 8198cb34463c6fed186372cf7a1d327604bbcb05..31b9db24e895288c994d7a04422a52e64b2cadde 100644 (file)
@@ -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;