forked from espressif/esp-idf
refactor(ana_cmpr): make analog comparator driver as component
This commit is contained in:
@@ -10,7 +10,6 @@ set(srcs)
|
|||||||
# Always included headers
|
# Always included headers
|
||||||
set(includes "include"
|
set(includes "include"
|
||||||
"deprecated"
|
"deprecated"
|
||||||
"analog_comparator/include"
|
|
||||||
"dac/include"
|
"dac/include"
|
||||||
"i2c/include"
|
"i2c/include"
|
||||||
"i2s/include"
|
"i2s/include"
|
||||||
@@ -38,14 +37,6 @@ if(CONFIG_SOC_ADC_DMA_SUPPORTED)
|
|||||||
list(APPEND srcs "deprecated/adc_dma_legacy.c")
|
list(APPEND srcs "deprecated/adc_dma_legacy.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Analog comparator related source files
|
|
||||||
if(CONFIG_SOC_ANA_CMPR_SUPPORTED)
|
|
||||||
list(APPEND srcs "analog_comparator/ana_cmpr.c")
|
|
||||||
if(CONFIG_SOC_ANA_CMPR_SUPPORT_ETM)
|
|
||||||
list(APPEND srcs "analog_comparator/ana_cmpr_etm.c")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# DAC related source files
|
# DAC related source files
|
||||||
if(CONFIG_SOC_DAC_SUPPORTED)
|
if(CONFIG_SOC_DAC_SUPPORTED)
|
||||||
list(APPEND srcs "dac/dac_oneshot.c"
|
list(APPEND srcs "dac/dac_oneshot.c"
|
||||||
@@ -192,7 +183,7 @@ else()
|
|||||||
# for backward compatibility, the driver component needs to
|
# for backward compatibility, the driver component needs to
|
||||||
# have a public dependency on other "esp_driver_foo" components
|
# have a public dependency on other "esp_driver_foo" components
|
||||||
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
|
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
|
||||||
esp_driver_sdmmc
|
esp_driver_sdmmc esp_driver_ana_cmpr
|
||||||
LDFRAGMENTS ${ldfragments}
|
LDFRAGMENTS ${ldfragments}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -120,31 +120,6 @@ menu "Driver Configurations"
|
|||||||
Note that, this option only controls the SDM driver log, won't affect other drivers.
|
Note that, this option only controls the SDM driver log, won't affect other drivers.
|
||||||
endmenu # Sigma Delta Modulator Configuration
|
endmenu # Sigma Delta Modulator Configuration
|
||||||
|
|
||||||
menu "Analog Comparator Configuration"
|
|
||||||
depends on SOC_ANA_CMPR_SUPPORTED
|
|
||||||
config ANA_CMPR_ISR_IRAM_SAFE
|
|
||||||
bool "Analog comparator ISR IRAM-Safe"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Ensure the Analog Comparator interrupt is IRAM-Safe by allowing the interrupt handler to be
|
|
||||||
executable when the cache is disabled (e.g. SPI Flash write).
|
|
||||||
|
|
||||||
config ANA_CMPR_CTRL_FUNC_IN_IRAM
|
|
||||||
bool "Place Analog Comparator control functions into IRAM"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Place Analog Comparator control functions (like ana_cmpr_set_internal_reference) into IRAM,
|
|
||||||
so that these functions can be IRAM-safe and able to be called in an IRAM interrupt context.
|
|
||||||
Enabling this option can improve driver performance as well.
|
|
||||||
|
|
||||||
config ANA_CMPR_ENABLE_DEBUG_LOG
|
|
||||||
bool "Enable debug log"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Wether to enable the debug log message for Analog Comparator driver.
|
|
||||||
Note that, this option only controls the Analog Comparator driver log, won't affect other drivers.
|
|
||||||
endmenu # Analog Comparator Configuration
|
|
||||||
|
|
||||||
orsource "./rmt/Kconfig.rmt"
|
orsource "./rmt/Kconfig.rmt"
|
||||||
|
|
||||||
menu "I2S Configuration"
|
menu "I2S Configuration"
|
||||||
|
@@ -3,10 +3,6 @@ archive: libdriver.a
|
|||||||
entries:
|
entries:
|
||||||
if SDM_CTRL_FUNC_IN_IRAM = y:
|
if SDM_CTRL_FUNC_IN_IRAM = y:
|
||||||
sdm: sdm_channel_set_pulse_density (noflash)
|
sdm: sdm_channel_set_pulse_density (noflash)
|
||||||
if ANA_CMPR_CTRL_FUNC_IN_IRAM = y:
|
|
||||||
ana_cmpr: ana_cmpr_set_internal_reference (noflash)
|
|
||||||
ana_cmpr: ana_cmpr_set_debounce (noflash)
|
|
||||||
ana_cmpr: ana_cmpr_set_cross_type (noflash)
|
|
||||||
if DAC_CTRL_FUNC_IN_IRAM = y:
|
if DAC_CTRL_FUNC_IN_IRAM = y:
|
||||||
dac_oneshot: dac_oneshot_output_voltage (noflash)
|
dac_oneshot: dac_oneshot_output_voltage (noflash)
|
||||||
dac_continuous: dac_continuous_write_asynchronously (noflash)
|
dac_continuous: dac_continuous_write_asynchronously (noflash)
|
||||||
|
@@ -1,13 +1,5 @@
|
|||||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
components/driver/test_apps/analog_comparator:
|
|
||||||
disable:
|
|
||||||
- if: SOC_ANA_CMPR_SUPPORTED != 1
|
|
||||||
disable_test:
|
|
||||||
- if: IDF_TARGET == "esp32p4"
|
|
||||||
temporary: true
|
|
||||||
reason: not supported yet
|
|
||||||
|
|
||||||
components/driver/test_apps/dac_test_apps/dac:
|
components/driver/test_apps/dac_test_apps/dac:
|
||||||
disable:
|
disable:
|
||||||
- if: SOC_DAC_SUPPORTED != 1
|
- if: SOC_DAC_SUPPORTED != 1
|
||||||
|
15
components/esp_driver_ana_cmpr/CMakeLists.txt
Normal file
15
components/esp_driver_ana_cmpr/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
set(srcs)
|
||||||
|
|
||||||
|
# Analog comparator related source files
|
||||||
|
if(CONFIG_SOC_ANA_CMPR_SUPPORTED)
|
||||||
|
list(APPEND srcs "ana_cmpr.c")
|
||||||
|
if(CONFIG_SOC_ANA_CMPR_SUPPORT_ETM)
|
||||||
|
list(APPEND srcs "ana_cmpr_etm.c")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
idf_component_register(SRCS ${srcs}
|
||||||
|
INCLUDE_DIRS "include"
|
||||||
|
PRIV_REQUIRES esp_pm esp_driver_gpio
|
||||||
|
LDFRAGMENTS "linker.lf"
|
||||||
|
)
|
24
components/esp_driver_ana_cmpr/Kconfig
Normal file
24
components/esp_driver_ana_cmpr/Kconfig
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
menu "ESP-Driver:Analog Comparator Configurations"
|
||||||
|
depends on SOC_ANA_CMPR_SUPPORTED
|
||||||
|
config ANA_CMPR_ISR_IRAM_SAFE
|
||||||
|
bool "Analog comparator ISR IRAM-Safe"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Ensure the Analog Comparator interrupt is IRAM-Safe by allowing the interrupt handler to be
|
||||||
|
executable when the cache is disabled (e.g. SPI Flash write).
|
||||||
|
|
||||||
|
config ANA_CMPR_CTRL_FUNC_IN_IRAM
|
||||||
|
bool "Place Analog Comparator control functions into IRAM"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Place Analog Comparator control functions (like ana_cmpr_set_internal_reference) into IRAM,
|
||||||
|
so that these functions can be IRAM-safe and able to be called in an IRAM interrupt context.
|
||||||
|
Enabling this option can improve driver performance as well.
|
||||||
|
|
||||||
|
config ANA_CMPR_ENABLE_DEBUG_LOG
|
||||||
|
bool "Enable debug log"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Wether to enable the debug log message for Analog Comparator driver.
|
||||||
|
Note that, this option only controls the Analog Comparator driver log, won't affect other drivers.
|
||||||
|
endmenu # Analog Comparator Configuration
|
7
components/esp_driver_ana_cmpr/linker.lf
Normal file
7
components/esp_driver_ana_cmpr/linker.lf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[mapping:ana_cmpr_driver]
|
||||||
|
archive: libesp_driver_ana_cmpr.a
|
||||||
|
entries:
|
||||||
|
if ANA_CMPR_CTRL_FUNC_IN_IRAM = y:
|
||||||
|
ana_cmpr: ana_cmpr_set_internal_reference (noflash)
|
||||||
|
ana_cmpr: ana_cmpr_set_debounce (noflash)
|
||||||
|
ana_cmpr: ana_cmpr_set_cross_type (noflash)
|
@@ -0,0 +1,12 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/esp_driver_ana_cmpr/test_apps/analog_comparator:
|
||||||
|
disable:
|
||||||
|
- if: SOC_ANA_CMPR_SUPPORTED != 1
|
||||||
|
disable_test:
|
||||||
|
- if: IDF_TARGET == "esp32p4"
|
||||||
|
temporary: true
|
||||||
|
reason: not supported yet
|
||||||
|
depends_components:
|
||||||
|
- esp_driver_gpio
|
||||||
|
- esp_driver_ana_cmpr
|
@@ -10,7 +10,7 @@ project(test_ana_cmpr)
|
|||||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||||
add_custom_target(check_test_app_sections ALL
|
add_custom_target(check_test_app_sections ALL
|
||||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_ana_cmpr/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||||
--elf-file ${CMAKE_BINARY_DIR}/test_ana_cmpr.elf
|
--elf-file ${CMAKE_BINARY_DIR}/test_ana_cmpr.elf
|
||||||
find-refs
|
find-refs
|
||||||
--from-sections=.iram0.text
|
--from-sections=.iram0.text
|
@@ -8,5 +8,5 @@ endif()
|
|||||||
|
|
||||||
idf_component_register(SRCS ${srcs}
|
idf_component_register(SRCS ${srcs}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES unity driver
|
PRIV_REQUIRES unity esp_driver_gpio esp_driver_ana_cmpr
|
||||||
WHOLE_ARCHIVE)
|
WHOLE_ARCHIVE)
|
@@ -18,7 +18,7 @@ components/esp_hw_support/test_apps/etm:
|
|||||||
- esp_driver_gpio
|
- esp_driver_gpio
|
||||||
- esp_driver_mcpwm
|
- esp_driver_mcpwm
|
||||||
- esp_timer
|
- esp_timer
|
||||||
- driver # TODO: replace with esp_driver_ana_cmpr (IDF-8521)
|
- esp_driver_ana_cmpr
|
||||||
|
|
||||||
components/esp_hw_support/test_apps/host_test_linux:
|
components/esp_hw_support/test_apps/host_test_linux:
|
||||||
enable:
|
enable:
|
||||||
|
@@ -29,6 +29,6 @@ endif()
|
|||||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||||
# the component can be registered as WHOLE_ARCHIVE
|
# the component can be registered as WHOLE_ARCHIVE
|
||||||
idf_component_register(SRCS ${srcs}
|
idf_component_register(SRCS ${srcs}
|
||||||
PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio esp_driver_mcpwm
|
PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio
|
||||||
driver # TODO: replace with esp_driver_ana_cmpr (IDF-8521)
|
esp_driver_mcpwm esp_driver_ana_cmpr
|
||||||
WHOLE_ARCHIVE)
|
WHOLE_ARCHIVE)
|
||||||
|
@@ -73,9 +73,6 @@ INPUT = \
|
|||||||
$(PROJECT_PATH)/components/bt/host/bluedroid/api/include/api/esp_spp_api.h \
|
$(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/bt/host/nimble/esp-hci/include/esp_nimble_hci.h \
|
||||||
$(PROJECT_PATH)/components/console/esp_console.h \
|
$(PROJECT_PATH)/components/console/esp_console.h \
|
||||||
$(PROJECT_PATH)/components/driver/analog_comparator/include/driver/ana_cmpr.h \
|
|
||||||
$(PROJECT_PATH)/components/driver/analog_comparator/include/driver/ana_cmpr_etm.h \
|
|
||||||
$(PROJECT_PATH)/components/driver/analog_comparator/include/driver/ana_cmpr_types.h \
|
|
||||||
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_continuous.h \
|
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_continuous.h \
|
||||||
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_cosine.h \
|
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_cosine.h \
|
||||||
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_oneshot.h \
|
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_oneshot.h \
|
||||||
@@ -124,6 +121,9 @@ INPUT = \
|
|||||||
$(PROJECT_PATH)/components/esp_common/include/esp_check.h \
|
$(PROJECT_PATH)/components/esp_common/include/esp_check.h \
|
||||||
$(PROJECT_PATH)/components/esp_common/include/esp_err.h \
|
$(PROJECT_PATH)/components/esp_common/include/esp_err.h \
|
||||||
$(PROJECT_PATH)/components/esp_common/include/esp_idf_version.h \
|
$(PROJECT_PATH)/components/esp_common/include/esp_idf_version.h \
|
||||||
|
$(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr.h \
|
||||||
|
$(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_etm.h \
|
||||||
|
$(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h \
|
||||||
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/dedic_gpio.h \
|
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/dedic_gpio.h \
|
||||||
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio.h \
|
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio.h \
|
||||||
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_etm.h \
|
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_etm.h \
|
||||||
|
@@ -11,6 +11,7 @@ In order to control the dependence of other components on drivers at a smaller g
|
|||||||
- `esp_driver_spi` - Driver for GPSPI
|
- `esp_driver_spi` - Driver for GPSPI
|
||||||
- `esp_driver_mcpwm` - Driver for Motor Control PWM
|
- `esp_driver_mcpwm` - Driver for Motor Control PWM
|
||||||
- `esp_driver_sdmmc` - Driver for SDMMC
|
- `esp_driver_sdmmc` - Driver for SDMMC
|
||||||
|
- `esp_driver_ana_cmpr` - Driver for Analog Comparator
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
- `esp_driver_spi` - 通用 SPI 驱动
|
- `esp_driver_spi` - 通用 SPI 驱动
|
||||||
- `esp_driver_mcpwm` - 电机控制 PWM 驱动
|
- `esp_driver_mcpwm` - 电机控制 PWM 驱动
|
||||||
- `esp_driver_sdmmc` - SDMMC 驱动
|
- `esp_driver_sdmmc` - SDMMC 驱动
|
||||||
|
- `esp_driver_ana_cmpr` - 模拟比较器驱动
|
||||||
|
|
||||||
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。
|
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。
|
||||||
|
|
||||||
|
@@ -22,6 +22,9 @@ examples/peripherals/analog_comparator:
|
|||||||
- if: IDF_TARGET == "esp32p4"
|
- if: IDF_TARGET == "esp32p4"
|
||||||
temporary: true
|
temporary: true
|
||||||
reason: not supported yet
|
reason: not supported yet
|
||||||
|
depends_components:
|
||||||
|
- esp_driver_gpio
|
||||||
|
- esp_driver_ana_cmpr
|
||||||
|
|
||||||
examples/peripherals/dac:
|
examples/peripherals/dac:
|
||||||
disable:
|
disable:
|
||||||
|
@@ -5,4 +5,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
set(COMPONENTS main)
|
||||||
|
|
||||||
project(analog_comparator_example)
|
project(analog_comparator_example)
|
||||||
|
@@ -7,4 +7,5 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS ${src}
|
idf_component_register(SRCS ${src}
|
||||||
|
PRIV_REQUIRES esp_driver_ana_cmpr esp_driver_gpio
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
Reference in New Issue
Block a user