Skip to content

Commit

Permalink
Merge branch 'docs/update_application_examples_of_gptimer' into 'master'
Browse files Browse the repository at this point in the history
docs: Update the application examples in gptimer.rst

See merge request espressif/esp-idf!32646
  • Loading branch information
Zhang Shu Xian committed Aug 20, 2024
2 parents a41c5c9 + ab7c3a5 commit 15825dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
20 changes: 12 additions & 8 deletions docs/en/api-reference/peripherals/gptimer.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
General Purpose Timer (GPTimer)
===============================

:link_to_translation:`zh_CN:[中文]`

Introduction
------------

GPTimer (General Purpose Timer) is the driver of {IDF_TARGET_NAME} Timer Group peripheral. The hardware timer features high resolution and flexible alarm action. The behavior when the internal counter of a timer reaches a specific target value is called a timer alarm. When a timer alarms, a user registered per-timer callback would be called.
GPTimer (General Purpose Timer) is the driver of {IDF_TARGET_NAME} Timer Group peripheral. The hardware timer features high resolution and flexible alarm action. A timer alarm occurs when the internal counter of a timer reaches a specific target value. At that moment, a user-registered per-timer callback function is triggered.

Typically, a general purpose timer can be used in scenarios like:
General-purpose timers are typically used in the following scenarios:

- Free running as a wall clock, fetching a high-resolution timestamp at any time and any places
- Generate period alarms, trigger events periodically
- Generate one-shot alarm, respond in target time
- To run freely like a clock, providing high-resolution timestamps anytime and anywhere;
- To generate periodic alarms that trigger events at regular intervals;
- To generate one-shot alarms that respond at a specific target time.

Functional Overview
-------------------
Expand Down Expand Up @@ -114,7 +116,7 @@ This function lazy installs the interrupt service for the timer but not enable i
Enable and Disable Timer
^^^^^^^^^^^^^^^^^^^^^^^^

Before doing IO control to the timer, you needs to enable the timer first, by calling :cpp:func:`gptimer_enable`. This function:
Before doing IO control to the timer, you need to enable the timer first, by calling :cpp:func:`gptimer_enable`. This function:

* Switches the timer driver state from **init** to **enable**.
* Enables the interrupt service if it has been lazy installed by :cpp:func:`gptimer_register_event_callbacks`.
Expand Down Expand Up @@ -341,8 +343,10 @@ Application Examples

.. list::

- Typical use cases of GPTimer are listed in the example :example:`peripherals/timer_group/gptimer`.
:SOC_TIMER_SUPPORT_ETM: - GPTimer capture external event's timestamp, with the help of ETM module: :example:`peripherals/timer_group/gptimer_capture_hc_sr04`.
* :example:`peripherals/timer_group/gptimer` demonstrates how to use the general purpose timer APIs on ESP SOC chip to generate periodic alarm events and manage different alarm actions.
:SOC_TIMER_SUPPORT_ETM: * :example:`peripherals/timer_group/gptimer_capture_hc_sr04` demonstrates how to use the general purpose timer and ETM (Event Task Matrix) peripheral to capture internal timer count values and measure the time between two events, specifically to decode the pulse width signals generated from a common HC-SR04 sonar sensor.
:not esp32c2: * :example:`peripherals/timer_group/wiegand_interface` uses two timers (one in one-shot mode and another in periodic mode) to trigger the interrupt and change the output state of the GPIO in the interrupt.


API Reference
-------------
Expand Down
14 changes: 9 additions & 5 deletions docs/zh_CN/api-reference/peripherals/gptimer.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
通用定时器
=====================

:link_to_translation:`en:[English]`

简介
-----------------

通用定时器是 {IDF_TARGET_NAME} 定时器组外设的驱动程序。{IDF_TARGET_NAME} 硬件定时器分辨率高,具有灵活的报警功能。定时器内部计数器达到特定目标数值的行为被称为定时器报警。定时器报警时将调用用户注册的不同定时器回调函数。

通用定时器通常在以下场景中使用:

- 如同挂钟一般自由运行,随时随地获取高分辨率时间戳;
- 生成周期性警报,定期触发事件;
- 生成一次性警报,在目标时间内响应。
- 如同挂钟一般自由运行,随时随地获取高分辨率时间戳;
- 生成周期性警报,定期触发事件;
- 生成一次性警报,在目标时间内响应。

功能概述
-----------------
Expand Down Expand Up @@ -341,8 +343,10 @@ Kconfig 选项

.. list::

- 示例 :example:`peripherals/timer_group/gptimer` 中列出了通用定时器的典型用例。
:SOC_TIMER_SUPPORT_ETM: - 示例 :example:`peripherals/timer_group/gptimer_capture_hc_sr04` 展示了如何在 ETM 模块的帮助下,用定时器捕获外部事件的时间戳。
* :example:`peripherals/timer_group/gptimer` 演示了如何在 ESP 芯片上使用通用定时器 API 生成周期性警报事件,触发不同的警报动作。
:SOC_TIMER_SUPPORT_ETM: * :example:`peripherals/timer_group/gptimer_capture_hc_sr04` 展示了如何使用通用定时器和事件任务矩阵 (ETM) 外设来捕获内部定时器计数值,并测量两个事件之间的时间,用于解码常见的 HC-SR04 超声波传感器生成的脉冲宽度信号。
:not esp32c2: * :example:`peripherals/timer_group/wiegand_interface` 使用两个定时器(一个在单次触发模式下,另一个在周期触发模式下),来触发中断并在中断中改变 GPIO 的输出状态。


API 参考
-------------------
Expand Down

0 comments on commit 15825dc

Please sign in to comment.