w5500 and be sure module works in any time.

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

Re: w5500 and be sure module works in any time.

Postby glrtheil » Fri Jun 09, 2023 4:54 pm

Was led here via an Espressif support rep, but had a lot of issues getting this to work. Even the claim of the code snippet from ESP_ondrej doesn't make sense, as that code doesn't appear anywhere in any example within any version of the IDF that I could find. But even using that code within the example he pointed out (Ethernet basic), that code snippet doesn't work. This is because W5500_REG_PHYCFGR is in a header file that's inaccessible because it's in a src directory within the IDF (4.3.2). After a ton of work, I came up with this, and it works great:

Code: Select all

esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);

esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth_handle = NULL;
ESP_ERROR_CHECK(esp_eth_driver_install(&config, &eth_handle));

//check PHY register to see if the w5500 exists on SPI bus
uint32_t regPosition = 0x002E << 16 | 0x00 << 3;
esp_eth_mediator_t *ethMediator = (esp_eth_mediator_t *)eth_handle;
uint8_t val = 0;
ethMediator->phy_reg_read(ethMediator, 0, regPosition, (uint32_t *)(&val));
ESP_LOGI(TAG, "W5500_REG_PHYCFGR val = 0x%x, i=%i", val, val);
if (val == 0xff)
{
    //w5500 ethernet does not exist/respond
}

ESP_ondrej
Posts: 166
Joined: Fri May 07, 2021 10:35 am

Re: w5500 and be sure module works in any time.

Postby ESP_ondrej » Tue Jun 13, 2023 8:13 am

I'm glad to hear you were able to resolve your issue. However, I'm bit sad about your negative experience. Therefore, I would like to provide clarification to some topics.
that code doesn't appear anywhere in any example within any version of the IDF that I could find.
Of course it doesn't appear anywhere since this is not standard way how to access the W5500. It's a workaround I came up with to help previous users to solve their problem. It happened to be also applicable to your case. Hence the support team directed you to this thread.
But even using that code within the example he pointed out (Ethernet basic), that code snippet doesn't work.
It works pretty well, I tested it again with the latest and v4.3.2 ethernet/basic example today. Only tiny updates were needed (eth handle name differs). You need to understand that the examples evolve and the forum's goal is to provide a guidance. It's impossible to give full solution for all versions. Some basic knowledge and effort from user's side is always required.
This is because W5500_REG_PHYCFGR is in a header file that's inaccessible because it's in a src directory within the IDF (4.3.2)
Did you include

Code: Select all

#include "../src/w5500.h"

Who is online

Users browsing this forum: No registered users and 198 guests