wangchdo commented on code in PR #17489:
URL: https://github.com/apache/nuttx/pull/17489#discussion_r2617717712
##########
Documentation/reference/os/time_clock.rst:
##########
@@ -657,3 +657,65 @@ with NuttX tasks.
#else
typedef uint32_t wdparm_t;
#endif
+
+High-resolution Timer Interfaces
+================================
+
+NuttX provides a high-resolution timer facility. This facility
+allows the NuttX user to specify a hrtimer function that
+will run after a specified delay in nanosec resolution. The hrtimer
+function will run in the context of the timer interrupt handler.
+Because of this, a limited number of NuttX interfaces are available to he
+hrtimer function. However, the hrtimer function may
+use ``mq_send()``, ``sigqueue()``, ``nxevent_post()``, or ``kill()``
+to communicate with NuttX tasks.
+
+- :c:func:`hrtimer_init`
+- :c:func:`hrtimer_cancel`
+- :c:func:`hrtimer_start`
+- High-resolution Timer Callback
+
+.. c:function:: void hrtimer_init(FAR hrtimer_t *hrtimer, hrtentry_t func, \
+ FAR void *arg)
+
+ This function initializes a high-resolution timer instance.
+ Sets the expiration callback and its argument. The timer is
+ not started by this function.
+
+ :param hrtimer: Pointer to hrtimer instance
+ :param func: Expiration callback function
+ :param arg: Callback argument
+
+ :return: None.
+
+ **POSIX Compatibility:** This is a NON-POSIX interface.
+
+.. c:function:: int hrtimer_cancel(FAR hrtimer_t *hrtimer)
+
+ This function cancels a high-resolution timer if it is pending.
+ The timer callback will not be called if the timer was successfully
+ canceled.
+
+ :param hrtimer: Timer instance to cancel
+
+ :return: ``OK`` on success; negated errno on failure.
+
+ **POSIX Compatibility:** This is a NON-POSIX interface.
+
+.. c:function:: int hrtimer_start(FAR hrtimer_t *hrtimer, uint64_t ns, \
Review Comment:
@xiaoxiang781216 @linguini1
I have added the test code and test logs. Please check them in the PR
description.
Formal test cases will be added to the apps repository after this PR is
merged.
As shown in the test code, `hrtimer_init`, `hrtimer_start`, and
`hrtimer_cancel `are all covered. The test logs also demonstrate that the
behavior matches the expected results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]