69b4e18118
- aes67_board: Waveshare ESP32-P4-ETH pin profile and EMAC + IP101 driver install (PHY addr 1, reset GPIO51, ref clock in on GPIO50). - aes67_net: Ethernet netif with DHCP client; logs link up/down (speed, duplex, MAC) and the DHCP lease. - Verified on board: 100 Mbps full duplex, DHCP lease in ~8 s, ping 0% loss, ~0.2 ms RTT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.7 KiB
C
45 lines
1.7 KiB
C
#include "aes67_board.h"
|
|
|
|
#include "esp_eth.h"
|
|
#include "esp_log.h"
|
|
#include "boards/waveshare_esp32p4_eth.h"
|
|
|
|
static const char *TAG = "board";
|
|
|
|
esp_err_t aes67_board_eth_init(esp_eth_handle_t *out_eth)
|
|
{
|
|
eth_mac_config_t mac_cfg = ETH_MAC_DEFAULT_CONFIG();
|
|
eth_esp32_emac_config_t emac_cfg = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
emac_cfg.smi_gpio.mdc_num = BOARD_ETH_MDC;
|
|
emac_cfg.smi_gpio.mdio_num = BOARD_ETH_MDIO;
|
|
emac_cfg.interface = EMAC_DATA_INTERFACE_RMII;
|
|
emac_cfg.clock_config.rmii.clock_mode = EMAC_CLK_EXT_IN;
|
|
emac_cfg.clock_config.rmii.clock_gpio = (emac_rmii_clock_gpio_t)BOARD_ETH_REF_CLK;
|
|
emac_cfg.emac_dataif_gpio.rmii.tx_en_num = BOARD_ETH_TX_EN;
|
|
emac_cfg.emac_dataif_gpio.rmii.txd0_num = BOARD_ETH_TXD0;
|
|
emac_cfg.emac_dataif_gpio.rmii.txd1_num = BOARD_ETH_TXD1;
|
|
emac_cfg.emac_dataif_gpio.rmii.crs_dv_num = BOARD_ETH_CRS_DV;
|
|
emac_cfg.emac_dataif_gpio.rmii.rxd0_num = BOARD_ETH_RXD0;
|
|
emac_cfg.emac_dataif_gpio.rmii.rxd1_num = BOARD_ETH_RXD1;
|
|
|
|
eth_phy_config_t phy_cfg = ETH_PHY_DEFAULT_CONFIG();
|
|
phy_cfg.phy_addr = BOARD_ETH_PHY_ADDR;
|
|
phy_cfg.reset_gpio_num = BOARD_ETH_PHY_RST;
|
|
|
|
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&emac_cfg, &mac_cfg);
|
|
esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_cfg);
|
|
if (!mac || !phy) {
|
|
ESP_LOGE(TAG, "EMAC/PHY create failed");
|
|
return ESP_FAIL;
|
|
}
|
|
|
|
esp_eth_config_t eth_cfg = ETH_DEFAULT_CONFIG(mac, phy);
|
|
esp_err_t err = esp_eth_driver_install(ð_cfg, out_eth);
|
|
if (err != ESP_OK) {
|
|
ESP_LOGE(TAG, "driver install failed: %s", esp_err_to_name(err));
|
|
return err;
|
|
}
|
|
ESP_LOGI(TAG, "%s: IP101 at PHY addr %d, RMII", BOARD_NAME, BOARD_ETH_PHY_ADDR);
|
|
return ESP_OK;
|
|
}
|