2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2014-08-08 14:43:02 -06:00
|
|
|
* sched/clock/clock.h
|
2007-02-17 23:21:28 +00: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-17 23:21:28 +00:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-17 23:21:28 +00: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-17 23:21:28 +00:00
|
|
|
*
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-08-08 14:43:02 -06:00
|
|
|
#ifndef __SCHED_CLOCK_CLOCK_H
|
|
|
|
#define __SCHED_CLOCK_CLOCK_H
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2007-02-17 23:21:28 +00:00
|
|
|
* Included Files
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2007-06-09 15:49:44 +00:00
|
|
|
#include <nuttx/config.h>
|
2009-12-14 19:30:18 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2011-10-02 14:16:30 +00:00
|
|
|
|
2007-09-09 11:58:50 +00:00
|
|
|
#include <nuttx/clock.h>
|
2007-02-17 23:21:28 +00:00
|
|
|
#include <nuttx/compiler.h>
|
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2011-10-02 14:16:30 +00:00
|
|
|
* Pre-processor Definitions
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2021-02-08 18:46:31 +01:00
|
|
|
|
2011-10-02 14:16:30 +00:00
|
|
|
/* Configuration ************************************************************/
|
2021-02-08 18:46:31 +01:00
|
|
|
|
2011-10-02 14:16:30 +00: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-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2007-02-17 23:21:28 +00:00
|
|
|
* Public Type Definitions
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2015-10-02 16:30:35 -06:00
|
|
|
* Public Data
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2014-10-03 10:20:46 -06:00
|
|
|
|
2014-08-30 14:44:48 -06:00
|
|
|
#if !defined(CONFIG_SCHED_TICKLESS) && !defined(__HAVE_KERNEL_GLOBALS)
|
2014-08-28 17:00:03 -06: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-17 23:21:28 +00:00
|
|
|
|
2016-07-11 06:54:02 -06:00
|
|
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
2014-08-28 17:00:03 -06:00
|
|
|
extern struct timespec g_basetime;
|
2016-07-10 16:14:25 -06:00
|
|
|
#endif
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2007-02-17 23:21:28 +00:00
|
|
|
* Public Function Prototypes
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2018-11-12 07:00:41 -06:00
|
|
|
int clock_basetime(FAR struct timespec *tp);
|
|
|
|
|
2012-07-14 19:30:31 +00:00
|
|
|
void weak_function clock_initialize(void);
|
2014-08-06 18:29:05 -06:00
|
|
|
#ifndef CONFIG_SCHED_TICKLESS
|
2012-07-14 19:30:31 +00:00
|
|
|
void weak_function clock_timer(void);
|
2014-08-06 18:29:05 -06:00
|
|
|
#endif
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2015-07-26 15:03:47 -06:00
|
|
|
int clock_abstime2ticks(clockid_t clockid,
|
|
|
|
FAR const struct timespec *abstime,
|
2018-06-16 12:16:13 -06:00
|
|
|
FAR sclock_t *ticks);
|
2017-04-21 08:51:31 -06:00
|
|
|
int clock_time2ticks(FAR const struct timespec *reltime,
|
2018-06-16 12:16:13 -06:00
|
|
|
FAR sclock_t *ticks);
|
|
|
|
int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime);
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-08-08 14:43:02 -06:00
|
|
|
#endif /* __SCHED_CLOCK_CLOCK_H */
|