1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

xtimer: add xtimer_set_timeout_flag64()

This commit is contained in:
Hauke Petersen 2020-02-13 15:37:14 +01:00
parent 55cc34fd17
commit 58e381979f
2 changed files with 24 additions and 1 deletions

View File

@ -398,6 +398,7 @@ static inline bool xtimer_less64(xtimer_ticks64_t a, xtimer_ticks64_t b);
*/
int xtimer_mutex_lock_timeout(mutex_t *mutex, uint64_t us);
#if defined(MODULE_CORE_THREAD_FLAGS) || defined(DOXYGEN)
/**
* @brief Set timeout thread flag after @p timeout
*
@ -409,6 +410,17 @@ int xtimer_mutex_lock_timeout(mutex_t *mutex, uint64_t us);
*/
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout);
/**
* @brief Set timeout thread flag after @p timeout
*
* See xtimer_set_timeout_flag() for more information.
*
* @param[in] t timer struct to use
* @param[in] timeout timeout in usec
*/
void xtimer_set_timeout_flag64(xtimer_t *t, uint64_t timeout);
#endif
#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
/**
* @brief Set a timer that sends a message

View File

@ -255,11 +255,22 @@ static void _set_timeout_flag_callback(void* arg)
thread_flags_set(arg, THREAD_FLAG_TIMEOUT);
}
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout)
static void _set_timeout_flag_prepare(xtimer_t *t)
{
t->callback = _set_timeout_flag_callback;
t->arg = (thread_t *)sched_active_thread;
thread_flags_clear(THREAD_FLAG_TIMEOUT);
}
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout)
{
_set_timeout_flag_prepare(t);
xtimer_set(t, timeout);
}
void xtimer_set_timeout_flag64(xtimer_t *t, uint64_t timeout)
{
_set_timeout_flag_prepare(t);
xtimer_set64(t, timeout);
}
#endif