45 #define TIME_IMMEDIATE ((sysinterval_t)0) 53 #define TIME_INFINITE ((sysinterval_t)-1) 58 #define TIME_MAX_INTERVAL ((sysinterval_t)-2) 63 #define TIME_MAX_SYSTIME ((systime_t)-1) 74 #if !defined(CH_CFG_ST_RESOLUTION) || defined(__DOXYGEN__) 75 #define CH_CFG_ST_RESOLUTION 32 83 #if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXYGEN__) 84 #define CH_CFG_ST_FREQUENCY 1000 91 #if !defined(CH_CFG_INTERVALS_SIZE) || defined(__DOXYGEN__) 92 #define CH_CFG_INTERVALS_SIZE 32 99 #if !defined(CH_CFG_TIME_TYPES_SIZE) || defined(__DOXYGEN__) 100 #define CH_CFG_TIME_TYPES_SIZE 32 107 #if (CH_CFG_ST_RESOLUTION != 16) && (CH_CFG_ST_RESOLUTION != 32) && \ 108 (CH_CFG_ST_RESOLUTION != 64) 109 #error "invalid CH_CFG_ST_RESOLUTION specified, must be 16, 32 or 64" 112 #if CH_CFG_ST_FREQUENCY < 10 113 #error "invalid CH_CFG_ST_FREQUENCY specified, must be >= 10" 116 #if (CH_CFG_INTERVALS_SIZE != 16) && (CH_CFG_INTERVALS_SIZE != 32) && \ 117 (CH_CFG_INTERVALS_SIZE != 64) 118 #error "invalid CH_CFG_INTERVALS_SIZE specified, must be 16, 32 or 64" 121 #if (CH_CFG_TIME_TYPES_SIZE != 16) && (CH_CFG_TIME_TYPES_SIZE != 32) 122 #error "invalid CH_CFG_TIME_TYPES_SIZE specified, must be 16 or 32" 125 #if CH_CFG_INTERVALS_SIZE < CH_CFG_ST_RESOLUTION 126 #error "CH_CFG_INTERVALS_SIZE must be >= CH_CFG_ST_RESOLUTION" 137 #if (CH_CFG_ST_RESOLUTION == 64) || defined(__DOXYGEN__) 139 #elif CH_CFG_ST_RESOLUTION == 32 141 #elif CH_CFG_ST_RESOLUTION == 16 149 #if (CH_CFG_INTERVALS_SIZE == 64) || defined(__DOXYGEN__) 151 #elif CH_CFG_INTERVALS_SIZE == 32 153 #elif CH_CFG_INTERVALS_SIZE == 16 157 #if (CH_CFG_TIME_TYPES_SIZE == 32) || defined(__DOXYGEN__) 212 #define TIME_S2I(secs) \ 213 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY)) 228 #define TIME_MS2I(msecs) \ 229 ((sysinterval_t)((((time_conv_t)(msecs) * \ 230 (time_conv_t)CH_CFG_ST_FREQUENCY) + \ 231 (time_conv_t)999) / (time_conv_t)1000)) 246 #define TIME_US2I(usecs) \ 247 ((sysinterval_t)((((time_conv_t)(usecs) * \ 248 (time_conv_t)CH_CFG_ST_FREQUENCY) + \ 249 (time_conv_t)999999) / (time_conv_t)1000000)) 264 #define TIME_I2S(interval) \ 265 (time_secs_t)(((time_conv_t)(interval) + \ 266 (time_conv_t)CH_CFG_ST_FREQUENCY - \ 267 (time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY) 282 #define TIME_I2MS(interval) \ 283 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \ 284 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \ 285 (time_conv_t)CH_CFG_ST_FREQUENCY) 300 #define TIME_I2US(interval) \ 301 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \ 302 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \ 303 (time_conv_t)CH_CFG_ST_FREQUENCY) 345 "conversion overflow");
367 "conversion overflow");
389 "conversion overflow");
412 "conversion overflow");
435 "conversion overflow");
458 "conversion overflow");
475 #if CH_CFG_ST_RESOLUTION != CH_CFG_INTERVALS_SIZE 516 return (
bool)((time - start) < (end - start));
uint64_t systime_t
Type of system time.
uint32_t time_secs_t
Type of seconds.
uint64_t sysinterval_t
Type of time interval.
static sysinterval_t chTimeS2I(time_secs_t secs)
Seconds to time interval.
static sysinterval_t chTimeDiffX(systime_t start, systime_t end)
Subtracts two system times returning an interval.
static bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
static sysinterval_t chTimeUS2I(time_usecs_t usec)
Microseconds to time interval.
uint64_t time_conv_t
Type of time conversion variable.
static time_usecs_t chTimeI2US(sysinterval_t interval)
Time interval to microseconds.
static time_msecs_t chTimeI2MS(sysinterval_t interval)
Time interval to milliseconds.
#define chDbgCheck(c)
Function parameters check.
uint32_t time_usecs_t
Type of microseconds.
uint32_t time_msecs_t
Type of milliseconds.
#define chDbgAssert(c, r)
Condition assertion.
static sysinterval_t chTimeMS2I(time_msecs_t msec)
Milliseconds to time interval.
static time_secs_t chTimeI2S(sysinterval_t interval)
Time interval to seconds.
static systime_t chTimeAddX(systime_t systime, sysinterval_t interval)
Adds an interval to a system time returning a system time.
#define CH_CFG_ST_FREQUENCY
System tick frequency.
#define TIME_MAX_INTERVAL
Maximum interval constant usable as timeout.