Merge pull request #11230 from maribu/xtimer_msg_deps
sys/xtimer: Remove dependency to core_msg
This commit is contained in:
commit
865059fc66
@ -29,10 +29,14 @@
|
|||||||
#ifndef XTIMER_H
|
#ifndef XTIMER_H
|
||||||
#define XTIMER_H
|
#define XTIMER_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "timex.h"
|
#include "timex.h"
|
||||||
|
#ifdef MODULE_CORE_MSG
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
|
#endif /* MODULE_CORE_MSG */
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
|
#include "kernel_types.h"
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "periph_conf.h"
|
#include "periph_conf.h"
|
||||||
@ -207,42 +211,6 @@ static inline void xtimer_spin(xtimer_ticks32_t ticks);
|
|||||||
*/
|
*/
|
||||||
static inline void xtimer_periodic_wakeup(xtimer_ticks32_t *last_wakeup, uint32_t period);
|
static inline void xtimer_periodic_wakeup(xtimer_ticks32_t *last_wakeup, uint32_t period);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a timer that sends a message
|
|
||||||
*
|
|
||||||
* This function sets a timer that will send a message @p offset ticks
|
|
||||||
* from now.
|
|
||||||
*
|
|
||||||
* The message struct specified by msg parameter will not be copied, e.g., it
|
|
||||||
* needs to point to valid memory until the message has been delivered.
|
|
||||||
*
|
|
||||||
* @param[in] timer timer struct to work with.
|
|
||||||
* Its xtimer_t::target and xtimer_t::long_target
|
|
||||||
* fields need to be initialized with 0 on first use.
|
|
||||||
* @param[in] offset microseconds from now
|
|
||||||
* @param[in] msg ptr to msg that will be sent
|
|
||||||
* @param[in] target_pid pid the message will be sent to
|
|
||||||
*/
|
|
||||||
static inline void xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a timer that sends a message, 64bit version
|
|
||||||
*
|
|
||||||
* This function sets a timer that will send a message @p offset microseconds
|
|
||||||
* from now.
|
|
||||||
*
|
|
||||||
* The message struct specified by msg parameter will not be copied, e.g., it
|
|
||||||
* needs to point to valid memory until the message has been delivered.
|
|
||||||
*
|
|
||||||
* @param[in] timer timer struct to work with.
|
|
||||||
* Its xtimer_t::target and xtimer_t::long_target
|
|
||||||
* fields need to be initialized with 0 on first use.
|
|
||||||
* @param[in] offset microseconds from now
|
|
||||||
* @param[in] msg ptr to msg that will be sent
|
|
||||||
* @param[in] target_pid pid the message will be sent to
|
|
||||||
*/
|
|
||||||
static inline void xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set a timer that wakes up a thread
|
* @brief Set a timer that wakes up a thread
|
||||||
*
|
*
|
||||||
@ -321,28 +289,6 @@ static inline void xtimer_set64(xtimer_t *timer, uint64_t offset_us);
|
|||||||
*/
|
*/
|
||||||
void xtimer_remove(xtimer_t *timer);
|
void xtimer_remove(xtimer_t *timer);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief receive a message blocking but with timeout
|
|
||||||
*
|
|
||||||
* @param[out] msg pointer to a msg_t which will be filled in case of
|
|
||||||
* no timeout
|
|
||||||
* @param[in] timeout timeout in microseconds relative
|
|
||||||
*
|
|
||||||
* @return < 0 on error, other value otherwise
|
|
||||||
*/
|
|
||||||
static inline int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief receive a message blocking but with timeout, 64bit version
|
|
||||||
*
|
|
||||||
* @param[out] msg pointer to a msg_t which will be filled in case of no
|
|
||||||
* timeout
|
|
||||||
* @param[in] timeout timeout in microseconds relative
|
|
||||||
*
|
|
||||||
* @return < 0 on error, other value otherwise
|
|
||||||
*/
|
|
||||||
static inline int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t timeout);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert microseconds to xtimer ticks
|
* @brief Convert microseconds to xtimer ticks
|
||||||
*
|
*
|
||||||
@ -469,6 +415,66 @@ int xtimer_mutex_lock_timeout(mutex_t *mutex, uint64_t us);
|
|||||||
*/
|
*/
|
||||||
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout);
|
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout);
|
||||||
|
|
||||||
|
#ifdef MODULE_CORE_MSG
|
||||||
|
/**
|
||||||
|
* @brief Set a timer that sends a message
|
||||||
|
*
|
||||||
|
* This function sets a timer that will send a message @p offset ticks
|
||||||
|
* from now.
|
||||||
|
*
|
||||||
|
* The message struct specified by msg parameter will not be copied, e.g., it
|
||||||
|
* needs to point to valid memory until the message has been delivered.
|
||||||
|
*
|
||||||
|
* @param[in] timer timer struct to work with.
|
||||||
|
* Its xtimer_t::target and xtimer_t::long_target
|
||||||
|
* fields need to be initialized with 0 on first use.
|
||||||
|
* @param[in] offset microseconds from now
|
||||||
|
* @param[in] msg ptr to msg that will be sent
|
||||||
|
* @param[in] target_pid pid the message will be sent to
|
||||||
|
*/
|
||||||
|
static inline void xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set a timer that sends a message, 64bit version
|
||||||
|
*
|
||||||
|
* This function sets a timer that will send a message @p offset microseconds
|
||||||
|
* from now.
|
||||||
|
*
|
||||||
|
* The message struct specified by msg parameter will not be copied, e.g., it
|
||||||
|
* needs to point to valid memory until the message has been delivered.
|
||||||
|
*
|
||||||
|
* @param[in] timer timer struct to work with.
|
||||||
|
* Its xtimer_t::target and xtimer_t::long_target
|
||||||
|
* fields need to be initialized with 0 on first use.
|
||||||
|
* @param[in] offset microseconds from now
|
||||||
|
* @param[in] msg ptr to msg that will be sent
|
||||||
|
* @param[in] target_pid pid the message will be sent to
|
||||||
|
*/
|
||||||
|
static inline void xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief receive a message blocking but with timeout
|
||||||
|
*
|
||||||
|
* @param[out] msg pointer to a msg_t which will be filled in case of
|
||||||
|
* no timeout
|
||||||
|
* @param[in] timeout timeout in microseconds relative
|
||||||
|
*
|
||||||
|
* @return < 0 on error, other value otherwise
|
||||||
|
*/
|
||||||
|
static inline int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief receive a message blocking but with timeout, 64bit version
|
||||||
|
*
|
||||||
|
* @param[out] msg pointer to a msg_t which will be filled in case of no
|
||||||
|
* timeout
|
||||||
|
* @param[in] timeout timeout in microseconds relative
|
||||||
|
*
|
||||||
|
* @return < 0 on error, other value otherwise
|
||||||
|
*/
|
||||||
|
static inline int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t timeout);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief xtimer backoff value
|
* @brief xtimer backoff value
|
||||||
*
|
*
|
||||||
|
|||||||
@ -84,12 +84,14 @@ int _xtimer_set_absolute(xtimer_t *timer, uint32_t target);
|
|||||||
void _xtimer_set(xtimer_t *timer, uint32_t offset);
|
void _xtimer_set(xtimer_t *timer, uint32_t offset);
|
||||||
void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset);
|
void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset);
|
||||||
void _xtimer_periodic_wakeup(uint32_t *last_wakeup, uint32_t period);
|
void _xtimer_periodic_wakeup(uint32_t *last_wakeup, uint32_t period);
|
||||||
void _xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid);
|
|
||||||
void _xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid);
|
|
||||||
void _xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid);
|
void _xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid);
|
||||||
void _xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid);
|
void _xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid);
|
||||||
|
#ifdef MODULE_CORE_MSG
|
||||||
int _xtimer_msg_receive_timeout(msg_t *msg, uint32_t ticks);
|
int _xtimer_msg_receive_timeout(msg_t *msg, uint32_t ticks);
|
||||||
int _xtimer_msg_receive_timeout64(msg_t *msg, uint64_t ticks);
|
int _xtimer_msg_receive_timeout64(msg_t *msg, uint64_t ticks);
|
||||||
|
void _xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid);
|
||||||
|
void _xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid);
|
||||||
|
#endif /* MODULE_CORE_MSG */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sleep for the given number of ticks
|
* @brief Sleep for the given number of ticks
|
||||||
@ -210,16 +212,6 @@ static inline void xtimer_periodic_wakeup(xtimer_ticks32_t *last_wakeup, uint32_
|
|||||||
_xtimer_periodic_wakeup(&last_wakeup->ticks32, _xtimer_ticks_from_usec(period));
|
_xtimer_periodic_wakeup(&last_wakeup->ticks32, _xtimer_ticks_from_usec(period));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid)
|
|
||||||
{
|
|
||||||
_xtimer_set_msg(timer, _xtimer_ticks_from_usec(offset), msg, target_pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid)
|
|
||||||
{
|
|
||||||
_xtimer_set_msg64(timer, _xtimer_ticks_from_usec64(offset), msg, target_pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
|
static inline void xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
|
||||||
{
|
{
|
||||||
_xtimer_set_wakeup(timer, _xtimer_ticks_from_usec(offset), pid);
|
_xtimer_set_wakeup(timer, _xtimer_ticks_from_usec(offset), pid);
|
||||||
@ -241,6 +233,7 @@ static inline void xtimer_set64(xtimer_t *timer, uint64_t period_us)
|
|||||||
_xtimer_set64(timer, ticks, ticks >> 32);
|
_xtimer_set64(timer, ticks, ticks >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MODULE_CORE_MSG
|
||||||
static inline int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout)
|
static inline int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout)
|
||||||
{
|
{
|
||||||
return _xtimer_msg_receive_timeout(msg, _xtimer_ticks_from_usec(timeout));
|
return _xtimer_msg_receive_timeout(msg, _xtimer_ticks_from_usec(timeout));
|
||||||
@ -251,6 +244,17 @@ static inline int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t timeout)
|
|||||||
return _xtimer_msg_receive_timeout64(msg, _xtimer_ticks_from_usec64(timeout));
|
return _xtimer_msg_receive_timeout64(msg, _xtimer_ticks_from_usec64(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid)
|
||||||
|
{
|
||||||
|
_xtimer_set_msg(timer, _xtimer_ticks_from_usec(offset), msg, target_pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid)
|
||||||
|
{
|
||||||
|
_xtimer_set_msg64(timer, _xtimer_ticks_from_usec64(offset), msg, target_pid);
|
||||||
|
}
|
||||||
|
#endif /* MODULE_CORE_MSG */
|
||||||
|
|
||||||
static inline xtimer_ticks32_t xtimer_ticks_from_usec(uint32_t usec)
|
static inline xtimer_ticks32_t xtimer_ticks_from_usec(uint32_t usec)
|
||||||
{
|
{
|
||||||
xtimer_ticks32_t ticks;
|
xtimer_ticks32_t ticks;
|
||||||
|
|||||||
@ -139,6 +139,7 @@ out:
|
|||||||
*last_wakeup = target;
|
*last_wakeup = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MODULE_CORE_MSG
|
||||||
static void _callback_msg(void* arg)
|
static void _callback_msg(void* arg)
|
||||||
{
|
{
|
||||||
msg_t *msg = (msg_t*)arg;
|
msg_t *msg = (msg_t*)arg;
|
||||||
@ -166,35 +167,6 @@ void _xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_
|
|||||||
_xtimer_set64(timer, offset, offset >> 32);
|
_xtimer_set64(timer, offset, offset >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _callback_wakeup(void* arg)
|
|
||||||
{
|
|
||||||
thread_wakeup((kernel_pid_t)((intptr_t)arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
|
|
||||||
{
|
|
||||||
timer->callback = _callback_wakeup;
|
|
||||||
timer->arg = (void*) ((intptr_t)pid);
|
|
||||||
|
|
||||||
_xtimer_set(timer, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid)
|
|
||||||
{
|
|
||||||
timer->callback = _callback_wakeup;
|
|
||||||
timer->arg = (void*) ((intptr_t)pid);
|
|
||||||
|
|
||||||
_xtimer_set64(timer, offset, offset >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xtimer_now_timex(timex_t *out)
|
|
||||||
{
|
|
||||||
uint64_t now = xtimer_usec_from_ticks64(xtimer_now64());
|
|
||||||
|
|
||||||
out->seconds = div_u64_by_1000000(now);
|
|
||||||
out->microseconds = now - (out->seconds * US_PER_SEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepares the message to trigger the timeout.
|
/* Prepares the message to trigger the timeout.
|
||||||
* Additionally, the xtimer_t struct gets initialized.
|
* Additionally, the xtimer_t struct gets initialized.
|
||||||
*/
|
*/
|
||||||
@ -236,6 +208,36 @@ int _xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout_ticks)
|
|||||||
_xtimer_set_msg(&t, timeout_ticks, &tmsg, sched_active_pid);
|
_xtimer_set_msg(&t, timeout_ticks, &tmsg, sched_active_pid);
|
||||||
return _msg_wait(msg, &tmsg, &t);
|
return _msg_wait(msg, &tmsg, &t);
|
||||||
}
|
}
|
||||||
|
#endif /* MODULE_CORE_MSG */
|
||||||
|
|
||||||
|
static void _callback_wakeup(void* arg)
|
||||||
|
{
|
||||||
|
thread_wakeup((kernel_pid_t)((intptr_t)arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
|
||||||
|
{
|
||||||
|
timer->callback = _callback_wakeup;
|
||||||
|
timer->arg = (void*) ((intptr_t)pid);
|
||||||
|
|
||||||
|
_xtimer_set(timer, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid)
|
||||||
|
{
|
||||||
|
timer->callback = _callback_wakeup;
|
||||||
|
timer->arg = (void*) ((intptr_t)pid);
|
||||||
|
|
||||||
|
_xtimer_set64(timer, offset, offset >> 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
void xtimer_now_timex(timex_t *out)
|
||||||
|
{
|
||||||
|
uint64_t now = xtimer_usec_from_ticks64(xtimer_now64());
|
||||||
|
|
||||||
|
out->seconds = div_u64_by_1000000(now);
|
||||||
|
out->microseconds = now - (out->seconds * US_PER_SEC);
|
||||||
|
}
|
||||||
|
|
||||||
static void _mutex_timeout(void *arg)
|
static void _mutex_timeout(void *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
include ../Makefile.tests_common
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
USEMODULE += xtimer
|
USEMODULE += xtimer
|
||||||
|
DISABLE_MODULE := core_msg
|
||||||
|
|
||||||
# Port and pin configuration for probing with oscilloscope
|
# Port and pin configuration for probing with oscilloscope
|
||||||
# Define Test pin for hardware timer interrupt, hardware dependent
|
# Define Test pin for hardware timer interrupt, hardware dependent
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user