unified: Add missing arguments to K_TIMER_DEFINE()
It is now possible to specify the expiry and stop functions of a statically-defined timer, just as can be done for a dynamically-defined timer. [Part of fix to ZEP-1186] Change-Id: Ibb9096f3fdafdc6c904184587f86ecd52accdd66 Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
parent
a3f3de3741
commit
1342adbd63
2 changed files with 16 additions and 5 deletions
|
@ -484,9 +484,17 @@ struct k_timer {
|
|||
_DEBUG_TRACING_KERNEL_OBJECTS_NEXT_PTR(k_timer);
|
||||
};
|
||||
|
||||
#define K_TIMER_INITIALIZER(obj) \
|
||||
#define K_TIMER_INITIALIZER(obj, expiry, stop) \
|
||||
{ \
|
||||
.timeout.delta_ticks_from_prev = -1, \
|
||||
.timeout.wait_q = NULL, \
|
||||
.timeout.thread = NULL, \
|
||||
.timeout.func = _timer_expiration_handler, \
|
||||
.wait_q = SYS_DLIST_STATIC_INIT(&obj.wait_q), \
|
||||
.expiry_fn = expiry, \
|
||||
.stop_fn = stop, \
|
||||
.status = 0, \
|
||||
._legacy_data = NULL, \
|
||||
_DEBUG_TRACING_KERNEL_OBJECTS_INIT \
|
||||
}
|
||||
|
||||
|
@ -499,11 +507,13 @@ struct k_timer {
|
|||
* extern struct k_timer @a name;
|
||||
*
|
||||
* @param name Name of the timer variable.
|
||||
* @param expiry_fn Function to invoke each time timer expires.
|
||||
* @param stop_fn Function to invoke if timer is stopped while running.
|
||||
*/
|
||||
#define K_TIMER_DEFINE(name) \
|
||||
#define K_TIMER_DEFINE(name, expiry_fn, stop_fn) \
|
||||
struct k_timer name \
|
||||
__in_section(_k_timer, static, name) = \
|
||||
K_TIMER_INITIALIZER(name)
|
||||
K_TIMER_INITIALIZER(name, expiry_fn, stop_fn)
|
||||
|
||||
/**
|
||||
* @brief Initialize a timer.
|
||||
|
@ -2368,6 +2378,7 @@ extern void k_free(void *ptr);
|
|||
|
||||
extern int _is_thread_essential(void);
|
||||
extern void _init_static_threads(void);
|
||||
extern void _timer_expiration_handler(struct _timeout *t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ SYS_INIT(init_timer_module, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
|
|||
*
|
||||
* @return N/A
|
||||
*/
|
||||
static void timer_expiration_handler(struct _timeout *t)
|
||||
void _timer_expiration_handler(struct _timeout *t)
|
||||
{
|
||||
int key = irq_lock();
|
||||
struct k_timer *timer = CONTAINER_OF(t, struct k_timer, timeout);
|
||||
|
@ -97,7 +97,7 @@ void k_timer_init(struct k_timer *timer,
|
|||
timer->status = 0;
|
||||
|
||||
sys_dlist_init(&timer->wait_q);
|
||||
_init_timeout(&timer->timeout, timer_expiration_handler);
|
||||
_init_timeout(&timer->timeout, _timer_expiration_handler);
|
||||
SYS_TRACING_OBJ_INIT(k_timer, timer);
|
||||
|
||||
timer->_legacy_data = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue