2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:43:02 +02:00
|
|
|
* sched/clock/clock.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* 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
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* 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.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 22:43:02 +02:00
|
|
|
#ifndef __SCHED_CLOCK_CLOCK_H
|
|
|
|
#define __SCHED_CLOCK_CLOCK_H
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-06-09 17:49:44 +02:00
|
|
|
#include <nuttx/config.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2011-10-02 16:16:30 +02:00
|
|
|
|
2007-09-09 13:58:50 +02:00
|
|
|
#include <nuttx/clock.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <nuttx/compiler.h>
|
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2011-10-02 16:16:30 +02:00
|
|
|
* Pre-processor Definitions
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2021-02-08 18:46:31 +01:00
|
|
|
|
2011-10-02 16:16:30 +02:00
|
|
|
/* Configuration ************************************************************/
|
2021-02-08 18:46:31 +01:00
|
|
|
|
2011-10-02 16:16:30 +02:00
|
|
|
/* If CONFIG_SYSTEM_TIME64 is selected and the CPU supports long long types,
|
|
|
|
* then a 64-bit system time will be used.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONFIG_HAVE_LONG_LONG
|
|
|
|
# undef CONFIG_SYSTEM_TIME64
|
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Type Definitions
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2014-10-03 18:20:46 +02:00
|
|
|
|
2014-08-30 22:44:48 +02:00
|
|
|
#if !defined(CONFIG_SCHED_TICKLESS) && !defined(__HAVE_KERNEL_GLOBALS)
|
2014-08-29 01:00:03 +02:00
|
|
|
/* The system clock exists (CONFIG_SCHED_TICKLESS), but it not prototyped
|
|
|
|
* globally in include/nuttx/clock.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
# ifdef CONFIG_SYSTEM_TIME64
|
|
|
|
extern volatile uint64_t g_system_timer;
|
|
|
|
# else
|
|
|
|
extern volatile uint32_t g_system_timer;
|
|
|
|
# endif
|
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-07-11 14:54:02 +02:00
|
|
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
2014-08-29 01:00:03 +02:00
|
|
|
extern struct timespec g_basetime;
|
2016-07-11 00:14:25 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Function Prototypes
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-11-12 14:00:41 +01:00
|
|
|
int clock_basetime(FAR struct timespec *tp);
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
void weak_function clock_initialize(void);
|
2014-08-07 02:29:05 +02:00
|
|
|
#ifndef CONFIG_SCHED_TICKLESS
|
2012-07-14 21:30:31 +02:00
|
|
|
void weak_function clock_timer(void);
|
2014-08-07 02:29:05 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2015-07-26 23:03:47 +02:00
|
|
|
int clock_abstime2ticks(clockid_t clockid,
|
|
|
|
FAR const struct timespec *abstime,
|
2018-06-16 20:16:13 +02:00
|
|
|
FAR sclock_t *ticks);
|
2017-04-21 16:51:31 +02:00
|
|
|
int clock_time2ticks(FAR const struct timespec *reltime,
|
2018-06-16 20:16:13 +02:00
|
|
|
FAR sclock_t *ticks);
|
|
|
|
int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 22:43:02 +02:00
|
|
|
#endif /* __SCHED_CLOCK_CLOCK_H */
|