mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
Merge branch 'master' into feature/esp32s2beta_update
This commit is contained in:
@@ -1,5 +1,2 @@
|
||||
set(COMPONENT_SRCS "connect.c"
|
||||
"stdin_out.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
register_component()
|
||||
idf_component_register(SRCS "connect.c" "stdin_out.c"
|
||||
INCLUDE_DIRS "include")
|
||||
|
@@ -1,5 +1,4 @@
|
||||
menu "Example Connection Configuration"
|
||||
|
||||
choice EXAMPLE_CONNECT_INTERFACE
|
||||
prompt "Connect using"
|
||||
default EXAMPLE_CONNECT_WIFI
|
||||
@@ -15,133 +14,120 @@ menu "Example Connection Configuration"
|
||||
|
||||
endchoice
|
||||
|
||||
config EXAMPLE_WIFI_SSID
|
||||
depends on EXAMPLE_CONNECT_WIFI
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
SSID (network name) for the example to connect to.
|
||||
|
||||
config EXAMPLE_WIFI_PASSWORD
|
||||
depends on EXAMPLE_CONNECT_WIFI
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
Can be left blank if the network has no security set.
|
||||
|
||||
|
||||
choice EXAMPLE_PHY_MODEL
|
||||
prompt "Ethernet PHY"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default EXAMPLE_PHY_TLK110
|
||||
help
|
||||
Select the PHY driver to use for the example.
|
||||
|
||||
config EXAMPLE_PHY_IP101
|
||||
bool "IP101"
|
||||
if EXAMPLE_CONNECT_WIFI
|
||||
config EXAMPLE_WIFI_SSID
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
IP101 is a single port 10/100 MII/RMII/TP/Fiber Fast Ethernet Transceiver.
|
||||
Goto http://www.icplus.com.tw/pp-IP101G.html for more information about it.
|
||||
SSID (network name) for the example to connect to.
|
||||
|
||||
config EXAMPLE_PHY_TLK110
|
||||
bool "TI TLK110 PHY"
|
||||
config EXAMPLE_WIFI_PASSWORD
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
Select this to use the TI TLK110 PHY
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
Can be left blank if the network has no security set.
|
||||
endif
|
||||
|
||||
config EXAMPLE_PHY_LAN8720
|
||||
bool "Microchip LAN8720 PHY"
|
||||
if EXAMPLE_CONNECT_ETHERNET
|
||||
choice EXAMPLE_USE_ETHERNET
|
||||
prompt "Ethernet Type"
|
||||
default EXAMPLE_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32
|
||||
default EXAMPLE_USE_SPI_ETHERNET if !IDF_TARGET_ESP32
|
||||
help
|
||||
Select this to use the Microchip LAN8720 PHY
|
||||
Select which kind of Ethernet will be used in the example.
|
||||
|
||||
endchoice
|
||||
config EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
depends on IDF_TARGET_ESP32
|
||||
select ETH_USE_ESP32_EMAC
|
||||
bool "Internal EMAC"
|
||||
help
|
||||
Select internal Ethernet MAC controller.
|
||||
|
||||
config EXAMPLE_USE_SPI_ETHERNET
|
||||
bool "SPI Ethernet Module"
|
||||
select ETH_USE_SPI_ETHERNET
|
||||
help
|
||||
Select external SPI-Ethernet module.
|
||||
endchoice
|
||||
|
||||
config EXAMPLE_PHY_ADDRESS
|
||||
int "PHY Address (0-31)"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default 31
|
||||
range 0 31
|
||||
help
|
||||
Select the PHY Address (0-31) for the hardware configuration and PHY model.
|
||||
TLK110 default 31
|
||||
LAN8720 default 1 or 0
|
||||
if EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
choice EXAMPLE_ETH_PHY_MODEL
|
||||
prompt "Ethernet PHY Device"
|
||||
default EXAMPLE_ETH_PHY_IP101
|
||||
help
|
||||
Select the Ethernet PHY device to use in the example.
|
||||
|
||||
config EXAMPLE_ETH_PHY_IP101
|
||||
bool "IP101"
|
||||
help
|
||||
IP101 is a single port 10/100 MII/RMII/TP/Fiber Fast Ethernet Transceiver.
|
||||
Goto http://www.icplus.com.tw/pp-IP101G.html for more information about it.
|
||||
|
||||
choice EXAMPLE_PHY_CLOCK_MODE
|
||||
prompt "EMAC clock mode"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default EXAMPLE_PHY_CLOCK_GPIO0_IN
|
||||
help
|
||||
Select external (input on GPIO0) or internal (output on GPIO16 or GPIO17) clock
|
||||
config EXAMPLE_ETH_PHY_RTL8201
|
||||
bool "RTL8201/SR8201"
|
||||
help
|
||||
RTL8201F/SR8201F is a single port 10/100Mb Ethernet Transceiver with auto MDIX.
|
||||
Goto http://www.corechip-sz.com/productsview.asp?id=22 for more information about it.
|
||||
|
||||
config EXAMPLE_ETH_PHY_LAN8720
|
||||
bool "LAN8720"
|
||||
help
|
||||
LAN8720A is a small footprint RMII 10/100 Ethernet Transceiver with HP Auto-MDIX Support.
|
||||
Goto https://www.microchip.com/LAN8720A for more information about it.
|
||||
|
||||
config EXAMPLE_PHY_CLOCK_GPIO0_IN
|
||||
bool "GPIO0 input"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
help
|
||||
Input of 50MHz PHY clock on GPIO0.
|
||||
config EXAMPLE_ETH_PHY_DP83848
|
||||
bool "DP83848"
|
||||
help
|
||||
DP83848 is a single port 10/100Mb/s Ethernet Physical Layer Transceiver.
|
||||
Goto http://www.ti.com/product/DP83848J for more information about it.
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config EXAMPLE_PHY_CLOCK_GPIO0_OUT
|
||||
bool "GPIO0 Output"
|
||||
help
|
||||
Output the internal 50MHz RMII clock on GPIO0.
|
||||
if EXAMPLE_USE_SPI_ETHERNET
|
||||
config EXAMPLE_ETH_SPI_HOST
|
||||
int "SPI Host Number"
|
||||
range 0 2
|
||||
default 1
|
||||
help
|
||||
Set the SPI host used to communicate with DM9051.
|
||||
|
||||
config EXAMPLE_PHY_CLOCK_GPIO16_OUT
|
||||
bool "GPIO16 output"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
help
|
||||
Output the internal 50MHz APLL clock on GPIO16.
|
||||
config EXAMPLE_ETH_SCLK_GPIO
|
||||
int "SPI SCLK GPIO number"
|
||||
range 0 33
|
||||
default 19
|
||||
help
|
||||
Set the GPIO number used by SPI SCLK.
|
||||
|
||||
config EXAMPLE_PHY_CLOCK_GPIO17_OUT
|
||||
bool "GPIO17 output (inverted)"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
help
|
||||
Output the internal 50MHz APLL clock on GPIO17 (inverted signal).
|
||||
config EXAMPLE_ETH_MOSI_GPIO
|
||||
int "SPI MOSI GPIO number"
|
||||
range 0 33
|
||||
default 23
|
||||
help
|
||||
Set the GPIO number used by SPI MOSI.
|
||||
|
||||
endchoice
|
||||
config EXAMPLE_ETH_MISO_GPIO
|
||||
int "SPI MISO GPIO number"
|
||||
range 0 33
|
||||
default 25
|
||||
help
|
||||
Set the GPIO number used by SPI MISO.
|
||||
|
||||
config EXAMPLE_PHY_CLOCK_MODE
|
||||
int
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default 0 if EXAMPLE_PHY_CLOCK_GPIO0_IN
|
||||
default 1 if EXAMPLE_PHY_CLOCK_GPIO0_OUT
|
||||
default 2 if EXAMPLE_PHY_CLOCK_GPIO16_OUT
|
||||
default 3 if EXAMPLE_PHY_CLOCK_GPIO17_OUT
|
||||
config EXAMPLE_ETH_CS_GPIO
|
||||
int "SPI CS GPIO number"
|
||||
range 0 33
|
||||
default 22
|
||||
help
|
||||
Set the GPIO number used by SPI CS.
|
||||
|
||||
|
||||
config EXAMPLE_PHY_USE_POWER_PIN
|
||||
bool "Use PHY Power (enable/disable) pin"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default y
|
||||
help
|
||||
Use a GPIO "power pin" to power the PHY on/off during operation.
|
||||
Consult the example README for more details
|
||||
|
||||
config EXAMPLE_PHY_POWER_PIN
|
||||
int "PHY Power GPIO"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default 17
|
||||
range 0 33
|
||||
depends on EXAMPLE_PHY_USE_POWER_PIN
|
||||
help
|
||||
GPIO number to use for powering on/off the PHY.
|
||||
|
||||
config EXAMPLE_PHY_SMI_MDC_PIN
|
||||
int "SMI MDC Pin"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default 23
|
||||
range 0 33
|
||||
help
|
||||
GPIO number to use for SMI clock output MDC to PHY.
|
||||
|
||||
config EXAMPLE_PHY_SMI_MDIO_PIN
|
||||
int "SMI MDIO Pin"
|
||||
depends on EXAMPLE_CONNECT_ETHERNET
|
||||
default 18
|
||||
range 0 33
|
||||
help
|
||||
GPIO number to use for SMI data pin MDIO to/from PHY.
|
||||
config EXAMPLE_ETH_SPI_CLOCK_MHZ
|
||||
int "SPI clock speed (MHz)"
|
||||
range 20 80
|
||||
default 20
|
||||
help
|
||||
Set the clock speed (MHz) of SPI interface.
|
||||
endif
|
||||
endif
|
||||
|
||||
config EXAMPLE_CONNECT_IPV6
|
||||
bool "Obtain IPv6 link-local address"
|
||||
@@ -151,5 +137,4 @@ menu "Example Connection Configuration"
|
||||
help
|
||||
By default, examples will wait until IPv4 and IPv6 addresses are obtained.
|
||||
Disable this option if the network does not support IPv6.
|
||||
|
||||
endmenu
|
||||
|
@@ -23,24 +23,23 @@
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#define GOT_IPV4_BIT BIT(0)
|
||||
#define GOT_IPV6_BIT BIT(1)
|
||||
#define GOT_IPV4_BIT BIT(0)
|
||||
#define GOT_IPV6_BIT BIT(1)
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
#define CONNECTED_BITS (GOT_IPV4_BIT | GOT_IPV6_BIT)
|
||||
#define CONNECTED_BITS (GOT_IPV4_BIT | GOT_IPV6_BIT)
|
||||
#else
|
||||
#define CONNECTED_BITS (GOT_IPV4_BIT)
|
||||
#define CONNECTED_BITS (GOT_IPV4_BIT)
|
||||
#endif
|
||||
|
||||
static EventGroupHandle_t s_connect_event_group;
|
||||
static ip4_addr_t s_ip_addr;
|
||||
static const char* s_connection_name;
|
||||
static const char *s_connection_name;
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
static ip6_addr_t s_ipv6_addr;
|
||||
#endif
|
||||
|
||||
|
||||
static const char *TAG = "example_connect";
|
||||
|
||||
/* set up connection, Wi-Fi or Ethernet */
|
||||
@@ -49,20 +48,20 @@ static void start();
|
||||
/* tear down connection, release resources */
|
||||
static void stop();
|
||||
|
||||
static void on_got_ip(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
static void on_got_ip(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
memcpy(&s_ip_addr, &event->ip_info.ip, sizeof(s_ip_addr));
|
||||
xEventGroupSetBits(s_connect_event_group, GOT_IPV4_BIT);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static void on_got_ipv6(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
static void on_got_ipv6(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
ip_event_got_ip6_t* event = (ip_event_got_ip6_t*) event_data;
|
||||
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *)event_data;
|
||||
memcpy(&s_ipv6_addr, &event->ip6_info.ip, sizeof(s_ipv6_addr));
|
||||
xEventGroupSetBits(s_connect_event_group, GOT_IPV6_BIT);
|
||||
}
|
||||
@@ -100,17 +99,17 @@ esp_err_t example_disconnect()
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
static void on_wifi_disconnect(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
static void on_wifi_disconnect(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
ESP_LOGI(TAG, "Wi-Fi disconnected, trying to reconnect...");
|
||||
ESP_ERROR_CHECK( esp_wifi_connect() );
|
||||
ESP_ERROR_CHECK(esp_wifi_connect());
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static void on_wifi_connect(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
static void on_wifi_connect(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_STA);
|
||||
}
|
||||
@@ -157,87 +156,13 @@ static void stop()
|
||||
}
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PHY_LAN8720
|
||||
#include "eth_phy/phy_lan8720.h"
|
||||
#define DEFAULT_ETHERNET_PHY_CONFIG phy_lan8720_default_ethernet_config
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLE_PHY_TLK110
|
||||
#include "eth_phy/phy_tlk110.h"
|
||||
#define DEFAULT_ETHERNET_PHY_CONFIG phy_tlk110_default_ethernet_config
|
||||
#elif CONFIG_EXAMPLE_PHY_IP101
|
||||
#include "eth_phy/phy_ip101.h"
|
||||
#define DEFAULT_ETHERNET_PHY_CONFIG phy_ip101_default_ethernet_config
|
||||
#endif
|
||||
|
||||
#define PIN_PHY_POWER CONFIG_EXAMPLE_PHY_POWER_PIN
|
||||
#define PIN_SMI_MDC CONFIG_EXAMPLE_PHY_SMI_MDC_PIN
|
||||
#define PIN_SMI_MDIO CONFIG_EXAMPLE_PHY_SMI_MDIO_PIN
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PHY_USE_POWER_PIN
|
||||
/**
|
||||
* @brief re-define power enable func for phy
|
||||
*
|
||||
* @param enable true to enable, false to disable
|
||||
*
|
||||
* @note This function replaces the default PHY power on/off function.
|
||||
* If this GPIO is not connected on your device (and PHY is always powered),
|
||||
* you can use the default PHY-specific power on/off function.
|
||||
*/
|
||||
static void phy_device_power_enable_via_gpio(bool enable)
|
||||
{
|
||||
assert(DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable);
|
||||
|
||||
if (!enable) {
|
||||
DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(false);
|
||||
}
|
||||
|
||||
gpio_pad_select_gpio(PIN_PHY_POWER);
|
||||
gpio_set_direction(PIN_PHY_POWER, GPIO_MODE_OUTPUT);
|
||||
if (enable == true) {
|
||||
gpio_set_level(PIN_PHY_POWER, 1);
|
||||
ESP_LOGI(TAG, "Power On Ethernet PHY");
|
||||
} else {
|
||||
gpio_set_level(PIN_PHY_POWER, 0);
|
||||
ESP_LOGI(TAG, "Power Off Ethernet PHY");
|
||||
}
|
||||
|
||||
vTaskDelay(1); // Allow the power up/down to take effect, min 300us
|
||||
|
||||
if (enable) {
|
||||
/* call the default PHY-specific power on function */
|
||||
DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief gpio specific init
|
||||
*
|
||||
* @note RMII data pins are fixed in esp32:
|
||||
* TXD0 <=> GPIO19
|
||||
* TXD1 <=> GPIO22
|
||||
* TX_EN <=> GPIO21
|
||||
* RXD0 <=> GPIO25
|
||||
* RXD1 <=> GPIO26
|
||||
* CLK <=> GPIO0
|
||||
*
|
||||
*/
|
||||
static void eth_gpio_config_rmii(void)
|
||||
{
|
||||
phy_rmii_configure_data_interface_pins();
|
||||
phy_rmii_smi_configure_pins(PIN_SMI_MDC, PIN_SMI_MDIO);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
/** Event handler for Ethernet events */
|
||||
static void on_eth_event(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
static void on_eth_event(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
switch (event_id) {
|
||||
case ETHERNET_EVENT_CONNECTED:
|
||||
@@ -251,30 +176,58 @@ static void on_eth_event(void* arg, esp_event_base_t event_base,
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
|
||||
static esp_eth_handle_t s_eth_handle = NULL;
|
||||
static esp_eth_mac_t *s_mac = NULL;
|
||||
static esp_eth_phy_t *s_phy = NULL;
|
||||
|
||||
static void start()
|
||||
{
|
||||
eth_config_t config = DEFAULT_ETHERNET_PHY_CONFIG;
|
||||
config.phy_addr = CONFIG_EXAMPLE_PHY_ADDRESS;
|
||||
config.gpio_config = eth_gpio_config_rmii;
|
||||
config.tcpip_input = tcpip_adapter_eth_input;
|
||||
config.clock_mode = CONFIG_EXAMPLE_PHY_CLOCK_MODE;
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_PHY_USE_POWER_PIN
|
||||
/* Replace the default 'power enable' function with an example-specific one
|
||||
that toggles a power GPIO. */
|
||||
config.phy_power_enable = phy_device_power_enable_via_gpio;
|
||||
#endif
|
||||
|
||||
ESP_ERROR_CHECK(esp_eth_init(&config));
|
||||
|
||||
ESP_ERROR_CHECK(tcpip_adapter_set_default_eth_handlers());
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip, NULL));
|
||||
#ifdef CONFIG_EXAMPLE_CONNECT_IPV6
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event, NULL));
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6, NULL));
|
||||
#endif
|
||||
|
||||
ESP_ERROR_CHECK(esp_eth_enable());
|
||||
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
#if CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
|
||||
s_mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
#if CONFIG_EXAMPLE_ETH_PHY_IP101
|
||||
s_phy = esp_eth_phy_new_ip101(&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_RTL8201
|
||||
s_phy = esp_eth_phy_new_rtl8201(&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_LAN8720
|
||||
s_phy = esp_eth_phy_new_lan8720(&phy_config);
|
||||
#elif CONFIG_EXAMPLE_ETH_PHY_DP83848
|
||||
s_phy = esp_eth_phy_new_dp83848(&phy_config);
|
||||
#endif
|
||||
#elif CONFIG_EXAMPLE_USE_SPI_ETHERNET
|
||||
gpio_install_isr_service(0);
|
||||
spi_device_handle_t spi_handle = NULL;
|
||||
spi_bus_config_t buscfg = {
|
||||
.miso_io_num = CONFIG_EXAMPLE_ETH_MISO_GPIO,
|
||||
.mosi_io_num = CONFIG_EXAMPLE_ETH_MOSI_GPIO,
|
||||
.sclk_io_num = CONFIG_EXAMPLE_ETH_SCLK_GPIO,
|
||||
.quadwp_io_num = -1,
|
||||
.quadhd_io_num = -1,
|
||||
};
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(CONFIG_EXAMPLE_ETH_SPI_HOST, &buscfg, 1));
|
||||
spi_device_interface_config_t devcfg = {
|
||||
.command_bits = 1,
|
||||
.address_bits = 7,
|
||||
.mode = 0,
|
||||
.clock_speed_hz = CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ * 1000 * 1000,
|
||||
.spics_io_num = CONFIG_EXAMPLE_ETH_CS_GPIO,
|
||||
.queue_size = 20
|
||||
};
|
||||
ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle));
|
||||
/* dm9051 ethernet driver is based on spi driver, so need to specify the spi handle */
|
||||
mac_config.spi_hdl = spi_handle;
|
||||
s_mac = esp_eth_mac_new_dm9051(&mac_config);
|
||||
s_phy = esp_eth_phy_new_dm9051(&phy_config);
|
||||
#endif
|
||||
esp_eth_config_t config = ETH_DEFAULT_CONFIG(s_mac, s_phy);
|
||||
ESP_ERROR_CHECK(esp_eth_driver_install(&config, &s_eth_handle));
|
||||
s_connection_name = "Ethernet";
|
||||
}
|
||||
|
||||
@@ -285,9 +238,9 @@ static void stop()
|
||||
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_GOT_IP6, &on_got_ipv6));
|
||||
ESP_ERROR_CHECK(esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_event));
|
||||
#endif
|
||||
|
||||
ESP_ERROR_CHECK(esp_eth_disable());
|
||||
ESP_ERROR_CHECK(esp_eth_deinit());
|
||||
ESP_ERROR_CHECK(esp_eth_driver_uninstall(s_eth_handle));
|
||||
ESP_ERROR_CHECK(s_phy->del(s_phy));
|
||||
ESP_ERROR_CHECK(s_mac->del(s_mac));
|
||||
}
|
||||
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_ETHERNET
|
||||
|
Reference in New Issue
Block a user