fix LAN8720

This commit is contained in:
Philippe G
2022-01-05 19:30:39 -08:00
parent f95ec33457
commit c1b39610fc
2 changed files with 19 additions and 3 deletions

View File

@@ -140,17 +140,23 @@ const i2s_platform_config_t * config_i2s_get_from_str(char * dac_config ){
*/ */
const eth_config_t * config_eth_get_from_str(char* config ){ const eth_config_t * config_eth_get_from_str(char* config ){
static EXT_RAM_ATTR eth_config_t eth_config; static EXT_RAM_ATTR eth_config_t eth_config;
eth_config.rst = eth_config.intr = -1;
PARSE_PARAM_STR(config, "model", '=', eth_config.model, 15); PARSE_PARAM_STR(config, "model", '=', eth_config.model, 15);
PARSE_PARAM(config, "rst", '=', eth_config.rst);
// RMII
PARSE_PARAM(config, "mdc", '=', eth_config.mdc); PARSE_PARAM(config, "mdc", '=', eth_config.mdc);
PARSE_PARAM(config, "mdio", '=', eth_config.mdio); PARSE_PARAM(config, "mdio", '=', eth_config.mdio);
PARSE_PARAM(config, "rst", '=', eth_config.rst); // SPI
PARSE_PARAM(config, "mosi", '=', eth_config.mosi);
PARSE_PARAM(config, "miso", '=', eth_config.miso);
PARSE_PARAM(config, "intr", '=', eth_config.intr); PARSE_PARAM(config, "intr", '=', eth_config.intr);
PARSE_PARAM(config, "cs", '=', eth_config.cs); PARSE_PARAM(config, "cs", '=', eth_config.cs);
PARSE_PARAM(config, "speed", '=', eth_config.speed); PARSE_PARAM(config, "speed", '=', eth_config.speed);
/* not used as SPI must be shared
PARSE_PARAM(config, "mosi", '=', eth_config.mosi);
PARSE_PARAM(config, "miso", '=', eth_config.miso);
PARSE_PARAM(config, "clk", '=', eth_config.clk); PARSE_PARAM(config, "clk", '=', eth_config.clk);
PARSE_PARAM(config, "host", '=', eth_config.host);
*/
// only system host is available // only system host is available
eth_config.host = spi_system_host; eth_config.host = spi_system_host;

View File

@@ -2,6 +2,9 @@
#include "network_ethernet.h" #include "network_ethernet.h"
static EXT_RAM_ATTR network_ethernet_driver_t LAN8720; static EXT_RAM_ATTR network_ethernet_driver_t LAN8720;
static EXT_RAM_ATTR esp_netif_config_t cfg_rmii;
static EXT_RAM_ATTR esp_netif_inherent_config_t esp_netif_config;
static esp_err_t start(spi_device_handle_t spi_handle, eth_config_t* ethernet_config) { static esp_err_t start(spi_device_handle_t spi_handle, eth_config_t* ethernet_config) {
#ifdef CONFIG_ETH_PHY_INTERFACE_RMII #ifdef CONFIG_ETH_PHY_INTERFACE_RMII
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
@@ -22,6 +25,13 @@ static esp_err_t start(spi_device_handle_t spi_handle, eth_config_t* ethernet_co
} }
static void init_config(eth_config_t* ethernet_config) { static void init_config(eth_config_t* ethernet_config) {
esp_netif_inherent_config_t loc_esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH();
memcpy(&esp_netif_config, &loc_esp_netif_config, sizeof(loc_esp_netif_config));
cfg_rmii.base = &esp_netif_config,
cfg_rmii.stack = ESP_NETIF_NETSTACK_DEFAULT_ETH;
LAN8720.cfg_netif = &cfg_rmii;
LAN8720.start = start; LAN8720.start = start;
} }