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, ð_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
}