mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 05:57:05 +03:00
Start of 5.X work
This commit is contained in:
@@ -5,26 +5,41 @@ static EXT_RAM_ATTR network_ethernet_driver_t W5500;
|
||||
static EXT_RAM_ATTR spi_device_interface_config_t devcfg;
|
||||
static EXT_RAM_ATTR esp_netif_config_t cfg_spi;
|
||||
static EXT_RAM_ATTR esp_netif_inherent_config_t esp_netif_config;
|
||||
static EXT_RAM_ATTR gpio_num_t rst = -1;
|
||||
static esp_err_t reset_hw(esp_eth_phy_t *phy)
|
||||
{
|
||||
// set reset_gpio_num to a negative value can skip hardware reset phy chip
|
||||
if (rst >= 0) {
|
||||
esp_rom_gpio_pad_select_gpio_x(rst);
|
||||
gpio_set_direction_x(rst, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level_x(rst, 0);
|
||||
esp_rom_delay_us(100); // insert min input assert time
|
||||
gpio_set_level_x(rst, 1);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t start(spi_device_handle_t spi_handle, sys_Eth * ethernet_config) {
|
||||
static esp_err_t start(spi_device_handle_t spi_handle, sys_dev_eth_config * ethernet_config) {
|
||||
#ifdef CONFIG_ETH_SPI_ETHERNET_W5500
|
||||
eth_w5500_config_t eth_config = ETH_W5500_DEFAULT_CONFIG(spi_handle);
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
|
||||
eth_config.int_gpio_num = ethernet_config->ethType.spi.has_intr?ethernet_config->ethType.spi.intr.pin:-1;
|
||||
eth_config.int_gpio_num = ethernet_config->ethType.spi.intr;
|
||||
phy_config.phy_addr = -1; // let the system automatically find out the phy address
|
||||
phy_config.reset_gpio_num = ethernet_config->common.has_rst?ethernet_config->common.rst.pin:-1;
|
||||
rst = ethernet_config->common.rst;
|
||||
phy_config.reset_gpio_num = rst;
|
||||
|
||||
esp_eth_mac_t* mac = esp_eth_mac_new_w5500(ð_config, &mac_config);
|
||||
esp_eth_phy_t* phy = esp_eth_phy_new_w5500(&phy_config);
|
||||
phy->reset_hw = reset_hw;
|
||||
esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
|
||||
return esp_eth_driver_install(&config, &W5500.handle);
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
static void init_config(sys_Eth * ethernet_config) {
|
||||
static void init_config(sys_dev_eth_config * ethernet_config) {
|
||||
// This function is called when the network interface is started
|
||||
// and performs any initialization that requires a valid ethernet
|
||||
// configuration .
|
||||
@@ -34,7 +49,7 @@ static void init_config(sys_Eth * ethernet_config) {
|
||||
devcfg.mode = 0;
|
||||
devcfg.clock_speed_hz = ethernet_config->ethType.spi.speed > 0 ? ethernet_config->ethType.spi.speed : SPI_MASTER_FREQ_20M; // default speed
|
||||
devcfg.queue_size = 20;
|
||||
devcfg.spics_io_num = ethernet_config->ethType.spi.has_cs?ethernet_config->ethType.spi.cs.pin:-1;
|
||||
devcfg.spics_io_num = ethernet_config->ethType.spi.cs;
|
||||
memcpy(&esp_netif_config, &loc_esp_netif_config, sizeof(loc_esp_netif_config));
|
||||
cfg_spi.base = &esp_netif_config,
|
||||
cfg_spi.stack = ESP_NETIF_NETSTACK_DEFAULT_ETH;
|
||||
@@ -43,9 +58,9 @@ static void init_config(sys_Eth * ethernet_config) {
|
||||
W5500.start = start;
|
||||
|
||||
}
|
||||
network_ethernet_driver_t* W5500_Detect(sys_Eth * ethernet_config) {
|
||||
if (ethernet_config->common.model != sys_EthModelEnum_W5500 ||
|
||||
ethernet_config->which_ethType != sys_Eth_spi_tag )
|
||||
network_ethernet_driver_t* W5500_Detect(sys_dev_eth_config * ethernet_config) {
|
||||
if (ethernet_config->common.model != sys_dev_eth_models_W5500 ||
|
||||
ethernet_config->which_ethType != sys_dev_eth_config_spi_tag )
|
||||
return NULL;
|
||||
W5500.init_config = init_config;
|
||||
W5500.spi = true;
|
||||
|
||||
Reference in New Issue
Block a user