Skip to content

esp32/network_lan: Add PHY_GENERIC device type. #17237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/esp32/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Required keyword arguments for the constructor:
- ``mdc`` and ``mdio`` - :class:`machine.Pin` objects (or integers) specifying
the MDC and MDIO pins.
- ``phy_type`` - Select the PHY device type. Supported devices are
``PHY_GENERIC``,
``PHY_LAN8710``, ``PHY_LAN8720``, ``PHY_IP101``, ``PHY_RTL8201``,
``PHY_DP83848``, ``PHY_KSZ8041`` and ``PHY_KSZ8081``. These values are all
constants defined in the ``network`` module.
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/modnetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "esp_netif.h"

enum { PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8081, PHY_KSZ8851SNL = 100, PHY_DM9051, PHY_W5500 };
enum { PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8081, PHY_GENERIC, PHY_KSZ8851SNL = 100, PHY_DM9051, PHY_W5500 };
#define IS_SPI_PHY(NUM) (NUM >= 100)
enum { ETH_INITIALIZED, ETH_STARTED, ETH_STOPPED, ETH_CONNECTED, ETH_DISCONNECTED, ETH_GOT_IP };

Expand Down
1 change: 1 addition & 0 deletions ports/esp32/modnetwork_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#if MICROPY_PY_NETWORK_LAN
{ MP_ROM_QSTR(MP_QSTR_PHY_LAN8710), MP_ROM_INT(PHY_LAN8710) },
{ MP_ROM_QSTR(MP_QSTR_PHY_LAN8720), MP_ROM_INT(PHY_LAN8720) },
{ MP_ROM_QSTR(MP_QSTR_PHY_GENERIC), MP_ROM_INT(PHY_GENERIC) },
{ MP_ROM_QSTR(MP_QSTR_PHY_IP101), MP_ROM_INT(PHY_IP101) },
{ MP_ROM_QSTR(MP_QSTR_PHY_RTL8201), MP_ROM_INT(PHY_RTL8201) },
{ MP_ROM_QSTR(MP_QSTR_PHY_DP83848), MP_ROM_INT(PHY_DP83848) },
Expand Down
8 changes: 8 additions & 0 deletions ports/esp32/network_lan.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ static mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar

if (args[ARG_phy_type].u_int != PHY_LAN8710 &&
args[ARG_phy_type].u_int != PHY_LAN8720 &&
args[ARG_phy_type].u_int != PHY_GENERIC &&
args[ARG_phy_type].u_int != PHY_IP101 &&
args[ARG_phy_type].u_int != PHY_RTL8201 &&
args[ARG_phy_type].u_int != PHY_KSZ8041 &&
Expand Down Expand Up @@ -221,6 +222,13 @@ static mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
case PHY_IP101:
self->phy = esp_eth_phy_new_ip101(&phy_config);
break;
case PHY_GENERIC:
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
self->phy = esp_eth_phy_new_generic(&phy_config);
#else
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("PHY_GENERIC not supported in ESP-IDF < 5.4"));
#endif
break;
case PHY_RTL8201:
self->phy = esp_eth_phy_new_rtl8201(&phy_config);
break;
Expand Down
Loading