fixed disabled ethernet code compilation, some refactoring
This commit is contained in:
parent
b0eab9fa1c
commit
9358549667
|
|
@ -30,7 +30,7 @@
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
|
|
||||||
esp_err_t spi_device_polling_transmit_custom(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */
|
#endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include "esp_netif.h"
|
#include "esp_netif.h"
|
||||||
#include "esp_eth.h"
|
#include "esp_eth.h"
|
||||||
#include "esp_event.h"
|
#include "esp_event.h"
|
||||||
#include "esp_log.h"
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "NetTransport.h"
|
#include "NetTransport.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
@ -37,12 +36,13 @@
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "EthTransport";
|
static const char *TAG = "EthTransport";
|
||||||
esp_netif_t *eth_netif_spi[CONFIG_SPI_ETHERNETS_NUM] = { NULL };
|
|
||||||
static bool isEthConn = false;
|
static bool isEthConn = false;
|
||||||
|
|
||||||
#if CONFIG_USE_SPI_ETHERNET
|
#if CONFIG_USE_SPI_ETHERNET
|
||||||
|
esp_netif_t *eth_netif_spi[CONFIG_SPI_ETHERNETS_NUM] = { NULL };
|
||||||
|
|
||||||
#define INIT_SPI_ETH_MODULE_CONFIG(eth_module_config, num) \
|
#define INIT_SPI_ETH_MODULE_CONFIG(eth_module_config, num) \
|
||||||
do { \
|
do { \
|
||||||
eth_module_config[num].spi_cs_gpio = CONFIG_ETH_SPI_CS ##num## _GPIO; \
|
eth_module_config[num].spi_cs_gpio = CONFIG_ETH_SPI_CS ##num## _GPIO; \
|
||||||
|
|
@ -58,13 +58,16 @@ typedef struct
|
||||||
int8_t phy_reset_gpio;
|
int8_t phy_reset_gpio;
|
||||||
uint8_t phy_addr;
|
uint8_t phy_addr;
|
||||||
} spi_eth_module_config_t;
|
} spi_eth_module_config_t;
|
||||||
#endif
|
|
||||||
|
|
||||||
esp_netif_t* GetETHNetifAdapter(void)
|
esp_netif_t* GetETHNetifAdapter(void)
|
||||||
{
|
{
|
||||||
return eth_netif_spi[0];
|
return eth_netif_spi[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool isETHConnected(void)
|
bool isETHConnected(void)
|
||||||
{
|
{
|
||||||
return isEthConn;
|
return isEthConn;
|
||||||
|
|
@ -91,7 +94,6 @@ static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
case ETHERNET_EVENT_DISCONNECTED:
|
case ETHERNET_EVENT_DISCONNECTED:
|
||||||
ESP_LOGI(TAG, "Ethernet Link Down");
|
ESP_LOGI(TAG, "Ethernet Link Down");
|
||||||
isEthConn = false;
|
isEthConn = false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ETHERNET_EVENT_START:
|
case ETHERNET_EVENT_START:
|
||||||
ESP_LOGI(TAG, "Ethernet Started");
|
ESP_LOGI(TAG, "Ethernet Started");
|
||||||
|
|
@ -120,20 +122,9 @@ static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
isEthConn = true;
|
isEthConn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_ethernet_got_ip(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void eth_init(void *pvParameter)
|
static void eth_init(void *pvParameter)
|
||||||
{
|
{
|
||||||
//SetETH_RST(0);
|
|
||||||
gpio_set_level(CONFIG_ETH_SPI_PHY_RST0_GPIO, 0);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
//SetETH_RST(1);
|
|
||||||
gpio_set_level(CONFIG_ETH_SPI_PHY_RST0_GPIO, 1);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
|
|
||||||
#if CONFIG_USE_INTERNAL_ETHERNET
|
#if CONFIG_USE_INTERNAL_ETHERNET
|
||||||
// Create new default instance of esp-netif for Ethernet
|
// Create new default instance of esp-netif for Ethernet
|
||||||
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
|
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
|
||||||
|
|
@ -169,6 +160,12 @@ static void eth_init(void *pvParameter)
|
||||||
#endif //CONFIG_USE_INTERNAL_ETHERNET
|
#endif //CONFIG_USE_INTERNAL_ETHERNET
|
||||||
|
|
||||||
#if CONFIG_USE_SPI_ETHERNET
|
#if CONFIG_USE_SPI_ETHERNET
|
||||||
|
//Reset ethernet SPI device
|
||||||
|
gpio_set_level(CONFIG_ETH_SPI_PHY_RST0_GPIO, 0);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
gpio_set_level(CONFIG_ETH_SPI_PHY_RST0_GPIO, 1);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
|
||||||
// Create instance(s) of esp-netif for SPI Ethernet(s)
|
// Create instance(s) of esp-netif for SPI Ethernet(s)
|
||||||
esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH();
|
esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH();
|
||||||
esp_netif_config_t cfg_spi = {
|
esp_netif_config_t cfg_spi = {
|
||||||
|
|
@ -318,7 +315,6 @@ static void eth_init(void *pvParameter)
|
||||||
// Register user defined event handers
|
// Register user defined event handers
|
||||||
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, NULL));
|
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, NULL));
|
||||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));
|
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));
|
||||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_ethernet_got_ip, NULL));
|
|
||||||
|
|
||||||
/* start Ethernet driver state machine */
|
/* start Ethernet driver state machine */
|
||||||
#if CONFIG_USE_INTERNAL_ETHERNET
|
#if CONFIG_USE_INTERNAL_ETHERNET
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ void spi_device_init_custom(void)
|
||||||
xSemaphoreGive(xSemaphoreSPIHandle);
|
xSemaphoreGive(xSemaphoreSPIHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t spi_device_polling_transmit_custom(spi_device_handle_t handle, spi_transaction_t *trans_desc)
|
esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc)
|
||||||
{
|
{
|
||||||
esp_err_t res;
|
esp_err_t res;
|
||||||
if (xSemaphoreTake(xSemaphoreSPIHandle,pdMS_TO_TICKS(SPI_LOCK_TIMEOUT_MS)) == pdTRUE)
|
if (xSemaphoreTake(xSemaphoreSPIHandle,pdMS_TO_TICKS(SPI_LOCK_TIMEOUT_MS)) == pdTRUE)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user