feat(ledc): make esp_driver_ledc as component

This commit is contained in:
wanlei 2023-12-28 14:54:19 +08:00
parent 227c5d2cb7
commit 82f26471f0
25 changed files with 79 additions and 63 deletions

View File

@ -10,7 +10,6 @@ set(srcs)
# Always included headers
set(includes "deprecated"
"i2c/include"
"ledc/include"
"parlio/include"
"touch_sensor/include"
"twai/include"
@ -54,13 +53,6 @@ if(CONFIG_SOC_I2S_SUPPORTED)
list(APPEND srcs "deprecated/i2s_legacy.c")
endif()
# LEDC related source files
if(CONFIG_SOC_LEDC_SUPPORTED)
list(APPEND srcs "ledc/ledc.c")
list(APPEND ldfragments "ledc/linker.lf")
endif()
# MCPWM legacy driver
if(CONFIG_SOC_MCPWM_SUPPORTED)
list(APPEND srcs "deprecated/mcpwm_legacy.c")
@ -127,7 +119,7 @@ else()
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio
esp_driver_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm esp_driver_i2c
esp_driver_uart
esp_driver_uart esp_driver_ledc
LDFRAGMENTS ${ldfragments}
)
endif()

View File

@ -101,6 +101,4 @@ menu "Driver Configurations"
endmenu # Parallel IO Configuration
orsource "./ledc/Kconfig.ledc"
endmenu # Driver configurations

View File

@ -18,10 +18,6 @@ components/driver/test_apps/i2s_test_apps/legacy_i2s_driver:
temporary: true
reason: lack of runners
components/driver/test_apps/ledc:
disable:
- if: SOC_LEDC_SUPPORTED != 1
components/driver/test_apps/legacy_adc_driver:
disable:
- if: SOC_ADC_SUPPORTED != 1

View File

@ -1,21 +0,0 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ledc_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/ledc_test.elf
find-refs
--from-sections=.iram0.text
--to-sections=.flash.text,.flash.rodata
--exit-code
DEPENDS ${elf}
)
endif()

View File

@ -0,0 +1,14 @@
set(srcs)
set(public_include "include")
if(CONFIG_SOC_LEDC_SUPPORTED)
list(APPEND srcs "src/ledc.c")
endif()
idf_component_register(
SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm" "esp_driver_gpio"
LDFRAGMENTS "linker.lf"
)

View File

@ -1,4 +1,4 @@
menu "LEDC Configuration"
menu "ESP-Driver:LEDC Configurations"
config LEDC_CTRL_FUNC_IN_IRAM
bool "Place LEDC control functions into IRAM"
@ -8,4 +8,4 @@ menu "LEDC Configuration"
so that these functions can be IRAM-safe and able to be called in an IRAM context.
Enabling this option can improve driver performance as well.
endmenu # LEDC Configuration
endmenu

View File

@ -1,5 +1,5 @@
[mapping:ledc_driver]
archive: libdriver.a
archive: libesp_driver_ledc.a
entries:
if LEDC_CTRL_FUNC_IN_IRAM = y:
ledc: ledc_stop (noflash)

View File

@ -453,7 +453,6 @@ static uint32_t ledc_auto_clk_divisor(ledc_mode_t speed_mode, int freq_hz, uint3
return ret;
}
/**
* @brief Function setting the LEDC timer divisor with the given source clock,
* frequency and resolution. If the clock configuration passed is
@ -593,11 +592,12 @@ static esp_err_t ledc_timer_del(ledc_mode_t speed_mode, ledc_timer_t timer_sel)
bool is_configured = true;
bool is_deleted = false;
portENTER_CRITICAL(&ledc_spinlock);
if (p_ledc_obj[speed_mode]->glb_clk_is_acquired[timer_sel] == false
#if SOC_LEDC_HAS_TIMER_SPECIFIC_MUX
&& p_ledc_obj[speed_mode]->timer_specific_clk[timer_sel] == LEDC_TIMER_SPECIFIC_CLK_UNINIT
if (p_ledc_obj[speed_mode]->glb_clk_is_acquired[timer_sel] == false && p_ledc_obj[speed_mode]->timer_specific_clk[timer_sel] == LEDC_TIMER_SPECIFIC_CLK_UNINIT)
#else
if (p_ledc_obj[speed_mode]->glb_clk_is_acquired[timer_sel] == false)
#endif
) {
{
is_configured = false;
} else if (p_ledc_obj[speed_mode]->timer_is_stopped[timer_sel] == true) {
is_deleted = true;

View File

@ -0,0 +1,7 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/esp_driver_ledc/test_apps/ledc:
disable:
- if: SOC_LEDC_SUPPORTED != 1
depends_components:
- esp_driver_ledc

View File

@ -0,0 +1,22 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ledc_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(
check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_ledc/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/ledc_test.elf
find-refs
--from-sections=.iram0.text
--to-sections=.flash.text,.flash.rodata
--exit-code
DEPENDS ${elf}
)
endif()

View File

@ -3,6 +3,8 @@ set(srcs "test_app_main.c"
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity esp_driver_pcnt driver esp_timer esp_psram
WHOLE_ARCHIVE)
idf_component_register(
SRCS ${srcs}
PRIV_REQUIRES unity esp_driver_pcnt esp_driver_ledc esp_driver_gpio esp_timer esp_psram
WHOLE_ARCHIVE
)

View File

@ -73,7 +73,6 @@ INPUT = \
$(PROJECT_PATH)/components/bt/host/bluedroid/api/include/api/esp_spp_api.h \
$(PROJECT_PATH)/components/bt/host/nimble/esp-hci/include/esp_nimble_hci.h \
$(PROJECT_PATH)/components/console/esp_console.h \
$(PROJECT_PATH)/components/driver/ledc/include/driver/ledc.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \
$(PROJECT_PATH)/components/driver/touch_sensor/include/driver/touch_sensor_common.h \
@ -108,6 +107,7 @@ INPUT = \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer.h \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_etm.h \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_types.h \
$(PROJECT_PATH)/components/esp_driver_ledc/include/driver/ledc.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_cmpr.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_etm.h \

View File

@ -24,6 +24,7 @@ In order to control the dependence of other components on drivers at a smaller g
- `esp_driver_sdm` - Driver for Sigma-Delta Modulator
- `esp_driver_i2c` - Driver for I2C
- `esp_driver_uart` - Driver for UART
- `esp_driver_ledc` - Driver for LEDC
For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on.

View File

@ -24,6 +24,7 @@
- `esp_driver_sdm` - Sigma-Delta 调制器驱动
- `esp_driver_i2c` - I2C 驱动
- `esp_driver_uart` - UART 驱动
- `esp_driver_ledc` - LEDC 驱动
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。

View File

@ -7,6 +7,6 @@ set(COMPONENT_SRCS
set(COMPONENT_ADD_INCLUDEDIRS ". include")
# requirements can't depend on config
set(COMPONENT_REQUIRES example_nvs driver esp_driver_gpio)
set(COMPONENT_REQUIRES example_nvs driver esp_driver_gpio esp_driver_ledc)
register_component()

View File

@ -169,10 +169,14 @@ examples/peripherals/lcd/tjpgd:
examples/peripherals/ledc:
disable:
- if: SOC_LEDC_SUPPORTED != 1
depends_components:
- esp_driver_ledc
examples/peripherals/ledc/ledc_gamma_curve_fade:
disable:
- if: SOC_LEDC_SUPPORTED != 1 or SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED != 1
depends_components:
- esp_driver_ledc
examples/peripherals/mcpwm:
disable: