Add ENC28J60 Ethernet Driver

Merges https://github.com/espressif/esp-idf/pull/4435
This commit is contained in:
Henry Gilbert
2019-11-27 09:24:05 -07:00
committed by suda-morris
parent 966f4227ad
commit eda07acc81
7 changed files with 1559 additions and 5 deletions

View File

@@ -18,7 +18,14 @@ menu "Example Configuration"
select ETH_USE_SPI_ETHERNET
select ETH_SPI_ETHERNET_DM9051
help
Select external SPI-Ethernet module.
Select external SPI-Ethernet module (DM9051).
config EXAMPLE_USE_ENC28J60
bool "ENC28J60 Module"
select ETH_USE_SPI_ETHERNET
select ETH_SPI_ETHERNET_ENC28J60
help
Select external SPI-Ethernet module (ENC28J60).
endchoice
if EXAMPLE_USE_INTERNAL_ETHERNET
@@ -72,7 +79,7 @@ menu "Example Configuration"
range 0 2
default 1
help
Set the SPI host used to communicate with DM9051.
Set the SPI host used to communicate with the SPI Ethernet Controller.
config EXAMPLE_DM9051_SCLK_GPIO
int "SPI SCLK GPIO number"
@@ -104,7 +111,7 @@ menu "Example Configuration"
config EXAMPLE_DM9051_SPI_CLOCK_MHZ
int "SPI clock speed (MHz)"
range 20 80
range 5 80
default 20
help
Set the clock speed (MHz) of SPI interface.

View File

@@ -119,6 +119,20 @@ void app_main(void)
dm9051_config.int_gpio_num = CONFIG_EXAMPLE_DM9051_INT_GPIO;
esp_eth_mac_t *mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config);
esp_eth_phy_t *phy = esp_eth_phy_new_dm9051(&phy_config);
#elif CONFIG_EXAMPLE_ETH_PHY_ENC28J60
/* ENC28J60 ethernet driver is based on spi driver */
spi_device_interface_config_t devcfg = {
.command_bits = 3,
.address_bits = 5,
.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));
eth_ENC28J60_config_t ENC28J60_config = ETH_ENC28J60_DEFAULT_CONFIG(spi_handle);
esp_eth_mac_t *mac = esp_eth_mac_new_ENC28J60(&ENC28J60_config, &mac_config);
esp_eth_phy_t *phy = esp_eth_phy_new_ENC28J60(&phy_config);
#endif
esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth_handle = NULL;