refactor(gptimer): refactor gptimer driver into a component

This commit is contained in:
morris
2023-10-27 13:57:39 +08:00
parent 455cc345f7
commit 2ef14fe55e
41 changed files with 72 additions and 55 deletions

View File

@@ -63,8 +63,8 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}" INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}"
# Requires "driver" for GPTimer in "SEGGER_SYSVIEW_Config_FreeRTOS.c" PRIV_REQUIRES soc esp_driver_gptimer esp_driver_gpio
PRIV_REQUIRES soc driver esp_driver_gpio driver # TODO: replace with esp_driver_uart (IDF-8384)
REQUIRES esp_timer REQUIRES esp_timer
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@@ -15,7 +15,7 @@ entries:
SEGGER_SYSVIEW_FreeRTOS (noflash) SEGGER_SYSVIEW_FreeRTOS (noflash)
[mapping:app_trace_driver] [mapping:app_trace_driver]
archive: libdriver.a archive: libesp_driver_gptimer.a
entries: entries:
if APPTRACE_SV_TS_SOURCE_GPTIMER = y: if APPTRACE_SV_TS_SOURCE_GPTIMER = y:
gptimer (noflash) gptimer (noflash)

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "test_app_trace_main.c" "test_trace.c" idf_component_register(SRCS "test_app_trace_main.c" "test_trace.c"
INCLUDE_DIRS "." INCLUDE_DIRS "."
PRIV_REQUIRES app_trace unity driver PRIV_REQUIRES app_trace unity esp_driver_gptimer
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@@ -13,7 +13,6 @@ set(includes "include"
"deprecated" "deprecated"
"analog_comparator/include" "analog_comparator/include"
"dac/include" "dac/include"
"gptimer/include"
"i2c/include" "i2c/include"
"i2s/include" "i2s/include"
"ledc/include" "ledc/include"
@@ -66,17 +65,9 @@ if(CONFIG_SOC_PARLIO_SUPPORTED)
list(APPEND srcs "parlio/parlio_common.c" "parlio/parlio_tx.c") list(APPEND srcs "parlio/parlio_common.c" "parlio/parlio_tx.c")
endif() endif()
# GPTimer related source files # GPTimer legacy driver
if(CONFIG_SOC_GPTIMER_SUPPORTED) if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "gptimer/gptimer.c" list(APPEND srcs "deprecated/timer_legacy.c")
"gptimer/gptimer_priv.c"
"deprecated/timer_legacy.c")
list(APPEND ldfragments "gptimer/linker.lf")
endif()
if(CONFIG_SOC_TIMER_SUPPORT_ETM)
list(APPEND srcs "gptimer/gptimer_etm.c")
endif() endif()
# I2C related source files # I2C related source files
@@ -226,7 +217,7 @@ else()
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
# 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_gpio esp_driver_pcnt esp_driver_gptimer
LDFRAGMENTS ${ldfragments} LDFRAGMENTS ${ldfragments}
) )
endif() endif()

View File

@@ -207,10 +207,6 @@ menu "Driver Configurations"
Note that, this option only controls the Analog Comparator driver log, won't affect other drivers. Note that, this option only controls the Analog Comparator driver log, won't affect other drivers.
endmenu # Analog Comparator Configuration endmenu # Analog Comparator Configuration
orsource "./gptimer/Kconfig.gptimer"
orsource "../esp_driver_pcnt/Kconfig.pcnt"
orsource "./rmt/Kconfig.rmt" orsource "./rmt/Kconfig.rmt"
orsource "./mcpwm/Kconfig.mcpwm" orsource "./mcpwm/Kconfig.mcpwm"

View File

@@ -16,10 +16,6 @@ components/driver/test_apps/dac_test_apps/legacy_dac_driver:
disable: disable:
- if: SOC_DAC_SUPPORTED != 1 - if: SOC_DAC_SUPPORTED != 1
components/driver/test_apps/gptimer:
disable:
- if: SOC_GPTIMER_SUPPORTED != 1
components/driver/test_apps/i2c_test_apps: components/driver/test_apps/i2c_test_apps:
disable: disable:
- if: SOC_I2C_SUPPORTED != 1 # TODO: IDF-8070 - if: SOC_I2C_SUPPORTED != 1 # TODO: IDF-8070

View File

@@ -9,5 +9,5 @@ set(srcs "test_app_main.c"
# 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 driver esp_wifi nvs_flash esp_adc test_utils efuse PRIV_REQUIRES esp_driver_gptimer esp_driver_gpio esp_wifi nvs_flash esp_adc test_utils efuse
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@@ -0,0 +1,16 @@
set(srcs)
set(public_include "include")
if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "src/gptimer.c"
"src/gptimer_priv.c")
endif()
if(CONFIG_SOC_TIMER_SUPPORT_ETM)
list(APPEND srcs "src/gptimer_etm.c")
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm"
LDFRAGMENTS "linker.lf"
)

