diff --git a/sys/include/xtimer.h b/sys/include/xtimer.h index 7f4f3cc17ee8855a44bb1a4efc4bdca434822f70..cb2e63036772b9f9d0a33ad3c35dd37aac349518 100644 --- a/sys/include/xtimer.h +++ b/sys/include/xtimer.h @@ -291,6 +291,27 @@ static inline void xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_ */ static inline void xtimer_set(xtimer_t *timer, uint32_t offset); +/** + * @brief Set a timer to execute a callback at some time in the future, 64bit + * version + * + * Expects timer->callback to be set. + * + * The callback specified in the timer struct will be executed @p offset_usec + * microseconds in the future. + * + * @warning BEWARE! Callbacks from xtimer_set() are being executed in interrupt + * context (unless offset < XTIMER_BACKOFF). DON'T USE THIS FUNCTION unless you + * know *exactly* what that means. + * + * @param[in] timer the timer structure to use. + * Its xtimer_t::target and xtimer_t::long_target + * fields need to be initialized with 0 on first use + * @param[in] offset_us time in microseconds from now specifying that timer's + * callback's execution time + */ +static inline void xtimer_set64(xtimer_t *timer, uint64_t offset_us); + /** * @brief remove a timer * diff --git a/sys/include/xtimer/implementation.h b/sys/include/xtimer/implementation.h index 3f070c001dd7e90c7e104e1780a88dfba2afa687..ed16aa91ad714fe50882733bcf8493d999a60fc7 100644 --- a/sys/include/xtimer/implementation.h +++ b/sys/include/xtimer/implementation.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de> - * Copyright (C) 2016 Eistec AB + * 2016 Eistec AB + * 2018 Josua Arndt * * 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 @@ -13,8 +14,11 @@ * @{ * @file * @brief xtimer implementation + * * @author Kaspar Schleiser <kaspar@schleiser.de> * @author Joakim NohlgÄrd <joakim.nohlgard@eistec.se> + * @author Josua Arndt <jarndt@ias.rwth-aachen.de> + * */ #ifndef XTIMER_IMPLEMENTATION_H #define XTIMER_IMPLEMENTATION_H @@ -217,6 +221,12 @@ static inline void xtimer_set(xtimer_t *timer, uint32_t offset) _xtimer_set(timer, _xtimer_ticks_from_usec(offset)); } +static inline void xtimer_set64(xtimer_t *timer, uint64_t period_us) +{ + uint64_t ticks = _xtimer_ticks_from_usec64(period_us); + _xtimer_set64(timer, ticks, ticks >> 32); +} + static inline int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout) { return _xtimer_msg_receive_timeout(msg, _xtimer_ticks_from_usec(timeout));