2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2021-11-04 12:18:38 +01:00
|
|
|
* libs/libc/sched/clock_ticks2time.c
|
2007-03-21 18:21:26 +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-03-21 18:21:26 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-21 18:21:26 +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-03-21 18:21:26 +01:00
|
|
|
*
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Included Files
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-14 19:39:29 +01:00
|
|
|
|
2007-03-21 18:21:26 +01:00
|
|
|
#include <time.h>
|
2021-11-04 12:18:38 +01:00
|
|
|
#include <nuttx/clock.h>
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Public Functions
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2012-07-14 21:30:31 +02:00
|
|
|
* Name: clock_ticks2time
|
2007-03-21 18:21:26 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Convert the system time tick value to a relative time.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2007-03-21 18:21:26 +01:00
|
|
|
* ticks - The number of system time ticks to convert.
|
|
|
|
* reltime - Return the converted system time here.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2007-03-21 18:21:26 +01:00
|
|
|
* Always returns OK
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2018-06-16 20:16:13 +02:00
|
|
|
int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime)
|
2007-03-21 18:21:26 +01:00
|
|
|
{
|
2018-06-16 20:16:13 +02:00
|
|
|
sclock_t remainder;
|
2007-03-21 18:21:26 +01:00
|
|
|
|
|
|
|
reltime->tv_sec = ticks / TICK_PER_SEC;
|
|
|
|
remainder = ticks - TICK_PER_SEC * reltime->tv_sec;
|
|
|
|
reltime->tv_nsec = remainder * NSEC_PER_TICK;
|
|
|
|
return OK;
|
|
|
|
}
|