cc26xx: add TSCH-related rtimer defines

This commit is contained in:
Atis Elsts 2016-04-25 17:57:46 +03:00
parent ac6f8008fd
commit 95b66657aa

View File

@ -50,6 +50,21 @@
#define RTIMER_ARCH_SECOND 65536
/*---------------------------------------------------------------------------*/
rtimer_clock_t rtimer_arch_now(void);
/* HW oscillator frequency is 32 kHz, not 64 kHz and RTIMER_NOW() never returns
* an odd value; so US_TO_RTIMERTICKS always rounds to the nearest even number.
*/
#define US_TO_RTIMERTICKS(US) (2 * ((US) >= 0 ? \
(((int32_t)(US) * (RTIMER_ARCH_SECOND / 2) + 500000) / 1000000L) : \
((int32_t)(US) * (RTIMER_ARCH_SECOND / 2) - 500000) / 1000000L))
#define RTIMERTICKS_TO_US(T) ((T) >= 0 ? \
(((int32_t)(T) * 1000000L + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) : \
((int32_t)(T) * 1000000L - ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND))
/* A 64-bit version because the 32-bit one cannot handle T >= 4295 ticks.
Intended only for positive values of T. */
#define RTIMERTICKS_TO_US_64(T) ((uint32_t)(((uint64_t)(T) * 1000000 + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)))
/*---------------------------------------------------------------------------*/
#endif /* RTIMER_ARCH_H_ */
/*---------------------------------------------------------------------------*/