|
@@ -276,6 +276,8 @@ static esp_err_t lan8720_negotiate(esp_eth_phy_t *phy)
|
|
|
{
|
|
{
|
|
|
phy_lan8720_t *lan8720 = __containerof(phy, phy_lan8720_t, parent);
|
|
phy_lan8720_t *lan8720 = __containerof(phy, phy_lan8720_t, parent);
|
|
|
esp_eth_mediator_t *eth = lan8720->eth;
|
|
esp_eth_mediator_t *eth = lan8720->eth;
|
|
|
|
|
+ /* in case any link status has changed, let's assume we're in link down status */
|
|
|
|
|
+ lan8720->link_status = ETH_LINK_DOWN;
|
|
|
/* Restart auto negotiation */
|
|
/* Restart auto negotiation */
|
|
|
bmcr_reg_t bmcr = {
|
|
bmcr_reg_t bmcr = {
|
|
|
.speed_select = 1, /* 100Mbps */
|
|
.speed_select = 1, /* 100Mbps */
|
|
@@ -287,9 +289,9 @@ static esp_err_t lan8720_negotiate(esp_eth_phy_t *phy)
|
|
|
/* Wait for auto negotiation complete */
|
|
/* Wait for auto negotiation complete */
|
|
|
bmsr_reg_t bmsr;
|
|
bmsr_reg_t bmsr;
|
|
|
pscsr_reg_t pscsr;
|
|
pscsr_reg_t pscsr;
|
|
|
- int32_t to = 0;
|
|
|
|
|
- for (to = 0; to < lan8720->autonego_timeout_ms / 10; to++) {
|
|
|
|
|
- vTaskDelay(pdMS_TO_TICKS(10));
|
|
|
|
|
|
|
+ uint32_t to = 0;
|
|
|
|
|
+ for (to = 0; to < lan8720->autonego_timeout_ms / 100; to++) {
|
|
|
|
|
+ vTaskDelay(pdMS_TO_TICKS(100));
|
|
|
PHY_CHECK(eth->phy_reg_read(eth, lan8720->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)) == ESP_OK,
|
|
PHY_CHECK(eth->phy_reg_read(eth, lan8720->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)) == ESP_OK,
|
|
|
"read BMSR failed", err);
|
|
"read BMSR failed", err);
|
|
|
PHY_CHECK(eth->phy_reg_read(eth, lan8720->addr, ETH_PHY_PSCSR_REG_ADDR, &(pscsr.val)) == ESP_OK,
|
|
PHY_CHECK(eth->phy_reg_read(eth, lan8720->addr, ETH_PHY_PSCSR_REG_ADDR, &(pscsr.val)) == ESP_OK,
|
|
@@ -299,11 +301,9 @@ static esp_err_t lan8720_negotiate(esp_eth_phy_t *phy)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/* Auto negotiation failed, maybe no network cable plugged in, so output a warning */
|
|
/* Auto negotiation failed, maybe no network cable plugged in, so output a warning */
|
|
|
- if (to >= lan8720->autonego_timeout_ms / 10) {
|
|
|
|
|
|
|
+ if (to >= lan8720->autonego_timeout_ms / 100) {
|
|
|
ESP_LOGW(TAG, "auto negotiation timeout");
|
|
ESP_LOGW(TAG, "auto negotiation timeout");
|
|
|
}
|
|
}
|
|
|
- /* Updata information about link, speed, duplex */
|
|
|
|
|
- PHY_CHECK(lan8720_update_link_duplex_speed(lan8720) == ESP_OK, "update link duplex speed failed", err);
|
|
|
|
|
return ESP_OK;
|
|
return ESP_OK;
|
|
|
err:
|
|
err:
|
|
|
return ESP_FAIL;
|
|
return ESP_FAIL;
|