Skip to content

Commit 64726df

Browse files
committed
Merge branch 'docs/update_twai_api_ref_struct_v5.5' into 'release/v5.5'
docs: update heading levels for twai api reference (v5.5) See merge request espressif/esp-idf!43846
2 parents afc3741 + c13ebc1 commit 64726df

File tree

4 files changed

+144
-82
lines changed

4 files changed

+144
-82
lines changed

docs/en/api-reference/peripherals/gptimer.rst

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
===============================
12
General Purpose Timer (GPTimer)
23
===============================
34

@@ -11,7 +12,7 @@ This document introduces the features of the General Purpose Timer (GPTimer) dri
1112
:depth: 2
1213

1314
Overview
14-
--------
15+
========
1516

1617
GPTimer is a dedicated driver for the {IDF_TARGET_NAME} [`Timer Group peripheral <{IDF_TARGET_TRM_EN_URL}#timg>`__]. This timer can select different clock sources and prescalers to meet the requirements of nanosecond-level resolution. Additionally, it has flexible timeout alarm functions and allows automatic updating of the count value at the alarm moment, achieving very precise timing cycles.
1718

@@ -24,7 +25,7 @@ Based on the **high resolution, high count range, and high response** capabiliti
2425
- etc.
2526

2627
Quick Start
27-
-----------
28+
===========
2829

2930
This section provides a concise overview of how to use the GPTimer driver. Through practical examples, it demonstrates how to initialize and start a timer, configure alarm events, and register callback functions. The typical usage flow is as follows:
3031

@@ -54,7 +55,7 @@ This section provides a concise overview of how to use the GPTimer driver. Throu
5455
}
5556

5657
Creating and Starting a Timer
57-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
-----------------------------
5859

5960
First, we need to create a timer instance. The following code shows how to create a timer with a resolution of 1 MHz:
6061

@@ -104,7 +105,7 @@ The :cpp:func:`gptimer_start` and :cpp:func:`gptimer_stop` functions follow the
104105
However, note that when the timer is in the **intermediate state** of starting (the start has begun but not yet completed), if another thread calls the :cpp:func:`gptimer_start` or :cpp:func:`gptimer_stop` function, it will return the :c:macro:`ESP_ERR_INVALID_STATE` error to avoid triggering uncertain behavior.
105106

106107
Setting and Getting the Count Value
107-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108+
-----------------------------------
108109

109110
When a timer is newly created, its internal counter value defaults to zero. You can set other count values using the :cpp:func:`gptimer_set_raw_count` function. The maximum count value depends on the bit width of the hardware timer (usually no less than ``54 bits``).
110111

@@ -126,7 +127,7 @@ The :cpp:func:`gptimer_get_raw_count` function is used to get the current count
126127
double time = (double)count / resolution_hz;
127128
128129
Triggering Periodic Alarm Events
129-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130+
--------------------------------
130131

131132
In addition to the timestamp function, the general-purpose timer also supports alarm functions. The following code shows how to set a periodic alarm that triggers once per second:
132133

@@ -194,7 +195,7 @@ The supported event callback functions for GPTimer are as follows:
194195
Be sure to register the callback function before calling :cpp:func:`gptimer_enable`, otherwise the timer event will not correctly trigger the interrupt service.
195196

196197
Triggering One-Shot Alarm Events
197-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198+
--------------------------------
198199

199200
Some application scenarios only require triggering a one-shot alarm interrupt. The following code shows how to set a one-shot alarm that triggers after 1 second:
200201

@@ -242,17 +243,17 @@ Some application scenarios only require triggering a one-shot alarm interrupt. T
242243
Unlike periodic alarms, the above code disables the auto-reload function when configuring the alarm behavior. This means that after the alarm event occurs, the timer will not automatically reload to the preset count value but will continue counting until it overflows. If you want the timer to stop immediately after the alarm, you can call :cpp:func:`gptimer_stop` in the callback function.
243244

244245
Resource Recycling
245-
^^^^^^^^^^^^^^^^^^
246+
------------------
246247

247248
When the timer is no longer needed, you should call the :cpp:func:`gptimer_delete_timer` function to release software and hardware resources. Before deleting, ensure that the timer is already stopped.
248249

249250
Advanced Features
250-
-----------------
251+
=================
251252

252253
After understanding the basic usage, we can further explore more features of the GPTimer driver.
253254

254255
Dynamic Alarm Value Update
255-
^^^^^^^^^^^^^^^^^^^^^^^^^^
256+
--------------------------
256257

257258
The GPTimer driver supports dynamically updating the alarm value in the interrupt callback function by calling the :cpp:func:`gptimer_set_alarm_action` function, thereby implementing a monotonic software timer list. The following code shows how to reset the next alarm trigger time when the alarm event occurs:
258259

@@ -300,15 +301,15 @@ The GPTimer driver supports dynamically updating the alarm value in the interrup
300301
.. _gptimer-etm-event-and-task:
301302

302303
GPTimer's ETM Events and Tasks
303-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304+
------------------------------
304305

305306
GPTimer can generate various events that can be connected to the :doc:`ETM </api-reference/peripherals/etm>` module. The event types are listed in :cpp:type:`gptimer_etm_event_type_t`. Users can create an ``ETM event`` handle by calling :cpp:func:`gptimer_new_etm_event`.
306307
GPTimer also supports some tasks that can be triggered by other events and executed automatically. The task types are listed in :cpp:type:`gptimer_etm_task_type_t`. Users can create an ``ETM task`` handle by calling :cpp:func:`gptimer_new_etm_task`.
307308

