From 7e817bb0812f5018582817ec251b2a24c13cd026 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Tue, 24 Oct 2023 11:52:50 +0800 Subject: [PATCH] fix(phy): update phy lib to master esp32: phy_version 4780,16b31a7,Sep 22 2023,20:42:16 esp32s2: phy_version 2401,2a6dc26,Sep 26 2023,11:22:15 esp32c3: phy_version 1130,b4e4b80,Sep 5 2023,11:09:30 esp32s3: phy_version 620,ec7ec30,Sep 5 2023,13:49:13 --- components/esp_wifi/esp32/esp_adapter.c | 34 ++++++++++++---------- components/esp_wifi/esp32c3/esp_adapter.c | 34 ++++++++++++---------- components/esp_wifi/esp32s2/esp_adapter.c | 32 ++++++++++---------- components/esp_wifi/esp32s3/esp_adapter.c | 34 ++++++++++++---------- components/esp_wifi/include/esp_phy_init.h | 12 ++++++++ components/esp_wifi/lib | 2 +- components/esp_wifi/src/phy_init.c | 6 ++++ 7 files changed, 93 insertions(+), 61 deletions(-) diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index e273d54b8bda..81c2b68ae62d 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -1,16 +1,8 @@ -// Copyright 2015-2018 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include @@ -726,6 +718,18 @@ int32_t IRAM_ATTR coex_is_in_isr_wrapper(void) return !xPortCanYield(); } +static void esp_phy_enable_wrapper(void) +{ + esp_phy_enable(); + phy_wifi_enable_set(1); +} + +static void esp_phy_disable_wrapper(void) +{ + phy_wifi_enable_set(0); + esp_phy_disable(); +} + wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -779,8 +783,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._dport_access_stall_other_cpu_end_wrap = s_esp_dport_access_stall_other_cpu_end, ._wifi_apb80m_request = wifi_apb80m_request_wrapper, ._wifi_apb80m_release = wifi_apb80m_release_wrapper, - ._phy_disable = esp_phy_disable, - ._phy_enable = esp_phy_enable, + ._phy_disable = esp_phy_disable_wrapper, + ._phy_enable = esp_phy_enable_wrapper, ._phy_common_clock_enable = esp_phy_common_clock_enable, ._phy_common_clock_disable = esp_phy_common_clock_disable, ._phy_update_country_info = esp_phy_update_country_info, diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index a59f46cd4f76..32c76cf647c5 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include @@ -657,6 +649,18 @@ static void IRAM_ATTR esp_empty_wrapper(void) } +static void esp_phy_enable_wrapper(void) +{ + esp_phy_enable(); + phy_wifi_enable_set(1); +} + +static void esp_phy_disable_wrapper(void) +{ + phy_wifi_enable_set(0); + esp_phy_disable(); +} + wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -710,8 +714,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper, ._wifi_apb80m_request = wifi_apb80m_request_wrapper, ._wifi_apb80m_release = wifi_apb80m_release_wrapper, - ._phy_disable = esp_phy_disable, - ._phy_enable = esp_phy_enable, + ._phy_disable = esp_phy_disable_wrapper, + ._phy_enable = esp_phy_enable_wrapper, ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac_wrapper, ._timer_arm = timer_arm_wrapper, diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 913ee303582e..45913266b9e4 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -1,16 +1,8 @@ -// Copyright 2015-2018 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include @@ -641,6 +633,16 @@ static void IRAM_ATTR esp_empty_wrapper(void) } +static void esp_phy_enable_wrapper(void) +{ + esp_phy_enable(); +} + +static void esp_phy_disable_wrapper(void) +{ + esp_phy_disable(); +} + wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -694,8 +696,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper, ._wifi_apb80m_request = wifi_apb80m_request_wrapper, ._wifi_apb80m_release = wifi_apb80m_release_wrapper, - ._phy_disable = esp_phy_disable, - ._phy_enable = esp_phy_enable, + ._phy_disable = esp_phy_disable_wrapper, + ._phy_enable = esp_phy_enable_wrapper, ._phy_common_clock_enable = esp_phy_common_clock_enable, ._phy_common_clock_disable = esp_phy_common_clock_disable, ._phy_update_country_info = esp_phy_update_country_info, diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index d1a61e0101ee..e81316a98c8c 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -1,16 +1,8 @@ -// Copyright 2015-2020 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include @@ -684,6 +676,18 @@ int32_t IRAM_ATTR coex_is_in_isr_wrapper(void) return !xPortCanYield(); } +static void esp_phy_enable_wrapper(void) +{ + esp_phy_enable(); + phy_wifi_enable_set(1); +} + +static void esp_phy_disable_wrapper(void) +{ + phy_wifi_enable_set(0); + esp_phy_disable(); +} + wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -737,8 +741,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper, ._wifi_apb80m_request = wifi_apb80m_request_wrapper, ._wifi_apb80m_release = wifi_apb80m_release_wrapper, - ._phy_disable = esp_phy_disable, - ._phy_enable = esp_phy_enable, + ._phy_disable = esp_phy_disable_wrapper, + ._phy_enable = esp_phy_enable_wrapper, ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac, ._timer_arm = timer_arm_wrapper, diff --git a/components/esp_wifi/include/esp_phy_init.h b/components/esp_wifi/include/esp_phy_init.h index 0c63a4bcc5c2..9ca94f57a70c 100644 --- a/components/esp_wifi/include/esp_phy_init.h +++ b/components/esp_wifi/include/esp_phy_init.h @@ -243,6 +243,18 @@ esp_err_t esp_phy_apply_phy_init_data(uint8_t *init_data); */ char * get_phy_version_str(void); +/** + * @brief Set PHY init parameters + * @param param is 1 means combo module + */ +void phy_init_param_set(uint8_t param); + +/** + * @brief Wi-Fi RX enable + * @param enable True for enable wifi receiving mode as default, false for closing wifi receiving mode as default. + */ +void phy_wifi_enable_set(uint8_t enable); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index fe03953f2a6a..0d32ed16f067 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit fe03953f2a6abe7336803274632d83e6b7879fda +Subproject commit 0d32ed16f0671cdff0b5be6335c378ae3c593c2d diff --git a/components/esp_wifi/src/phy_init.c b/components/esp_wifi/src/phy_init.c index 83a7f1dafe2d..f107f7db4745 100644 --- a/components/esp_wifi/src/phy_init.c +++ b/components/esp_wifi/src/phy_init.c @@ -683,6 +683,12 @@ void esp_phy_load_cal_and_init(void) phy_eco_version_sel(efuse_hal_chip_revision() / 100); #endif + // Set PHY whether in combo module + // For comode mode, phy enable will be not in WiFi RX state +#if SOC_PHY_COMBO_MODULE + phy_init_param_set(0); +#endif + esp_phy_calibration_data_t* cal_data = (esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1); if (cal_data == NULL) {