esp32/network_lan: Add support for Ethernet PHY KSZ8081.

This is available since ESP-IDF v4.4.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
ma-lalonde 2022-05-30 01:16:51 -04:00 committed by Damien George
parent 54e85fe212
commit 30db33d1e0
3 changed files with 13 additions and 1 deletions

View File

@ -270,6 +270,10 @@ STATIC const mp_rom_map_elem_t mp_module_network_globals_table[] = {
// PHY_KSZ8041 is new in ESP-IDF v4.3
{ MP_ROM_QSTR(MP_QSTR_PHY_KSZ8041), MP_ROM_INT(PHY_KSZ8041) },
#endif
#if ESP_IDF_VERSION_MINOR >= 4
// PHY_KSZ8081 is new in ESP-IDF v4.4
{ MP_ROM_QSTR(MP_QSTR_PHY_KSZ8081), MP_ROM_INT(PHY_KSZ8081) },
#endif
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
{ MP_ROM_QSTR(MP_QSTR_PHY_KSZ8851SNL), MP_ROM_INT(PHY_KSZ8851SNL) },

View File

@ -28,7 +28,7 @@
#include "esp_event.h"
enum { PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8851SNL = 100, PHY_DM9051, PHY_W5500 };
enum { PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8081, 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 };

View File

@ -150,6 +150,9 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
#if ESP_IDF_VERSION_MINOR >= 3 // KSZ8041 is new in ESP-IDF v4.3
args[ARG_phy_type].u_int != PHY_KSZ8041 &&
#endif
#if ESP_IDF_VERSION_MINOR >= 4 // KSZ8081 is new in ESP-IDF v4.4
args[ARG_phy_type].u_int != PHY_KSZ8081 &&
#endif
#if CONFIG_ETH_USE_SPI_ETHERNET
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
args[ARG_phy_type].u_int != PHY_KSZ8851SNL &&
@ -237,6 +240,11 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
self->phy = esp_eth_phy_new_ksz8041(&phy_config);
break;
#endif
#if ESP_IDF_VERSION_MINOR >= 4 // KSZ8081 is new in ESP-IDF v4.4
case PHY_KSZ8081:
self->phy = esp_eth_phy_new_ksz8081(&phy_config);
break;
#endif
#endif
#if CONFIG_ETH_USE_SPI_ETHERNET
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL