refactor(gptimer): refactor gptimer driver into a component

pull/12525/head
morris 2023-10-27 13:57:39 +08:00
rodzic 455cc345f7
commit 2ef14fe55e
41 zmienionych plików z 72 dodań i 55 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -13,7 +13,6 @@ set(includes "include"
"deprecated"
"analog_comparator/include"
"dac/include"
"gptimer/include"
"i2c/include"
"i2s/include"
"ledc/include"
@ -66,17 +65,9 @@ if(CONFIG_SOC_PARLIO_SUPPORTED)
list(APPEND srcs "parlio/parlio_common.c" "parlio/parlio_tx.c")
endif()
# GPTimer related source files
# GPTimer legacy driver
if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "gptimer/gptimer.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")
list(APPEND srcs "deprecated/timer_legacy.c")
endif()
# I2C related source files
@ -226,7 +217,7 @@ else()
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
# for backward compatibility, the driver component needs to
# 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}
)
endif()

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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,
# the component can be registered as WHOLE_ARCHIVE
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)

Wyświetl plik

@ -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"
)

Wyświetl plik

@ -1,4 +1,4 @@
menu "GPTimer Configuration"
menu "ESP-Driver:GPTimer Configurations"
depends on SOC_GPTIMER_SUPPORTED
config GPTIMER_ISR_HANDLER_IN_IRAM
bool "Place GPTimer ISR handler into IRAM"
@ -36,4 +36,4 @@ menu "GPTimer Configuration"
help
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.
endmenu # GPTimer Configuration
endmenu

Wyświetl plik

@ -35,7 +35,7 @@ typedef struct {
* @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
*/
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
}

Wyświetl plik

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

Wyświetl plik

@ -254,8 +254,8 @@ esp_err_t gptimer_register_event_callbacks(gptimer_handle_t timer, const gptimer
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,
(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");
(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");
}
// enable/disable GPTimer interrupt events

Wyświetl plik

@ -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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -1,4 +1,4 @@
menu "PCNT Configuration"
menu "ESP-Driver:PCNT Configurations"
depends on SOC_PCNT_SUPPORTED
config PCNT_CTRL_FUNC_IN_IRAM
bool "Place PCNT control functions into IRAM"
@ -29,4 +29,4 @@ menu "PCNT Configuration"
help
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.
endmenu # PCNT Configuration
endmenu

Wyświetl plik

@ -13,6 +13,11 @@ components/esp_hw_support/test_apps/esp_hw_support_unity_tests:
components/esp_hw_support/test_apps/etm:
disable:
- 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:
enable:

Wyświetl plik

@ -29,5 +29,6 @@ endif()
# 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_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)

Wyświetl plik

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

Wyświetl plik

@ -79,9 +79,6 @@ INPUT = \
$(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_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/i2s/include/driver/i2s_common.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/lp_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_eth/include/esp_eth_com.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \

Wyświetl plik

@ -299,13 +299,23 @@ examples/peripherals/temperature_sensor/temp_sensor_monitor:
disable:
- if: SOC_TEMPERATURE_SENSOR_INTR_SUPPORT != 1
examples/peripherals/timer_group:
examples/peripherals/timer_group/gptimer:
disable:
- if: SOC_GPTIMER_SUPPORTED != 1
depends_components:
- esp_driver_gptimer
examples/peripherals/timer_group/gptimer_capture_hc_sr04:
disable:
- 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:
disable:

Wyświetl plik

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

Wyświetl plik

@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included
cxx
# [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.
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
# esp_bootloader_format is dependency of bootloader_support, app_update

Wyświetl plik

@ -16,5 +16,7 @@ endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include
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")