-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime_units.h
47 lines (37 loc) · 1022 Bytes
/
time_units.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @file time_units.h
* @author TheSomeMan
* @date 2020-10-23
* @copyright Ruuvi Innovations Ltd, license BSD-3-Clause.
*/
#ifndef RUUVI_TIME_UNITS_H
#define RUUVI_TIME_UNITS_H
#include <stdint.h>
#include "attribs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TIME_UNITS_MS_PER_SECOND (1000U)
#define TIME_UNITS_US_PER_MS (1000U)
#define TIME_UNITS_HOURS_PER_DAY (24U)
#define TIME_UNITS_MINUTES_PER_HOUR (60U)
#define TIME_UNITS_SECONDS_PER_MINUTE (60U)
typedef uint32_t TimeUnitsSeconds_t;
typedef uint32_t TimeUnitsMilliSeconds_t;
typedef uint64_t TimeUnitsMicroSeconds_t;
ATTR_CONST
static inline TimeUnitsMilliSeconds_t
time_units_conv_seconds_to_ms(const TimeUnitsSeconds_t num_seconds)
{
return num_seconds * TIME_UNITS_MS_PER_SECOND;
}
ATTR_CONST
static inline TimeUnitsMicroSeconds_t
time_units_conv_ms_to_us(const TimeUnitsMilliSeconds_t num_ms)
{
return (TimeUnitsMicroSeconds_t)num_ms * TIME_UNITS_US_PER_MS;
}
#ifdef __cplusplus
}
#endif
#endif // RUUVI_TIME_UNITS_H