2010-12-01 17:13:37 +01:00
|
|
|
#ifndef __TIMEX_H
|
2013-06-22 05:11:53 +02:00
|
|
|
#define __TIMEX_H
|
2010-12-01 17:13:37 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2013-10-01 15:31:03 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
// mspgcc bug : PRIxxx macros not defined before mid-2011 versions
|
|
|
|
#ifndef PRIu32
|
|
|
|
#define PRIu32 "lu"
|
|
|
|
#endif
|
2010-12-01 17:13:37 +01:00
|
|
|
|
|
|
|
typedef struct timex_t {
|
|
|
|
uint32_t seconds;
|
2011-12-01 13:01:36 +01:00
|
|
|
uint32_t microseconds;
|
2010-12-01 17:13:37 +01:00
|
|
|
} timex_t;
|
|
|
|
|
2010-12-01 17:23:28 +01:00
|
|
|
/* a+b */
|
2013-06-22 05:11:53 +02:00
|
|
|
timex_t timex_add(const timex_t a, const timex_t b);
|
2010-12-01 17:13:37 +01:00
|
|
|
|
2010-12-01 17:23:28 +01:00
|
|
|
/* a-b*/
|
|
|
|
timex_t timex_sub(const timex_t a, const timex_t b);
|
|
|
|
|
2011-12-01 13:01:36 +01:00
|
|
|
timex_t timex_set(uint32_t seconds, uint32_t microseconds);
|
2010-12-01 17:23:28 +01:00
|
|
|
|
2010-12-06 16:02:40 +01:00
|
|
|
/**
|
|
|
|
* @brief Compares two timex values.
|
|
|
|
*
|
|
|
|
* @return -1 when a is smaller, 0 if equal, 1 if a is bigger
|
|
|
|
*/
|
2012-01-11 17:02:43 +01:00
|
|
|
int timex_cmp(const timex_t a, const timex_t b);
|
2010-12-06 16:02:40 +01:00
|
|
|
|
|
|
|
/**
|
2011-12-01 13:01:36 +01:00
|
|
|
* @brief Corrects timex_t structure so that microseconds < 1000000
|
2010-12-06 16:02:40 +01:00
|
|
|
*/
|
|
|
|
void timex_normalize(timex_t *time);
|
|
|
|
|
2013-06-14 20:38:27 +02:00
|
|
|
/**
|
|
|
|
* @brief Prints a timex_t
|
|
|
|
*/
|
|
|
|
void timex_print(const timex_t t);
|
|
|
|
|
2010-12-01 17:13:37 +01:00
|
|
|
#endif /* __TIMEX_H */
|