View File

@@ -1,4 +1,4 @@
menu "GPTimer Configuration" menu "ESP-Driver:GPTimer Configurations"
depends on SOC_GPTIMER_SUPPORTED depends on SOC_GPTIMER_SUPPORTED
config GPTIMER_ISR_HANDLER_IN_IRAM config GPTIMER_ISR_HANDLER_IN_IRAM
bool "Place GPTimer ISR handler into IRAM" bool "Place GPTimer ISR handler into IRAM"
@@ -36,4 +36,4 @@ menu "GPTimer Configuration"
help help
Wether to enable the debug log message for GPTimer driver. Wether to enable the debug log message for GPTimer driver.
Note that, this option only controls the GPTimer driver log, won't affect other drivers. Note that, this option only controls the GPTimer driver log, won't affect other drivers.
endmenu # GPTimer Configuration endmenu

View File

@@ -35,7 +35,7 @@ typedef struct {
* @param[in] user_ctx User data, passed from `gptimer_register_event_callbacks` * @param[in] user_ctx User data, passed from `gptimer_register_event_callbacks`
* @return Whether a high priority task has been waken up by this function * @return Whether a high priority task has been waken up by this function
*/ */
typedef bool (*gptimer_alarm_cb_t) (gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx); typedef bool (*gptimer_alarm_cb_t)(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
[mapping:gptimer_driver] [mapping:gptimer_driver]
archive: libdriver.a archive: libesp_driver_gptimer.a
entries: entries:
if GPTIMER_ISR_HANDLER_IN_IRAM = y: if GPTIMER_ISR_HANDLER_IN_IRAM = y:
gptimer: gptimer_default_isr (noflash) gptimer: gptimer_default_isr (noflash)

View File

@@ -254,8 +254,8 @@ esp_err_t gptimer_register_event_callbacks(gptimer_handle_t timer, const gptimer
isr_flags |= 1 << (timer->intr_priority); isr_flags |= 1 << (timer->intr_priority);
} }
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(timer_group_periph_signals.groups[group_id].timer_irq_id[timer_id], isr_flags, ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(timer_group_periph_signals.groups[group_id].timer_irq_id[timer_id], isr_flags,
(uint32_t)timer_ll_get_intr_status_reg(timer->hal.dev), TIMER_LL_EVENT_ALARM(timer_id), (uint32_t)timer_ll_get_intr_status_reg(timer->hal.dev), TIMER_LL_EVENT_ALARM(timer_id),
gptimer_default_isr, timer, &timer->intr), TAG, "install interrupt service failed"); gptimer_default_isr, timer, &timer->intr), TAG, "install interrupt service failed");
} }
// enable/disable GPTimer interrupt events // enable/disable GPTimer interrupt events

View File

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

View File

@@ -10,7 +10,7 @@ project(gptimer_test)
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_gptimer/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/gptimer_test.elf --elf-file ${CMAKE_BINARY_DIR}/gptimer_test.elf
find-refs find-refs
--from-sections=.iram0.text --from-sections=.iram0.text

View File

@@ -4,14 +4,8 @@ if(CONFIG_SOC_PCNT_SUPPORTED)
list(APPEND srcs "src/pulse_cnt.c") list(APPEND srcs "src/pulse_cnt.c")
endif() endif()
if(BOOTLOADER_BUILD) idf_component_register(SRCS ${srcs}
# Bootloader shall NOT depend on the drivers INCLUDE_DIRS ${public_include}
idf_component_register() PRIV_REQUIRES "esp_pm" "esp_driver_gpio"
else() LDFRAGMENTS "linker.lf"
idf_component_register(SRCS ${srcs} )
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm"
"esp_driver_gpio"
LDFRAGMENTS "linker.lf"
)
endif()

View File

@@ -1,4 +1,4 @@
menu "PCNT Configuration" menu "ESP-Driver:PCNT Configurations"
depends on SOC_PCNT_SUPPORTED depends on SOC_PCNT_SUPPORTED
config PCNT_CTRL_FUNC_IN_IRAM config PCNT_CTRL_FUNC_IN_IRAM
bool "Place PCNT control functions into IRAM" bool "Place PCNT control functions into IRAM"
@@ -29,4 +29,4 @@ menu "PCNT Configuration"
help help
Wether to enable the debug log message for PCNT driver. Wether to enable the debug log message for PCNT driver.
Note that, this option only controls the PCNT driver log, won't affect other drivers. Note that, this option only controls the PCNT driver log, won't affect other drivers.
endmenu # PCNT Configuration endmenu

View File