308309
For how to connect the timer events and tasks to the ETM channel, please refer to the :doc:`ETM </api-reference/peripherals/etm>` documentation.
309310

310311
Power Management
311-
^^^^^^^^^^^^^^^^
312+
----------------
312313

313314
When power management :ref:`CONFIG_PM_ENABLE` is enabled, the system may adjust or disable the clock source before entering sleep mode, causing the GPTimer to lose accuracy.
314315

@@ -319,7 +320,7 @@ To prevent this, the GPTimer driver creates a power management lock internally.
319320
Besides disabling the clock source, the system can also power down the GPTimer before entering sleep mode to further reduce power consumption. To achieve this, set :cpp:member:`gptimer_config_t::allow_pd` to ``true``. Before the system enters sleep mode, the GPTimer register context will be backed up to memory and restored after the system wakes up. Note that enabling this option reduces power consumption but increases memory usage. Therefore, you need to balance power consumption and memory usage when using this feature.
320321

321322
Thread Safety
322-
^^^^^^^^^^^^^
323+
-------------
323324

324325
The driver uses critical sections to ensure atomic operations on registers. Key members in the driver handle are also protected by critical sections. The driver's internal state machine uses atomic instructions to ensure thread safety, with state checks preventing certain invalid concurrent operations (e.g., conflicts between `start` and `stop`). Therefore, GPTimer driver APIs can be used in a multi-threaded environment without extra locking.
325326

@@ -335,7 +336,7 @@ The following functions can also be used in an interrupt context:
335336
- :cpp:func:`gptimer_set_alarm_action`
336337

337338
Cache Safety
338-
^^^^^^^^^^^^
339+
------------
339340

340341
When the file system performs Flash read/write operations, the system temporarily disables the Cache function to avoid errors when loading instructions and data from Flash. This causes the GPTimer interrupt handler to be unresponsive during this period, preventing the user callback function from executing in time. If you want the interrupt handler to run normally when the Cache is disabled, you can enable the :ref:`CONFIG_GPTIMER_ISR_CACHE_SAFE` option.
341342

@@ -344,7 +345,7 @@ When the file system performs Flash read/write operations, the system temporaril
344345
Note that when this option is enabled, all interrupt callback functions and their context data **must be placed in internal storage**. This is because the system cannot load data and instructions from Flash when the Cache is disabled.
345346

346347
Performance
347-
^^^^^^^^^^^
348+
-----------
348349

349350
To improve the real-time responsiveness of interrupt handling, the GPTimer driver provides the :ref:`CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM` option. Once enabled, the interrupt handler is placed in internal RAM, reducing delays caused by potential cache misses when loading instructions from Flash.
350351

@@ -355,12 +356,12 @@ To improve the real-time responsiveness of interrupt handling, the GPTimer drive
355356
As mentioned above, the GPTimer driver allows some functions to be called in an interrupt context. By enabling the :ref:`CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM` option, these functions can also be placed in IRAM, which helps avoid performance loss caused by cache misses and allows them to be used when the Cache is disabled.
356357

357358
Other Kconfig Options
358-
^^^^^^^^^^^^^^^^^^^^^
359+
---------------------
359360

360361
- The :ref:`CONFIG_GPTIMER_ENABLE_DEBUG_LOG` option forces the GPTimer driver to enable all debug logs, regardless of the global log level settings. Enabling this option helps developers obtain more detailed log information during debugging, making it easier to locate and solve problems.
361362

362363
Resource Consumption
363-
^^^^^^^^^^^^^^^^^^^^
364+
--------------------
364365

365366
Use the :doc:`/api-guides/tools/idf-size` tool to check the code and data consumption of the GPTimer driver. The following are the test conditions (using ESP32-C2 as an example):
366367

@@ -386,7 +387,7 @@ Use the :doc:`/api-guides/tools/idf-size` tool to check the code and data consum
386387
Additionally, each GPTimer handle dynamically allocates about ``100`` bytes of memory from the heap. If the :cpp:member:`gptimer_config_t::flags::allow_pd` option is enabled, each timer will also consume approximately ``30`` extra bytes of memory during sleep to store the register context.
387388

388389
Application Examples
389-
--------------------
390+
====================
390391

391392
.. list::
392393

@@ -395,12 +396,26 @@ Application Examples
395396
:SOC_TIMER_SUPPORT_ETM: - :example:`peripherals/timer_group/gptimer_capture_hc_sr04` demonstrates how to use the general-purpose timer and Event Task Matrix (ETM) to accurately capture timestamps of ultrasonic sensor events and convert them into distance information.
396397

397398
API Reference
398-
-------------
399+
=============
400+
401+
GPTimer Driver APIs
402+
-------------------
399403

400404
.. include-build-file:: inc/gptimer.inc
405+
406+
GPTimer Driver Types
407+
--------------------
408+
401409
.. include-build-file:: inc/gptimer_types.inc
410+
411+
GPTimer HAL Types
412+
-----------------
413+
402414
.. include-build-file:: inc/timer_types.inc
403415

416+
GPTimer ETM APIs
417+
----------------
418+
404419
.. only:: SOC_TIMER_SUPPORT_ETM
405420

406421
.. include-build-file:: inc/gptimer_etm.inc

0 commit comments

Comments
 (0)