wangchdo commented on code in PR #17065:
URL: https://github.com/apache/nuttx/pull/17065#discussion_r2374584318


##########
include/nuttx/hrtimer.h:
##########
@@ -0,0 +1,475 @@
+/****************************************************************************
+ * include/nuttx/hrtimer.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_TIMERS_HRTIMER_H
+#define __INCLUDE_NUTTX_TIMERS_HRTIMER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/clock.h>
+#include <nuttx/spinlock.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Select tick type (32-bit or 64-bit) based on configuration */
+
+typedef clock_t hrtimer_time_t;
+
+#ifdef CONFIG_SYSTEM_TIME64
+# define HRTIMER_MAX_VALUE UINT64_MAX
+#else
+# define HRTIMER_MAX_VALUE UINT32_MAX
+#endif
+
+/* The maximum increment that can be safely distinguished without overflow */
+
+#define HRTIMER_MAX_INCREMENT     (HRTIMER_MAX_VALUE >> 1)
+
+/* Default expiration increment if no timer is active */
+
+#define HRTIMER_DEFAULT_INCREMENT ((hrtimer_time_t)UINT32_MAX >> 2)
+
+/* Convert microseconds/nanoseconds to hardware timer ticks */
+
+#define HRTIMER_QUEUE_USEC2TICKS(queue, us) \
+  (((hrtimer_time_t)(us)) * ((queue)->driver->freq) / USEC_PER_SEC)
+
+#define HRTIMER_QUEUE_NSEC2TICKS(queue, ns) \
+  (((hrtimer_time_t)(ns)) * ((queue)->driver->freq) / NSEC_PER_SEC)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* Timer mode: absolute or relative */
+
+enum hrtimer_mode
+{
+  HRTIMER_MODE_ABS = 0x0, /* Absolute expiration time */
+  HRTIMER_MODE_REL = 0x1  /* Relative delay from now  */
+};
+
+/* Forward declarations */
+
+struct hrtimer_s;
+struct hrtimer_queue_s;
+
+/* Callback type for high-resolution timer expiration */
+
+typedef void (*hrtimer_callback_t)(FAR struct hrtimer_s *);
+
+/* Hardware-specific timer operations.  These must be provided by the
+ * underlying architecture/platform driver.  They define how to set the
+ * expiration, read current time, start and trigger the hardware timer.
+ */
+
+struct hrtimer_driver_ops_s

Review Comment:
   I will use oneshot, please wait a second



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to