From bb7acca31eeb63ee47d13366dc178223141e4a5c Mon Sep 17 00:00:00 2001
From: Josarn <josuaarndt@live.de>
Date: Tue, 3 Apr 2018 23:18:11 +0200
Subject: [PATCH] sys/include/xtimer: Added xtimer_set64()

---
 sys/include/xtimer.h                | 21 +++++++++++++++++++++
 sys/include/xtimer/implementation.h | 12 +++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/sys/include/xtimer.h b/sys/include/xtimer.h
index 616e4a60e6..e1f19347a0 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 3f070c001d..ed16aa91ad 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));
-- 
GitLab