From 7bf1ede250a06d817fbfcd85b081144f2f28c4b2 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Sat, 1 Jan 2022 17:56:51 -0800 Subject: [PATCH] dm9501 is not a RMII + CS delay option for displays --- components/display/SH1106.c | 1 + components/display/core/gds_private.h | 1 + .../wifi-manager/network_driver_DM9051.c | 21 +++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/components/display/SH1106.c b/components/display/SH1106.c index a08a3116..c7d2da2e 100644 --- a/components/display/SH1106.c +++ b/components/display/SH1106.c @@ -140,6 +140,7 @@ static const struct GDS_Device SH1106 = { .SetLayout = SetLayout, .Update = Update, .Init = Init, .Depth = 1, + .CS_post = 2, #if !defined SHADOW_BUFFER && defined USE_IRAM .Alloc = GDS_ALLOC_IRAM_SPI; #endif diff --git a/components/display/core/gds_private.h b/components/display/core/gds_private.h index bec6a3c0..db0339b4 100644 --- a/components/display/core/gds_private.h +++ b/components/display/core/gds_private.h @@ -86,6 +86,7 @@ struct GDS_Device { struct { spi_device_handle_t SPIHandle; int8_t CSPin; + int8_t CS_pre, CS_post, SPI_mode; }; }; diff --git a/components/wifi-manager/network_driver_DM9051.c b/components/wifi-manager/network_driver_DM9051.c index 7574857a..82e228f5 100644 --- a/components/wifi-manager/network_driver_DM9051.c +++ b/components/wifi-manager/network_driver_DM9051.c @@ -1,6 +1,11 @@ #include "esp_eth.h" #include "network_ethernet.h" + static EXT_RAM_ATTR network_ethernet_driver_t DM9051; +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 esp_err_t start(spi_device_handle_t spi_handle, eth_config_t* ethernet_config) { #ifdef CONFIG_ETH_SPI_ETHERNET_DM9051 eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); @@ -21,14 +26,26 @@ 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) { + esp_netif_inherent_config_t loc_esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH(); + devcfg.command_bits = 1; + devcfg.address_bits = 7; + devcfg.mode = 0; + devcfg.clock_speed_hz = ethernet_config->speed > 0 ? ethernet_config->speed : SPI_MASTER_FREQ_20M; // default speed + devcfg.queue_size = 20; + devcfg.spics_io_num = ethernet_config->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; + DM9051.cfg_netif = &cfg_spi; + DM9051.devcfg = &devcfg; DM9051.start = start; } network_ethernet_driver_t* DM9051_Detect(char* Driver) { if (!strcasestr(Driver, "DM9051")) return NULL; - DM9051.rmii = true; - DM9051.spi = false; + DM9051.rmii = false; + DM9051.spi = true; #ifdef CONFIG_ETH_SPI_ETHERNET_DM9051 DM9051.valid = true; #else