mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 04:25:32 +00:00
esp_phy: support phy init on esp32h2 chip
This commit is contained in:
@@ -9,7 +9,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(IDF_TARGET STREQUAL "esp32h2")
|
if(IDF_TARGET STREQUAL "esp32h2")
|
||||||
set(srcs "src/esp32h2/phy_init.c")
|
set(srcs "src/phy_init_esp32hxx.c")
|
||||||
else()
|
else()
|
||||||
set(srcs "src/phy_init.c")
|
set(srcs "src/phy_init.c")
|
||||||
endif()
|
endif()
|
||||||
@@ -28,15 +28,22 @@ if(link_binary_libs)
|
|||||||
target_link_libraries(${COMPONENT_LIB} PUBLIC phy)
|
target_link_libraries(${COMPONENT_LIB} PUBLIC phy)
|
||||||
|
|
||||||
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
|
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a
|
|
||||||
$<TARGET_FILE:${esp_phy_lib}>)
|
|
||||||
|
|
||||||
if(CONFIG_IDF_TARGET_ESP32)
|
if(CONFIG_IDF_TARGET_ESP32)
|
||||||
target_link_libraries(${COMPONENT_LIB} PUBLIC rtc)
|
target_link_libraries(${COMPONENT_LIB} PUBLIC rtc)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a librtc.a
|
||||||
|
$<TARGET_FILE:${esp_phy_lib}>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_IDF_TARGET_ESP32C3 OR CONFIG_IDF_TARGET_ESP32S3)
|
if(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a
|
||||||
|
$<TARGET_FILE:${esp_phy_lib}>)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_IDF_TARGET_ESP32C3 OR CONFIG_IDF_TARGET_ESP32S3 OR CONFIG_IDF_TARGET_ESP32H2)
|
||||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btbb)
|
target_link_libraries(${COMPONENT_LIB} PUBLIC btbb)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a libbtbb.a
|
||||||
|
$<TARGET_FILE:${esp_phy_lib}>)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ESP32H2-TODO: IDF-3398
|
// There is no init data for H2 right now, could be added when necessary.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// ESP32H2-TODO: IDF-3398
|
|
72
components/esp_phy/src/phy_init_esp32hxx.c
Normal file
72
components/esp_phy/src/phy_init_esp32hxx.c
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// 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_attr.h"
|
||||||
|
#include "freertos/portmacro.h"
|
||||||
|
#include "esp_phy_init.h"
|
||||||
|
#include "phy.h"
|
||||||
|
|
||||||
|
#define PHY_ENABLE_VERSION_PRINT 1
|
||||||
|
|
||||||
|
static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
extern void phy_version_print(void);
|
||||||
|
|
||||||
|
static _lock_t s_phy_access_lock;
|
||||||
|
|
||||||
|
/* Reference count of enabling PHY */
|
||||||
|
static uint8_t s_phy_access_ref = 0;
|
||||||
|
|
||||||
|
extern void bt_bb_v2_init_cmplx(int print_version);
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR phy_enter_critical(void)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(&s_phy_int_mux);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(&s_phy_int_mux);
|
||||||
|
}
|
||||||
|
// Interrupt level will be stored in current tcb, so always return zero.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR phy_exit_critical(uint32_t level)
|
||||||
|
{
|
||||||
|
// Param level don't need any more, ignore it.
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(&s_phy_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(&s_phy_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_phy_enable(void)
|
||||||
|
{
|
||||||
|
_lock_acquire(&s_phy_access_lock);
|
||||||
|
if (s_phy_access_ref == 0) {
|
||||||
|
register_chipv7_phy(NULL, NULL, PHY_RF_CAL_FULL);
|
||||||
|
bt_bb_v2_init_cmplx(PHY_ENABLE_VERSION_PRINT);
|
||||||
|
phy_version_print();
|
||||||
|
}
|
||||||
|
|
||||||
|
s_phy_access_ref++;
|
||||||
|
|
||||||
|
_lock_release(&s_phy_access_lock);
|
||||||
|
// ESP32H2-TODO: enable common clk.
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_phy_disable(void)
|
||||||
|
{
|
||||||
|
// ESP32H2-TODO: close rf and disable clk for modem sleep and light sleep
|
||||||
|
}
|
@@ -1,18 +1,19 @@
|
|||||||
|
idf_build_get_property(idf_target IDF_TARGET)
|
||||||
|
|
||||||
idf_component_register(
|
idf_component_register(
|
||||||
INCLUDE_DIRS include
|
INCLUDE_DIRS include
|
||||||
|
REQUIRES esp_phy
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CONFIG_IEEE802154_ENABLED)
|
if(CONFIG_IEEE802154_ENABLED)
|
||||||
|
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
|
||||||
if(CONFIG_IEEE802154_LIB_FROM_INTERNAL_SRC)
|
if(CONFIG_IEEE802154_LIB_FROM_INTERNAL_SRC)
|
||||||
idf_component_get_property(ieee802154_lib ieee802154_driver COMPONENT_LIB)
|
idf_component_get_property(ieee802154_lib ieee802154_driver COMPONENT_LIB)
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${ieee802154_lib}>)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${ieee802154_lib}> libphy.a libbtbb.a
|
||||||
|
$<TARGET_FILE:${esp_phy_lib}>)
|
||||||
else()
|
else()
|
||||||
add_prebuilt_library(ieee802154_lib "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/lib802154.a")
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}")
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE ieee802154_lib)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> lib802154.a libphy.a libbtbb.a
|
||||||
|
$<TARGET_FILE:${esp_phy_lib}>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# force the phy libraries to be linked behind ieee802154
|
|
||||||
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
|
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a libbtbb.a
|
|
||||||
$<TARGET_FILE:${esp_phy_lib}>)
|
|
||||||
endif()
|
endif()
|
||||||
|
Submodule components/ieee802154/lib updated: 1751a7a4e2...d7d5f59259
Reference in New Issue
Block a user