1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys: factor out US_PER_SEC etc from timex.h into time_units.h

This commit is contained in:
Kaspar Schleiser 2021-12-15 14:33:20 +01:00
parent e3f6212708
commit fd1f257ee8
2 changed files with 78 additions and 45 deletions

77
sys/include/time_units.h Normal file
View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2021 Kaspar Schleiser <kaspar@schleiser.de>
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup sys_time_units Time unit representations
* @brief Timestamp representation, computation, and conversion
* @ingroup sys
*
* @{
* @file
* @brief Utility header providing time unit defines
*/
#ifndef TIME_UNITS_H
#define TIME_UNITS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The number of microseconds per second
*/
#define US_PER_SEC (1000000LU)
/**
* @brief The number of seconds per minute
*/
#define SEC_PER_MIN (60LU)
/**
* @brief The number of centiseconds per second
*/
#define CS_PER_SEC (100LU)
/**
* @brief The number of milliseconds per second
*/
#define MS_PER_SEC (1000LU)
/**
* @brief The number of microseconds per millisecond
*/
#define US_PER_MS (1000LU)
/**
* @brief The number of microseconds per centisecond
*/
#define US_PER_CS (10000U)
/**
* @brief The number of milliseconds per centisecond
*/
#define MS_PER_CS (10U)
/**
* @brief The number of nanoseconds per microsecond
*/
#define NS_PER_US (1000LU)
/**
* @brief The number of nanoseconds per second
*/
#define NS_PER_SEC (1000000000LLU)
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* TIME_UNITS_H */

View File

@ -22,56 +22,12 @@
#include <stdint.h>
#include <inttypes.h>
#include "time_units.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The number of microseconds per second
*/
#define US_PER_SEC (1000000LU)
/**
* @brief The number of seconds per minute
*/
#define SEC_PER_MIN (60LU)
/**
* @brief The number of centiseconds per second
*/
#define CS_PER_SEC (100LU)
/**
* @brief The number of milliseconds per second
*/
#define MS_PER_SEC (1000LU)
/**
* @brief The number of microseconds per millisecond
*/
#define US_PER_MS (1000LU)
/**
* @brief The number of microseconds per centisecond
*/
#define US_PER_CS (10000U)
/**
* @brief The number of milliseconds per centisecond
*/
#define MS_PER_CS (10U)
/**
* @brief The number of nanoseconds per microsecond
*/
#define NS_PER_US (1000LU)
/**
* @brief The number of nanoseconds per second
*/
#define NS_PER_SEC (1000000000LLU)
/**
* @brief The maximum length of the string representation of a timex timestamp
*/