@@ -13,6 +13,11 @@ components/esp_hw_support/test_apps/esp_hw_support_unity_tests:
components/esp_hw_support/test_apps/etm: components/esp_hw_support/test_apps/etm:
disable: disable:
- if: SOC_ETM_SUPPORTED != 1 - if: SOC_ETM_SUPPORTED != 1
depends_components:
- esp_driver_gptimer
- esp_driver_gpio
- esp_timer
- driver # TODO: replace with esp_driver_mcpwm, esp_driver_ana_cmpr
components/esp_hw_support/test_apps/host_test_linux: components/esp_hw_support/test_apps/host_test_linux:
enable: enable:

View File

@@ -29,5 +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 driver PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio
driver # TODO: replace with esp_driver_mcpwm (IDF-8379), esp_driver_ana_cmpr
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@@ -38,10 +38,9 @@ components/spi_flash/test_apps/flash_suspend:
- if: IDF_TARGET != "esp32c3" - if: IDF_TARGET != "esp32c3"
temporary: true temporary: true
reason: lack of runners reason: lack of runners
depends_filepatterns:
- components/driver/gptimer/**/*
depends_components: depends_components:
- spi_flash - spi_flash
- esp_driver_gptimer
components/spi_flash/test_apps/mspi_test: components/spi_flash/test_apps/mspi_test:
disable: disable:

View File

@@ -79,9 +79,6 @@ INPUT = \
$(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 \
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_types.h \ $(PROJECT_PATH)/components/driver/dac/include/driver/dac_types.h \
$(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer.h \
$(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_etm.h \
$(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_types.h \
$(PROJECT_PATH)/components/driver/i2c/include/driver/i2c.h \ $(PROJECT_PATH)/components/driver/i2c/include/driver/i2c.h \
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_common.h \ $(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_common.h \
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_pdm.h \ $(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_pdm.h \
@@ -139,6 +136,9 @@ INPUT = \
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_filter.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_filter.h \
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/lp_io.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/lp_io.h \
$(PROJECT_PATH)/components/esp_driver_gpio/include/driver/rtc_io.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/rtc_io.h \
$(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_pcnt/include/driver/pulse_cnt.h \ $(PROJECT_PATH)/components/esp_driver_pcnt/include/driver/pulse_cnt.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \

View File

@@ -299,13 +299,23 @@ examples/peripherals/temperature_sensor/temp_sensor_monitor:
disable: disable:
- if: SOC_TEMPERATURE_SENSOR_INTR_SUPPORT != 1 - if: SOC_TEMPERATURE_SENSOR_INTR_SUPPORT != 1
examples/peripherals/timer_group: examples/peripherals/timer_group/gptimer:
disable: disable:
- if: SOC_GPTIMER_SUPPORTED != 1 - if: SOC_GPTIMER_SUPPORTED != 1
depends_components:
- esp_driver_gptimer
examples/peripherals/timer_group/gptimer_capture_hc_sr04: examples/peripherals/timer_group/gptimer_capture_hc_sr04:
disable: disable:
- if: SOC_TIMER_SUPPORT_ETM != 1 - if: SOC_TIMER_SUPPORT_ETM != 1
depends_components:
- esp_driver_gptimer
examples/peripherals/timer_group/legacy_driver:
disable:
- if: SOC_GPTIMER_SUPPORTED != 1
depends_components:
- driver # legacy driver is still located in the "driver" component
examples/peripherals/touch_sensor: examples/peripherals/touch_sensor:
disable: disable:

View File

@@ -81,7 +81,7 @@ examples/system/eventfd:
- if: SOC_GPTIMER_SUPPORTED != 1 - if: SOC_GPTIMER_SUPPORTED != 1
depends_components: depends_components:
- vfs - vfs
- driver - esp_driver_gptimer
examples/system/flash_suspend: examples/system/flash_suspend:
enable: enable:

View File

@@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included
cxx cxx
# [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi # [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi
# all of these should be removed from G1 except for spi_flash. # all of these should be removed from G1 except for spi_flash.
driver esp_driver_gpio esp_driver_pcnt driver esp_driver_gpio esp_driver_pcnt esp_driver_gptimer
# esp_app_format is dependency of bootloader_support, app_update # esp_app_format is dependency of bootloader_support, app_update
esp_app_format esp_app_format
# esp_bootloader_format is dependency of bootloader_support, app_update # esp_bootloader_format is dependency of bootloader_support, app_update

View File

@@ -16,5 +16,7 @@ endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include INCLUDE_DIRS include
REQUIRES esp_partition idf_test cmock REQUIRES esp_partition idf_test cmock
PRIV_REQUIRES perfmon esp_driver_pcnt driver esp_netif) PRIV_REQUIRES perfmon esp_driver_pcnt esp_driver_gptimer esp_netif
driver # TODO: replace with esp_driver_rmt
)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")