mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 04:04:31 +02:00
fix(gptimer): hal function placement under wrong condition
timer_hal_capture_and_get_counter_value should be placed in the IRAM for speed optimization because the default ISR handler is placed in the IRAM. Closes https://github.com/espressif/esp-idf/issues/12021
This commit is contained in:
@@ -306,37 +306,7 @@ 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
|
||||||
|
|
||||||
menu "GPTimer Configuration"
|
orsource "./gptimer/Kconfig.gptimer"
|
||||||
config GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
bool "Place GPTimer control functions into IRAM"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Place GPTimer control functions (like start/stop) into IRAM,
|
|
||||||
so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context.
|
|
||||||
Enabling this option can improve driver performance as well.
|
|
||||||
|
|
||||||
config GPTIMER_ISR_IRAM_SAFE
|
|
||||||
bool "GPTimer ISR IRAM-Safe"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Ensure the GPTimer interrupt is IRAM-Safe by allowing the interrupt handler to be
|
|
||||||
executable when the cache is disabled (e.g. SPI Flash write).
|
|
||||||
|
|
||||||
config GPTIMER_SUPPRESS_DEPRECATE_WARN
|
|
||||||
bool "Suppress legacy driver deprecated warning"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Wether to suppress the deprecation warnings when using legacy timer group driver (driver/timer.h).
|
|
||||||
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
|
|
||||||
you can enable this option.
|
|
||||||
|
|
||||||
config GPTIMER_ENABLE_DEBUG_LOG
|
|
||||||
bool "Enable debug log"
|
|
||||||
default n
|
|
||||||
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
|
|
||||||
|
|
||||||
menu "PCNT Configuration"
|
menu "PCNT Configuration"
|
||||||
depends on SOC_PCNT_SUPPORTED
|
depends on SOC_PCNT_SUPPORTED
|
||||||
|
38
components/driver/gptimer/Kconfig.gptimer
Normal file
38
components/driver/gptimer/Kconfig.gptimer
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
menu "GPTimer Configuration"
|
||||||
|
config GPTIMER_ISR_HANDLER_IN_IRAM
|
||||||
|
bool "Place GPTimer ISR handler into IRAM"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Place GPTimer ISR handler into IRAM for better performance and fewer cache misses.
|
||||||
|
|
||||||
|
config GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
bool "Place GPTimer control functions into IRAM"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Place GPTimer control functions (like start/stop) into IRAM,
|
||||||
|
so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context.
|
||||||
|
Enabling this option can improve driver performance as well.
|
||||||
|
|
||||||
|
config GPTIMER_ISR_IRAM_SAFE
|
||||||
|
bool "GPTimer ISR IRAM-Safe"
|
||||||
|
select GPTIMER_ISR_HANDLER_IN_IRAM
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Ensure the GPTimer interrupt is IRAM-Safe by allowing the interrupt handler to be
|
||||||
|
executable when the cache is disabled (e.g. SPI Flash write).
|
||||||
|
|
||||||
|
config GPTIMER_SUPPRESS_DEPRECATE_WARN
|
||||||
|
bool "Suppress legacy driver deprecated warning"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Wether to suppress the deprecation warnings when using legacy timer group driver (driver/timer.h).
|
||||||
|
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
|
||||||
|
you can enable this option.
|
||||||
|
|
||||||
|
config GPTIMER_ENABLE_DEBUG_LOG
|
||||||
|
bool "Enable debug log"
|
||||||
|
default n
|
||||||
|
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
|
@@ -480,8 +480,7 @@ static esp_err_t gptimer_select_periph_clock(gptimer_t *timer, gptimer_clock_sou
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the default ISR handler in the IRAM for better performance
|
static void gptimer_default_isr(void *args)
|
||||||
IRAM_ATTR static void gptimer_default_isr(void *args)
|
|
||||||
{
|
{
|
||||||
bool need_yield = false;
|
bool need_yield = false;
|
||||||
gptimer_t *timer = (gptimer_t *)args;
|
gptimer_t *timer = (gptimer_t *)args;
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
[mapping:gptimer_driver]
|
[mapping:gptimer_driver]
|
||||||
archive: libdriver.a
|
archive: libdriver.a
|
||||||
entries:
|
entries:
|
||||||
|
if GPTIMER_ISR_HANDLER_IN_IRAM = y:
|
||||||
|
gptimer: gptimer_default_isr (noflash)
|
||||||
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
||||||
gptimer: gptimer_set_raw_count (noflash)
|
gptimer: gptimer_set_raw_count (noflash)
|
||||||
gptimer: gptimer_get_raw_count (noflash)
|
gptimer: gptimer_get_raw_count (noflash)
|
||||||
@@ -12,6 +14,8 @@ entries:
|
|||||||
[mapping:gptimer_hal]
|
[mapping:gptimer_hal]
|
||||||
archive: libhal.a
|
archive: libhal.a
|
||||||
entries:
|
entries:
|
||||||
|
if GPTIMER_ISR_HANDLER_IN_IRAM = y:
|
||||||
|
timer_hal: timer_hal_capture_and_get_counter_value (noflash)
|
||||||
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
||||||
timer_hal: timer_hal_set_counter_value (noflash)
|
timer_hal: timer_hal_set_counter_value (noflash)
|
||||||
timer_hal: timer_hal_capture_and_get_counter_value (noflash)
|
timer_hal: timer_hal_capture_and_get_counter_value (noflash)
|
||||||
|
@@ -327,8 +327,9 @@ All the APIs provided by the driver are guaranteed to be thread safe, which mean
|
|||||||
Kconfig Options
|
Kconfig Options
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` controls where to place the GPTimer control functions (IRAM or flash), see Section :ref:`gptimer-iram-safe` for more information.
|
- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` controls where to place the GPTimer control functions (IRAM or flash).
|
||||||
- :ref:`CONFIG_GPTIMER_ISR_IRAM_SAFE` controls whether the default ISR handler can work when the cache is disabled, see Section :ref:`gptimer-iram-safe` for more information.
|
- :ref:`CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM` controls where to place the GPTimer ISR handler (IRAM or flash).
|
||||||
|
- :ref:`CONFIG_GPTIMER_ISR_IRAM_SAFE` controls whether the default ISR handler should be masked when the cache is disabled, see Section :ref:`gptimer-iram-safe` for more information.
|
||||||
- :ref:`CONFIG_GPTIMER_ENABLE_DEBUG_LOG` is used to enabled the debug log output. Enable this option will increase the firmware binary size.
|
- :ref:`CONFIG_GPTIMER_ENABLE_DEBUG_LOG` is used to enabled the debug log output. Enable this option will increase the firmware binary size.
|
||||||
|
|
||||||
Application Examples
|
Application Examples
|
||||||
|
@@ -327,8 +327,9 @@ IRAM 安全
|
|||||||
Kconfig 选项
|
Kconfig 选项
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` 控制放置通用定时器控制函数(IRAM 或 flash)的位置。了解更多信息,请参考章节 :ref:`gptimer-iram-safe`。
|
- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` 控制着定时器控制函数的存放位置(IRAM 或 flash)。
|
||||||
- :ref:`CONFIG_GPTIMER_ISR_IRAM_SAFE` 控制默认 ISR 程序在 cache 禁用时是否可以运行。了解更多信息,请参考章节 :ref:`gptimer-iram-safe`。
|
- :ref:`CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM` 控制着定时器中断处理函数的存放位置(IRAM 或 flash)。
|
||||||
|
- :ref:`CONFIG_GPTIMER_ISR_IRAM_SAFE` 控制着中断处理函数是否需要在 cache 关闭的时候被屏蔽掉。更多信息,请参阅 :ref:`gptimer-iram-safe`。
|
||||||
- :ref:`CONFIG_GPTIMER_ENABLE_DEBUG_LOG` 用于启用调试日志输出。启用这一选项将增加固件二进制文件大小。
|
- :ref:`CONFIG_GPTIMER_ENABLE_DEBUG_LOG` 用于启用调试日志输出。启用这一选项将增加固件二进制文件大小。
|
||||||
|
|
||||||
应用示例
|
应用示例
|
||||||
|
Reference in New Issue
Block a user