Skip to content

Commit

Permalink
Merge branch 'bugfix/gptimer_hal_placement_wrong_condition' into 'mas…
Browse files Browse the repository at this point in the history
…ter'

fix(gptimer): hal function placement under wrong condition

Closes IDFGH-10809

See merge request espressif/esp-idf!25237
  • Loading branch information
suda-morris committed Aug 8, 2023
2 parents 259dea3 + a662ec0 commit 3e31826
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 37 deletions.
32 changes: 1 addition & 31 deletions components/driver/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -306,37 +306,7 @@ menu "Driver Configurations"
Note that, this option only controls the Analog Comparator driver log, won't affect other drivers.
endmenu # Analog Comparator Configuration

menu "GPTimer Configuration"
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
orsource "./gptimer/Kconfig.gptimer"

menu "PCNT Configuration"
depends on SOC_PCNT_SUPPORTED
Expand Down
39 changes: 39 additions & 0 deletions components/driver/gptimer/Kconfig.gptimer
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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
select GPTIMER_ISR_NON_MASKABLE
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
3 changes: 1 addition & 2 deletions components/driver/gptimer/gptimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ static esp_err_t gptimer_select_periph_clock(gptimer_t *timer, gptimer_clock_sou
return ESP_OK;
}

// Put the default ISR handler in the IRAM for better performance
IRAM_ATTR static void gptimer_default_isr(void *args)
static void gptimer_default_isr(void *args)
{
bool need_yield = false;
gptimer_t *timer = (gptimer_t *)args;
Expand Down
4 changes: 4 additions & 0 deletions components/driver/gptimer/linker.lf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[mapping:gptimer_driver]
archive: libdriver.a
entries:
if GPTIMER_ISR_HANDLER_IN_IRAM = y:
gptimer: gptimer_default_isr (noflash)
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
gptimer: gptimer_set_raw_count (noflash)
gptimer: gptimer_get_raw_count (noflash)
Expand All @@ -12,6 +14,8 @@ entries:
[mapping:gptimer_hal]
archive: libhal.a
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:
timer_hal: timer_hal_set_counter_value (noflash)
timer_hal: timer_hal_capture_and_get_counter_value (noflash)
5 changes: 3 additions & 2 deletions docs/en/api-reference/peripherals/gptimer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ All the APIs provided by the driver are guaranteed to be thread safe, which mean
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_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_CTRL_FUNC_IN_IRAM` controls where to place the GPTimer control functions (IRAM or flash).
- :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.

Application Examples
Expand Down
5 changes: 3 additions & 2 deletions docs/zh_CN/api-reference/peripherals/gptimer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ IRAM 安全
Kconfig 选项
^^^^^^^^^^^^^^^^^^^^^^

- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` 控制放置通用定时器控制函数(IRAM 或 flash)的位置。了解更多信息,请参考章节 :ref:`gptimer-iram-safe`。
- :ref:`CONFIG_GPTIMER_ISR_IRAM_SAFE` 控制默认 ISR 程序在 cache 禁用时是否可以运行。了解更多信息,请参考章节 :ref:`gptimer-iram-safe`。
- :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` 控制着定时器控制函数的存放位置(IRAM 或 flash)。
- :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` 用于启用调试日志输出。启用这一选项将增加固件二进制文件大小。

应用示例
Expand Down

0 comments on commit 3e31826

Please sign in to comment.