mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/remove_ethernet_config_option' into 'master'
ethernet: remove CONFIG_ETHERNET See merge request !1116
This commit is contained in:
commit
bb7d5fc10f
@ -56,46 +56,17 @@ static esp_err_t system_event_sta_connected_handle_default(system_event_t *event
|
||||
static esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event);
|
||||
static esp_err_t system_event_sta_got_ip_default(system_event_t *event);
|
||||
|
||||
#ifdef CONFIG_ETHERNET
|
||||
static esp_err_t system_event_eth_start_handle_default(system_event_t *event);
|
||||
static esp_err_t system_event_eth_stop_handle_default(system_event_t *event);
|
||||
static esp_err_t system_event_eth_connected_handle_default(system_event_t *event);
|
||||
static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event);
|
||||
#endif
|
||||
|
||||
/* Default event handler functions
|
||||
|
||||
Any entry in this table which is disabled by config will have a NULL handler.
|
||||
*/
|
||||
static system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = {
|
||||
[SYSTEM_EVENT_WIFI_READY] = NULL,
|
||||
[SYSTEM_EVENT_SCAN_DONE] = NULL,
|
||||
[SYSTEM_EVENT_STA_START] = NULL,
|
||||
[SYSTEM_EVENT_STA_STOP] = NULL,
|
||||
[SYSTEM_EVENT_STA_CONNECTED] = NULL,
|
||||
[SYSTEM_EVENT_STA_DISCONNECTED] = NULL,
|
||||
[SYSTEM_EVENT_STA_AUTHMODE_CHANGE] = NULL,
|
||||
[SYSTEM_EVENT_STA_GOT_IP] = NULL,
|
||||
[SYSTEM_EVENT_STA_WPS_ER_SUCCESS] = NULL,
|
||||
[SYSTEM_EVENT_STA_WPS_ER_FAILED] = NULL,
|
||||
[SYSTEM_EVENT_STA_WPS_ER_TIMEOUT] = NULL,
|
||||
[SYSTEM_EVENT_STA_WPS_ER_PIN] = NULL,
|
||||
[SYSTEM_EVENT_AP_START] = NULL,
|
||||
[SYSTEM_EVENT_AP_STOP] = NULL,
|
||||
[SYSTEM_EVENT_AP_STACONNECTED] = NULL,
|
||||
[SYSTEM_EVENT_AP_STADISCONNECTED] = NULL,
|
||||
[SYSTEM_EVENT_AP_PROBEREQRECVED] = NULL,
|
||||
[SYSTEM_EVENT_AP_STA_GOT_IP6] = NULL,
|
||||
#ifdef CONFIG_ETHERNET
|
||||
[SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default,
|
||||
[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default,
|
||||
[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default,
|
||||
[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default,
|
||||
[SYSTEM_EVENT_ETH_GOT_IP] = NULL,
|
||||
#endif
|
||||
};
|
||||
static system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = { 0 };
|
||||
|
||||
#ifdef CONFIG_ETHERNET
|
||||
esp_err_t system_event_eth_start_handle_default(system_event_t *event)
|
||||
{
|
||||
tcpip_adapter_ip_info_t eth_ip;
|
||||
@ -151,7 +122,6 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event)
|
||||
tcpip_adapter_down(TCPIP_ADAPTER_IF_ETH);
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static esp_err_t system_event_sta_got_ip_default(system_event_t *event)
|
||||
{
|
||||
@ -404,7 +374,7 @@ esp_err_t esp_event_process_default(system_event_t *event)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_init(wifi_init_config_t *config)
|
||||
void esp_event_set_default_wifi_handlers()
|
||||
{
|
||||
default_event_handlers[SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default;
|
||||
default_event_handlers[SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default;
|
||||
@ -415,5 +385,12 @@ esp_err_t esp_wifi_init(wifi_init_config_t *config)
|
||||
default_event_handlers[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default;
|
||||
|
||||
esp_register_shutdown_handler((shutdown_handler_t)esp_wifi_stop);
|
||||
return esp_wifi_init_internal(config);
|
||||
}
|
||||
|
||||
void esp_event_set_default_eth_handlers()
|
||||
{
|
||||
default_event_handlers[SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default;
|
||||
default_event_handlers[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default;
|
||||
default_event_handlers[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default;
|
||||
default_event_handlers[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default;
|
||||
}
|
||||
|
@ -159,6 +159,17 @@ esp_err_t esp_event_send(system_event_t *event);
|
||||
*/
|
||||
esp_err_t esp_event_process_default(system_event_t *event);
|
||||
|
||||
/**
|
||||
* @brief Install default event handlers for Ethernet interface
|
||||
*
|
||||
*/
|
||||
void esp_event_set_default_eth_handlers();
|
||||
|
||||
/**
|
||||
* @brief Install default event handlers for Wi-Fi interfaces (station and AP)
|
||||
*
|
||||
*/
|
||||
void esp_event_set_default_wifi_handlers();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -45,6 +45,12 @@ extern "C" {
|
||||
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
|
||||
* WiFi NVS structure among others.
|
||||
*
|
||||
* For the most part, you need not call this function directly. It gets called
|
||||
* from esp_wifi_init().
|
||||
*
|
||||
* This function may be called, if you only need to initialize the Wi-Fi driver
|
||||
* without having to use the network stack on top.
|
||||
*
|
||||
* @param config provide WiFi init configuration
|
||||
*
|
||||
* @return
|
||||
|
23
components/esp32/wifi_init.c
Normal file
23
components/esp32/wifi_init.c
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <esp_event.h>
|
||||
#include <esp_wifi.h>
|
||||
#include "esp_wifi_internal.h"
|
||||
|
||||
esp_err_t esp_wifi_init(wifi_init_config_t *config)
|
||||
{
|
||||
esp_event_set_default_wifi_handlers();
|
||||
return esp_wifi_init_internal(config);
|
||||
}
|
@ -1,14 +1,9 @@
|
||||
menuconfig ETHERNET
|
||||
bool "Ethernet"
|
||||
default n
|
||||
help
|
||||
Select this option to enable ethernet driver and show the submenu with ethernet features.
|
||||
menu ETHERNET
|
||||
|
||||
config DMA_RX_BUF_NUM
|
||||
int "Number of DMA RX buffers"
|
||||
range 3 20
|
||||
default 10
|
||||
depends on ETHERNET
|
||||
help
|
||||
Number of DMA receive buffers. Each buffer is 1600 bytes.
|
||||
Buffers are allocated statically.
|
||||
@ -19,7 +14,6 @@ config DMA_TX_BUF_NUM
|
||||
int "Number of DMA RX buffers"
|
||||
range 3 20
|
||||
default 10
|
||||
depends on ETHERNET
|
||||
help
|
||||
Number of DMA transmit buffers. Each buffer is 1600 bytes.
|
||||
Buffers are allocated statically.
|
||||
@ -28,7 +22,6 @@ config DMA_TX_BUF_NUM
|
||||
config EMAC_L2_TO_L3_RX_BUF_MODE
|
||||
bool "Enable copy between Layer2 and Layer3"
|
||||
default n
|
||||
depends on ETHERNET
|
||||
help
|
||||
If this options is selected, a copy of each received buffer will be created when
|
||||
passing it from the Ethernet MAC (L2) to the IP stack (L3). Otherwise, IP stack
|
||||
@ -46,7 +39,7 @@ config EMAC_TASK_PRIORITY
|
||||
int "EMAC_TASK_PRIORITY"
|
||||
default 20
|
||||
range 3 22
|
||||
depends on ETHERNET
|
||||
help
|
||||
Ethernet MAC task priority.
|
||||
|
||||
endmenu
|
@ -101,15 +101,11 @@ struct emac_open_cmd {
|
||||
struct emac_close_cmd {
|
||||
int8_t err;
|
||||
};
|
||||
#if CONFIG_ETHERNET
|
||||
|
||||
#define DMA_RX_BUF_NUM CONFIG_DMA_RX_BUF_NUM
|
||||
#define DMA_TX_BUF_NUM CONFIG_DMA_TX_BUF_NUM
|
||||
#define EMAC_TASK_PRIORITY CONFIG_EMAC_TASK_PRIORITY
|
||||
#else
|
||||
#define DMA_RX_BUF_NUM 1
|
||||
#define DMA_TX_BUF_NUM 1
|
||||
#define EMAC_TASK_PRIORITY 10
|
||||
#endif
|
||||
|
||||
#define DMA_RX_BUF_SIZE 1600
|
||||
#define DMA_TX_BUF_SIZE 1600
|
||||
|
||||
|
@ -978,13 +978,14 @@ esp_err_t IRAM_ATTR emac_post(emac_sig_t sig, emac_par_t par)
|
||||
}
|
||||
|
||||
esp_err_t esp_eth_init(eth_config_t *config)
|
||||
{
|
||||
esp_event_set_default_eth_handlers();
|
||||
return esp_eth_init_internal(config);
|
||||
}
|
||||
|
||||
esp_err_t esp_eth_init_internal(eth_config_t *config)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
#if !CONFIG_ETHERNET
|
||||
ESP_LOGI(TAG, "eth driver init fail,please make menuconfig and enable ethernet .");
|
||||
ret = ESP_FAIL;
|
||||
goto _exit;
|
||||
#endif
|
||||
if (emac_config.emac_status != EMAC_RUNTIME_NOT_INIT) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -117,6 +117,24 @@ typedef struct {
|
||||
*/
|
||||
esp_err_t esp_eth_init(eth_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Init Ethernet mac driver only
|
||||
*
|
||||
* For the most part, you need not call this function directly. It gets called
|
||||
* from esp_eth_init().
|
||||
*
|
||||
* This function may be called, if you only need to initialize the Ethernet
|
||||
* driver without having to use the network stack on top.
|
||||
*
|
||||
* @note config can not be NULL,and phy chip must be suitable to phy init func.
|
||||
* @param[in] config mac init data.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_eth_init_internal(eth_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Send packet from tcp/ip to mac
|
||||
*
|
||||
|
@ -1 +1 @@
|
||||
CONFIG_ETHERNET=y
|
||||
|
||||
|
@ -191,7 +191,6 @@ CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y
|
||||
# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set
|
||||
CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20
|
||||
CONFIG_ESP32_PHY_MAX_TX_POWER=20
|
||||
# CONFIG_ETHERNET is not set
|
||||
|
||||
#
|
||||
# FAT Filesystem support
|
||||
|
Loading…
Reference in New Issue
Block a user