-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32 with W5500 #1
Comments
Hi @maialbe2823 You simply replace the config part and creation of esp-network-examples/backnet-sever/main/eth_init.c Lines 85 to 99 in b784ebd
with this code gpio_install_isr_service(0);
spi_bus_config_t buscfg = {
.miso_io_num = CONFIG_EXAMPLE_ETH_SPI_MISO_GPIO,
.mosi_io_num = CONFIG_EXAMPLE_ETH_SPI_MOSI_GPIO,
.sclk_io_num = CONFIG_EXAMPLE_ETH_SPI_SCLK_GPIO,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
};
ESP_ERROR_CHECK(spi_bus_initialize(CONFIG_EXAMPLE_ETH_SPI_HOST, &buscfg, SPI_DMA_CH_AUTO));
spi_device_interface_config_t spi_devcfg = {
.mode = 0,
.clock_speed_hz = CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ * 1000 * 1000,
.spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO,
.queue_size = 20
};
/* w5500 ethernet driver is based on spi driver */
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &spi_devcfg);
w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
phy = esp_eth_phy_new_w5500(&phy_config);
// Install Ethernet driver ... (which also sets up the SPI bus) see the docs here https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_eth.html#spi-ethernet-module |
Got it thanks. And which or how many gpios should I use? |
Hi David, I tried you configuration however I am getting the following errors: #include "network_init.h" #define TAG "bacnet-eth-init" EventGroupHandle_t s_net_event_group; //#define CONFIG_EXAMPLE_ETH_PHY_IP101 1 #define CONFIG_EXAMPLE_ETH_SPI_MISO_GPIO 19 #define CONFIG_EXAMPLE_ETH_SPI_SCLK_MHZ 20 static void eth_event_handler(void *arg, esp_event_base_t event_base,
} /** Event handler for IP_EVENT_ETH_GOT_IP */
}
} esp_netif_t* get_netif(void) Also, do I have to setup W5500 in esp-idf menuconfig or not? |
I'd recommend starting with this example: https://github.com/espressif/esp-idf/tree/master/examples/ethernet/basic You'd need to choose SPI Ethernet (W5500) in menuconfig and it will help you with assigning default pins based on your target device. Once you can successfully connect and get an IP for your board, you can switch to your project. Looking at the logs, it seems that the SPI connection is not working. It's usually easier to start with something working by default, just to rule out bad wiring, HW, communication... |
Everything working now David. Thanks so much. I had to use the defaults pins like you said. |
Thank you. I'll try it out. |
Hi David, |
Hi david, is there any way to have this configuration of the ethernet port be able to work for the W5500 eth? I have tried but not luck keep getting no ip. There is no much info out there for the config part of the W5500
https://github.com/david-cermak/esp-network-examples/blob/main/backnet-sever/main/eth_init.c
The text was updated successfully, but these errors were encountered: