components/esp_eth/src/esp_eth_mac_dm9051.c
/**
 * @brief software reset dm9051 internal register
 */
@brief software reset dm9051 internal register
@brief software reset dm9051 internal register
static esp_err_t dm9051_reset(emac_dm9051_t *emac)
{
    esp_err_t ret = ESP_OK;
    ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_GPR, 0x00), err, TAG, "write GPR failed");
    vTaskDelay(pdMS_TO_TICKS(10));
    uint8_t ncr = NCR_RST;
    ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_NCR, ncr), err, TAG, "write NCR failed");
    uint32_t to = 0;
    for (to = 0; to < emac->sw_reset_timeout_ms / 10; to++) {
        ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_NCR, &ncr), err, TAG, "read NCR failed");
        if (!(ncr & NCR_RST)) {
            break;
        }
        vTaskDelay(pdMS_TO_TICKS(10));
    }
    ESP_GOTO_ON_FALSE(to < emac->sw_reset_timeout_ms / 10, ESP_ERR_TIMEOUT, err, TAG, "reset timeout");
    return ESP_OK;
err:
    return ret;
}
static esp_err_t dm9051_reset ( emac_dm9051_t * emac ) { esp_err_t ret = ESP_OK ; ESP_GOTO_ON_ERROR ( dm9051_register_write ( emac , DM9051_GPR , 0x00 ) , err , TAG , " " ) ; vTaskDelay ( pdMS_TO_TICKS ( 10 ) ) ; uint8_t ncr = NCR_RST ; ESP_GOTO_ON_ERROR ( dm9051_register_write ( emac , DM9051_NCR , ncr ) , err , TAG , " " ) ; uint32_t to = 0 ; for ( to = 0 ; to < emac -> sw_reset_timeout_ms / 10 ; to ++ ) { ESP_GOTO_ON_ERROR ( dm9051_register_read ( emac , DM9051_NCR , & ncr ) , err , TAG , " " ) ; if ( ! ( ncr & NCR_RST ) ) { break ; } vTaskDelay ( pdMS_TO_TICKS ( 10 ) ) ; } ESP_GOTO_ON_FALSE ( to < emac -> sw_reset_timeout_ms / 10 , ESP_ERR_TIMEOUT , err , TAG , " " ) ; return ESP_OK ; err : return ret ; }
@brief software reset dm9051 internal register
@brief software reset dm9051 internal register
/* power on phy */ /* mac and phy register won't be accesable within at least 1ms */ /* software reset */